~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_revision.py

  • Committer: Kit Randel
  • Date: 2014-12-15 20:24:42 UTC
  • mto: This revision was merged to the branch mainline in revision 6602.
  • Revision ID: kit.randel@canonical.com-20141215202442-usf2ixhypqg8yh6q
added a note for bug-1400567 to the 2.7b release notes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Canonical Ltd
 
1
# Copyright (C) 2005-2011 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
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
 
import os
19
18
import warnings
20
19
 
21
20
from bzrlib import (
22
21
    bugtracker,
23
22
    revision,
24
 
    symbol_versioning,
25
23
    )
26
 
from bzrlib.branch import Branch
27
24
from bzrlib.errors import (
28
25
    InvalidBugStatus,
29
26
    InvalidLineInBugsProperty,
30
 
    NoSuchRevision,
31
27
    )
32
 
from bzrlib.deprecated_graph import Graph
33
 
from bzrlib.revision import (find_present_ancestors,
34
 
                             NULL_REVISION)
 
28
from bzrlib.revision import NULL_REVISION
35
29
from bzrlib.tests import TestCase, TestCaseWithTransport
36
 
from bzrlib.trace import mutter
37
 
from bzrlib.workingtree import WorkingTree
 
30
from bzrlib.tests.matchers import MatchesAncestry
38
31
 
39
32
# We're allowed to test deprecated interfaces
40
33
warnings.filterwarnings('ignore',
73
66
    br2 = tree2.branch
74
67
    tree2.commit("Commit four", rev_id="b@u-0-3")
75
68
    tree2.commit("Commit five", rev_id="b@u-0-4")
76
 
    revisions_2 = br2.revision_history()
77
 
    self.assertEquals(revisions_2[-1], 'b@u-0-4')
 
69
    self.assertEquals(br2.last_revision(), 'b@u-0-4')
78
70
 
79
71
    tree1.merge_from_branch(br2)
80
72
    tree1.commit("Commit six", rev_id="a@u-0-3")
81
73
    tree1.commit("Commit seven", rev_id="a@u-0-4")
82
74
    tree2.commit("Commit eight", rev_id="b@u-0-5")
83
 
    self.assertEquals(br2.revision_history()[-1], 'b@u-0-5')
 
75
    self.assertEquals(br2.last_revision(), 'b@u-0-5')
84
76
 
85
77
    tree1.merge_from_branch(br2)
86
78
    tree1.commit("Commit nine", rev_id="a@u-0-5")
87
79
    # DO NOT MERGE HERE - we WANT a GHOST.
88
 
    tree2.add_parent_tree_id(br1.revision_history()[4])
 
80
    br1.lock_read()
 
81
    try:
 
82
        graph = br1.repository.get_graph()
 
83
        revhistory = list(graph.iter_lefthand_ancestry(br1.last_revision(),
 
84
            [revision.NULL_REVISION]))
 
85
        revhistory.reverse()
 
86
    finally:
 
87
        br1.unlock()
 
88
    tree2.add_parent_tree_id(revhistory[4])
89
89
    tree2.commit("Commit ten - ghost merge", rev_id="b@u-0-6")
90
90
 
91
91
    return br1, br2
111
111
             ('a@u-0-5', ['a@u-0-0', 'a@u-0-1', 'a@u-0-2', 'a@u-0-3', 'a@u-0-4',
112
112
                          'b@u-0-3', 'b@u-0-4',
113
113
                          'b@u-0-5', 'a@u-0-5']),
114
 
             ('b@u-0-6', ['a@u-0-0', 'a@u-0-1', 'a@u-0-2',
 
114
             ('b@u-0-6', ['a@u-0-0', 'a@u-0-1', 'a@u-0-2', 'a@u-0-4',
115
115
                          'b@u-0-3', 'b@u-0-4',
116
116
                          'b@u-0-5', 'b@u-0-6']),
117
117
             ]
123
123
                    continue
124
124
                if rev_id in br2_only and not branch is br2:
125
125
                    continue
126
 
                mutter('ancestry of {%s}: %r',
127
 
                       rev_id, branch.repository.get_ancestry(rev_id))
128
 
                result = sorted(branch.repository.get_ancestry(rev_id))
129
 
                self.assertEquals(result, [None] + sorted(anc))
 
126
                self.assertThat(anc,
 
127
                    MatchesAncestry(branch.repository, rev_id))
130
128
 
131
129
 
132
130
class TestIntermediateRevisions(TestCaseWithTransport):