~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revision.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-08-17 07:52:09 UTC
  • mfrom: (1910.3.4 trivial)
  • Revision ID: pqm@pqm.ubuntu.com-20060817075209-e85a1f9e05ff8b87
(andrew) Trivial fixes to NotImplemented errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Canonical Ltd
 
1
# (C) 2005 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
23
23
    )
24
24
from bzrlib.branch import Branch
25
25
from bzrlib.errors import NoSuchRevision
26
 
from bzrlib.deprecated_graph import Graph
 
26
from bzrlib.graph import Graph
27
27
from bzrlib.revision import (find_present_ancestors, combined_graph,
28
28
                             common_ancestor,
29
29
                             is_ancestor, MultipleRevisionSources,
39
39
        r'bzrlib\.tests\.test_revision')
40
40
 
41
41
# XXX: Make this a method of a merge base case
42
 
def make_branches(self, format=None):
 
42
def make_branches(self):
43
43
    """Create two branches
44
44
 
45
45
    branch 1 has 6 commits, branch 2 has 3 commits
58
58
    so A is missing b6 at the start
59
59
    and B is missing a3, a4, a5
60
60
    """
61
 
    tree1 = self.make_branch_and_tree("branch1", format=format)
 
61
    tree1 = self.make_branch_and_tree("branch1")
62
62
    br1 = tree1.branch
63
63
    
64
64
    tree1.commit("Commit one", rev_id="a@u-0-0")
70
70
    tree2.commit("Commit four", rev_id="b@u-0-3")
71
71
    tree2.commit("Commit five", rev_id="b@u-0-4")
72
72
    revisions_2 = br2.revision_history()
73
 
    self.assertEquals(revisions_2[-1], 'b@u-0-4')
74
73
    
75
 
    tree1.merge_from_branch(br2)
 
74
    br1.fetch(br2)
 
75
    tree1.add_pending_merge(revisions_2[4])
 
76
    self.assertEquals(revisions_2[4], 'b@u-0-4')
76
77
    tree1.commit("Commit six", rev_id="a@u-0-3")
77
78
    tree1.commit("Commit seven", rev_id="a@u-0-4")
78
79
    tree2.commit("Commit eight", rev_id="b@u-0-5")
79
 
    self.assertEquals(br2.revision_history()[-1], 'b@u-0-5')
80
80
    
81
 
    tree1.merge_from_branch(br2)
 
81
    br1.fetch(br2)
 
82
    tree1.add_pending_merge(br2.revision_history()[5])
82
83
    tree1.commit("Commit nine", rev_id="a@u-0-5")
83
 
    # DO NOT MERGE HERE - we WANT a GHOST.
84
 
    tree2.add_parent_tree_id(br1.revision_history()[4])
 
84
    # DO NOT FETCH HERE - we WANT a GHOST.
 
85
    # br2.fetch(br1)
 
86
    tree2.add_pending_merge(br1.revision_history()[4])
85
87
    tree2.commit("Commit ten - ghost merge", rev_id="b@u-0-6")
86
88
    
87
89
    return br1, br2
156
158
        wt2.commit("Commit twelve", rev_id="b@u-0-8")
157
159
        wt2.commit("Commit thirtteen", rev_id="b@u-0-9")
158
160
 
159
 
        wt1.merge_from_branch(self.br2)
 
161
        self.br1.fetch(self.br2)
 
162
        wt1.add_pending_merge(self.br2.revision_history()[6])
160
163
        wt1.commit("Commit fourtten", rev_id="a@u-0-6")
161
164
 
162
 
        wt2.merge_from_branch(self.br1)
 
165
        self.br2.fetch(self.br1)
 
166
        wt2.add_pending_merge(self.br1.revision_history()[6])
163
167
        wt2.commit("Commit fifteen", rev_id="b@u-0-10")
164
168
 
165
169
        from bzrlib.revision import MultipleRevisionSources
234
238
        """
235
239
        br1, br2 = make_branches(self)
236
240
        source = MultipleRevisionSources(br1.repository, br2.repository)
237
 
        combined_1 = combined_graph(br1.last_revision(),
 
241
        combined_1 = combined_graph(br1.last_revision(), 
238
242
                                    br2.last_revision(), source)
239
243
        combined_2 = combined_graph(br2.last_revision(),
240
244
                                    br1.last_revision(), source)
287
291
        # in repo 2, which has A, the revision_graph()
288
292
        # should return A and B both.
289
293
        tree_1 = self.make_branch_and_tree('1')
290
 
        tree_1.set_parent_ids(['A'], allow_leftmost_as_ghost=True)
 
294
        tree_1.add_pending_merge('A')
291
295
        tree_1.commit('foo', rev_id='B', allow_pointless=True)
292
296
        tree_2 = self.make_branch_and_tree('2')
293
297
        tree_2.commit('bar', rev_id='A', allow_pointless=True)
296
300
        self.assertEqual({'B':['A'],
297
301
                          'A':[]},
298
302
                         source.get_revision_graph('B'))
299
 
 
300
 
 
301
 
class TestReservedId(TestCase):
302
 
 
303
 
    def test_is_reserved_id(self):
304
 
        self.assertEqual(True, revision.is_reserved_id(NULL_REVISION))
305
 
        self.assertEqual(True, revision.is_reserved_id(
306
 
            revision.CURRENT_REVISION))
307
 
        self.assertEqual(True, revision.is_reserved_id('arch:'))
308
 
        self.assertEqual(False, revision.is_reserved_id('null'))
309
 
        self.assertEqual(False, revision.is_reserved_id(
310
 
            'arch:a@example.com/c--b--v--r'))
311
 
        self.assertEqual(False, revision.is_reserved_id(None))
312
 
 
313
 
 
314
 
class TestRevisionMethods(TestCase):
315
 
 
316
 
    def test_get_summary(self):
317
 
        r = revision.Revision('1')
318
 
        r.message = 'a'
319
 
        self.assertEqual('a', r.get_summary())
320
 
        r.message = 'a\nb'
321
 
        self.assertEqual('a', r.get_summary())
322
 
        r.message = '\na\nb'
323
 
        self.assertEqual('a', r.get_summary())
324
 
 
325
 
    def test_get_apparent_author(self):
326
 
        r = revision.Revision('1')
327
 
        r.committer = 'A'
328
 
        self.assertEqual('A', r.get_apparent_author())
329
 
        r.properties['author'] = 'B'
330
 
        self.assertEqual('B', r.get_apparent_author())