/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revision.py

  • Committer: John Arbash Meinel
  • Date: 2008-07-09 21:42:24 UTC
  • mto: This revision was merged to the branch mainline in revision 3543.
  • Revision ID: john@arbash-meinel.com-20080709214224-r75k87r6a01pfc3h
Restore a real weave merge to 'bzr merge --weave'.

To do so efficiently, we only add the simple LCAs to the final weave
object, unless we run into complexities with the merge graph.
This gives the same effective result as adding all the texts,
with the advantage of not having to extract all of them.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
 
18
18
import os
19
19
import warnings
20
20
 
21
21
from bzrlib import (
22
 
    bugtracker,
23
22
    revision,
24
23
    symbol_versioning,
25
24
    )
26
25
from bzrlib.branch import Branch
27
 
from bzrlib.errors import (
28
 
    InvalidBugStatus,
29
 
    InvalidLineInBugsProperty,
30
 
    NoSuchRevision,
31
 
    )
 
26
from bzrlib.errors import NoSuchRevision
32
27
from bzrlib.deprecated_graph import Graph
33
28
from bzrlib.revision import (find_present_ancestors,
34
29
                             NULL_REVISION)
 
30
from bzrlib.symbol_versioning import one_three
35
31
from bzrlib.tests import TestCase, TestCaseWithTransport
36
32
from bzrlib.trace import mutter
37
33
from bzrlib.workingtree import WorkingTree
51
47
 
52
48
    the object graph is
53
49
    B:     A:
54
 
    a..0   a..0
 
50
    a..0   a..0 
55
51
    a..1   a..1
56
52
    a..2   a..2
57
53
    b..3   a..3 merges b..4
64
60
    """
65
61
    tree1 = self.make_branch_and_tree("branch1", format=format)
66
62
    br1 = tree1.branch
67
 
 
 
63
    
68
64
    tree1.commit("Commit one", rev_id="a@u-0-0")
69
65
    tree1.commit("Commit two", rev_id="a@u-0-1")
70
66
    tree1.commit("Commit three", rev_id="a@u-0-2")
71
67
 
72
 
    tree2 = tree1.bzrdir.sprout("branch2").open_workingtree()
 
68
    tree2 = tree1.bzrdir.clone("branch2").open_workingtree()
73
69
    br2 = tree2.branch
74
70
    tree2.commit("Commit four", rev_id="b@u-0-3")
75
71
    tree2.commit("Commit five", rev_id="b@u-0-4")
76
72
    revisions_2 = br2.revision_history()
77
73
    self.assertEquals(revisions_2[-1], 'b@u-0-4')
78
 
 
 
74
    
79
75
    tree1.merge_from_branch(br2)
80
76
    tree1.commit("Commit six", rev_id="a@u-0-3")
81
77
    tree1.commit("Commit seven", rev_id="a@u-0-4")
82
78
    tree2.commit("Commit eight", rev_id="b@u-0-5")
83
79
    self.assertEquals(br2.revision_history()[-1], 'b@u-0-5')
84
 
 
 
80
    
85
81
    tree1.merge_from_branch(br2)
86
82
    tree1.commit("Commit nine", rev_id="a@u-0-5")
87
83
    # DO NOT MERGE HERE - we WANT a GHOST.
88
84
    tree2.add_parent_tree_id(br1.revision_history()[4])
89
85
    tree2.commit("Commit ten - ghost merge", rev_id="b@u-0-6")
90
 
 
 
86
    
91
87
    return br1, br2
92
88
 
93
89
 
127
123
                       rev_id, branch.repository.get_ancestry(rev_id))
128
124
                result = sorted(branch.repository.get_ancestry(rev_id))
129
125
                self.assertEquals(result, [None] + sorted(anc))
130
 
 
 
126
    
131
127
 
132
128
class TestIntermediateRevisions(TestCaseWithTransport):
133
129
 
146
142
        wt2.merge_from_branch(self.br1)
147
143
        wt2.commit("Commit fifteen", rev_id="b@u-0-10")
148
144
 
 
145
        from bzrlib.revision import MultipleRevisionSources
 
146
        self.sources = self.applyDeprecated(one_three,
 
147
                        MultipleRevisionSources, self.br1.repository,
 
148
                                                 self.br2.repository)
 
149
 
 
150
 
149
151
 
150
152
class MockRevisionSource(object):
151
153
    """A RevisionSource that takes a pregenerated graph.
