1
# Copyright (C) 2005 Canonical Ltd
1
# Copyright (C) 2005-2011, 2016 Canonical Ltd
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
26
from bzrlib.branch import Branch
27
from bzrlib.errors import (
24
from breezy.errors import (
29
26
InvalidLineInBugsProperty,
32
from bzrlib.deprecated_graph import Graph
33
from bzrlib.revision import (find_present_ancestors,
35
from bzrlib.tests import TestCase, TestCaseWithTransport
36
from bzrlib.trace import mutter
37
from bzrlib.workingtree import WorkingTree
28
from breezy.revision import NULL_REVISION
29
from breezy.tests import TestCase, TestCaseWithTransport
30
from breezy.tests.matchers import MatchesAncestry
39
32
# We're allowed to test deprecated interfaces
40
33
warnings.filterwarnings('ignore',
41
34
'.*get_intervening_revisions was deprecated',
42
35
DeprecationWarning,
43
r'bzrlib\.tests\.test_revision')
36
r'breezy\.tests\.test_revision')
45
38
# XXX: Make this a method of a merge base case
46
39
def make_branches(self, format=None):
69
62
tree1.commit("Commit two", rev_id="a@u-0-1")
70
63
tree1.commit("Commit three", rev_id="a@u-0-2")
72
tree2 = tree1.bzrdir.sprout("branch2").open_workingtree()
65
tree2 = tree1.controldir.sprout("branch2").open_workingtree()
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.assertEqual(br2.last_revision(), 'b@u-0-4')
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.assertEqual(br2.last_revision(), 'b@u-0-5')
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])
82
graph = br1.repository.get_graph()
83
revhistory = list(graph.iter_lefthand_ancestry(br1.last_revision(),
84
[revision.NULL_REVISION]))
88
tree2.add_parent_tree_id(revhistory[4])
89
89
tree2.commit("Commit ten - ghost merge", rev_id="b@u-0-6")
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']),
124
124
if rev_id in br2_only and not branch is br2:
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))
127
MatchesAncestry(branch.repository, rev_id))
132
130
class TestIntermediateRevisions(TestCaseWithTransport):
135
133
TestCaseWithTransport.setUp(self)
136
134
self.br1, self.br2 = make_branches(self)
137
wt1 = self.br1.bzrdir.open_workingtree()
138
wt2 = self.br2.bzrdir.open_workingtree()
135
wt1 = self.br1.controldir.open_workingtree()
136
wt2 = self.br2.controldir.open_workingtree()
139
137
wt2.commit("Commit eleven", rev_id="b@u-0-7")
140
138
wt2.commit("Commit twelve", rev_id="b@u-0-8")
141
139
wt2.commit("Commit thirtteen", rev_id="b@u-0-9")
212
210
self.assertEqual('', r.get_summary())
214
def test_get_apparent_author(self):
215
r = revision.Revision('1')
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)
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)
239
212
def test_get_apparent_authors(self):
240
213
r = revision.Revision('1')
241
214
r.committer = 'A'