1
# Copyright (C) 2005 Canonical Ltd
1
# Copyright (C) 2005-2011 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
21
20
from bzrlib import (
26
from bzrlib.branch import Branch
27
24
from bzrlib.errors import (
29
26
InvalidLineInBugsProperty,
32
from bzrlib.deprecated_graph import Graph
33
from bzrlib.revision import (find_present_ancestors,
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
39
32
# We're allowed to test deprecated interfaces
40
33
warnings.filterwarnings('ignore',
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')
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')
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):
208
206
self.assertEqual('a', r.get_summary())
209
207
r.message = '\na\nb'
210
208
self.assertEqual('a', r.get_summary())
212
def test_get_apparent_author(self):
213
r = revision.Revision('1')
215
author = self.applyDeprecated(
216
symbol_versioning.deprecated_in((1, 13, 0)),
217
r.get_apparent_author)
218
self.assertEqual('A', author)
219
r.properties['author'] = 'B'
220
author = self.applyDeprecated(
221
symbol_versioning.deprecated_in((1, 13, 0)),
222
r.get_apparent_author)
223
self.assertEqual('B', author)
224
r.properties['authors'] = 'C\nD'
225
author = self.applyDeprecated(
226
symbol_versioning.deprecated_in((1, 13, 0)),
227
r.get_apparent_author)
228
self.assertEqual('C', author)
230
def test_get_apparent_author_none(self):
231
r = revision.Revision('1')
232
author = self.applyDeprecated(
233
symbol_versioning.deprecated_in((1, 13, 0)),
234
r.get_apparent_author)
235
self.assertEqual(None, author)
210
self.assertEqual('', r.get_summary())
237
212
def test_get_apparent_authors(self):
238
213
r = revision.Revision('1')