208
210
        self.assertEqual('a', r.get_summary())
209
211
        r.message = '\na\nb'
210
212
        self.assertEqual('a', r.get_summary())
211
 
        r.message = None
212
 
        self.assertEqual('', r.get_summary())
213
213
 
214
214
    def test_get_apparent_author(self):
215
215
        r = revision.Revision('1')
216
216
        r.committer = 'A'
217
 
        author = self.applyDeprecated(
218
 
                symbol_versioning.deprecated_in((1, 13, 0)),
219
 
                r.get_apparent_author)
220
 
        self.assertEqual('A', author)
221
 
        r.properties['author'] = 'B'
222
 
        author = self.applyDeprecated(
223
 
                symbol_versioning.deprecated_in((1, 13, 0)),
224
 
                r.get_apparent_author)
225
 
        self.assertEqual('B', author)
226
 
        r.properties['authors'] = 'C\nD'
227
 
        author = self.applyDeprecated(
228
 
                symbol_versioning.deprecated_in((1, 13, 0)),
229
 
                r.get_apparent_author)
230
 
        self.assertEqual('C', author)
231
 
 
232
 
    def test_get_apparent_author_none(self):
233
 
        r = revision.Revision('1')
234
 
        author = self.applyDeprecated(
235
 
                symbol_versioning.deprecated_in((1, 13, 0)),
236
 
                r.get_apparent_author)
237
 
        self.assertEqual(None, author)
238
 
 
239
 
    def test_get_apparent_authors(self):
240
 
        r = revision.Revision('1')
241
 
        r.committer = 'A'
242
 
        self.assertEqual(['A'], r.get_apparent_authors())
243
 
        r.properties['author'] = 'B'
244
 
        self.assertEqual(['B'], r.get_apparent_authors())
245
 
        r.properties['authors'] = 'C\nD'
246
 
        self.assertEqual(['C', 'D'], r.get_apparent_authors())
247
 
 
248
 
    def test_get_apparent_authors_no_committer(self):
249
 
        r = revision.Revision('1')
250
 
        self.assertEqual([], r.get_apparent_authors())
251
 
 
252
 
 
253
 
class TestRevisionBugs(TestCase):
254
 
    """Tests for getting the bugs that a revision is linked to."""
255
 
 
256
 
    def test_no_bugs(self):
257
 
        r = revision.Revision('1')
258
 
        self.assertEqual([], list(r.iter_bugs()))
259
 
 
260
 
    def test_some_bugs(self):
261
 
        r = revision.Revision(
262
 
            '1', properties={
263
 
                'bugs': bugtracker.encode_fixes_bug_urls(
264
 
                    ['http://example.com/bugs/1',
265
 
                     'http://launchpad.net/bugs/1234'])})
266
 
        self.assertEqual(
267
 
            [('http://example.com/bugs/1', bugtracker.FIXED),
268
 
             ('http://launchpad.net/bugs/1234', bugtracker.FIXED)],
269
 
            list(r.iter_bugs()))
270
 
 
271
 
    def test_no_status(self):
272
 
        r = revision.Revision(
273
 
            '1', properties={'bugs': 'http://example.com/bugs/1'})
274
 
        self.assertRaises(InvalidLineInBugsProperty, list, r.iter_bugs())
275
 
 
276
 
    def test_too_much_information(self):
277
 
        r = revision.Revision(
278
 
            '1', properties={'bugs': 'http://example.com/bugs/1 fixed bar'})
279
 
        self.assertRaises(InvalidLineInBugsProperty, list, r.iter_bugs())
280
 
 
281
 
    def test_invalid_status(self):
282
 
        r = revision.Revision(
283
 
            '1', properties={'bugs': 'http://example.com/bugs/1 faxed'})
284
 
        self.assertRaises(InvalidBugStatus, list, r.iter_bugs())
 
217
        self.assertEqual('A', r.get_apparent_author())
 
218
        r.properties['author'] = 'B'
 
219
        self.assertEqual('B', r.get_apparent_author())