bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
1 |
# Copyright (C) 2006 Canonical Ltd
|
2 |
#
|
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
"""Whitebox tests for annotate functionality."""
|
|
18 |
||
19 |
from cStringIO import StringIO |
|
20 |
||
21 |
from bzrlib import ( |
|
22 |
annotate, |
|
23 |
conflicts, |
|
24 |
errors, |
|
25 |
tests, |
|
26 |
trace, |
|
27 |
)
|
|
28 |
||
29 |
||
30 |
class TestAnnotate(tests.TestCaseWithTransport): |
|
31 |
||
32 |
def create_merged_trees(self): |
|
33 |
tree1 = self.make_branch_and_tree('tree1') |
|
34 |
self.build_tree_contents([('tree1/a', 'first\n')]) |
|
35 |
tree1.add(['a'], ['a-id']) |
|
36 |
tree1.commit('a', rev_id='rev-1', |
|
|
2182.3.12
by John Arbash Meinel
Force the timezone properly during tests which look at dates. |
37 |
committer="joe@foo.com", |
38 |
timestamp=1166046000.00, timezone=0) |
|
|
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
39 |
|
40 |
tree2 = tree1.bzrdir.clone('tree2').open_workingtree() |
|
41 |
||
42 |
self.build_tree_contents([('tree1/a', 'first\nsecond\n')]) |
|
43 |
tree1.commit('b', rev_id='rev-2', |
|
|
2182.3.12
by John Arbash Meinel
Force the timezone properly during tests which look at dates. |
44 |
committer='joe@foo.com', |
45 |
timestamp=1166046001.00, timezone=0) |
|
|
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
46 |
|
47 |
self.build_tree_contents([('tree2/a', 'first\nthird\n')]) |
|
48 |
tree2.commit('c', rev_id='rev-1_1_1', |
|
|
2182.3.12
by John Arbash Meinel
Force the timezone properly during tests which look at dates. |
49 |
committer="barry@foo.com", |
50 |
timestamp=1166046002.00, timezone=0) |
|
|
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
51 |
|
52 |
num_conflicts = tree1.merge_from_branch(tree2.branch) |
|
53 |
self.assertEqual(1, num_conflicts) |
|
54 |
||
55 |
self.build_tree_contents([('tree1/a', |
|
56 |
'first\nsecond\nthird\n')]) |
|
57 |
tree1.set_conflicts(conflicts.ConflictList()) |
|
58 |
tree1.commit('merge 2', rev_id='rev-3', |
|
|
2182.3.12
by John Arbash Meinel
Force the timezone properly during tests which look at dates. |
59 |
committer='sal@foo.com', |
60 |
timestamp=1166046003.00, timezone=0) |
|
|
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
61 |
return tree1, tree2 |
62 |
||
63 |
def create_deeply_merged_trees(self): |
|
64 |
tree1, tree2 = self.create_merged_trees() |
|
65 |
||
66 |
tree3 = tree2.bzrdir.clone('tree3').open_workingtree() |
|
67 |
||
68 |
tree2.commit('noop', rev_id='rev-1.1.2') |
|
69 |
self.assertEqual(0, tree1.merge_from_branch(tree2.branch)) |
|
70 |
tree1.commit('noop merge', rev_id='rev-4') |
|
71 |
||
72 |
self.build_tree_contents([('tree3/a', 'first\nthird\nfourth\n')]) |
|
|
2182.3.4
by John Arbash Meinel
add show-ids and test that nearby areas are collapsed without full |
73 |
tree3.commit('four', rev_id='rev-1_1_1_1_1', |
|
2182.3.12
by John Arbash Meinel
Force the timezone properly during tests which look at dates. |
74 |
committer='jerry@foo.com', |
75 |
timestamp=1166046003.00, timezone=0) |
|
|
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
76 |
|
77 |
tree4 = tree3.bzrdir.clone('tree4').open_workingtree() |
|
78 |
||
79 |
tree3.commit('noop', rev_id='rev-1.1.1.1.2', |
|
|
2182.3.12
by John Arbash Meinel
Force the timezone properly during tests which look at dates. |
80 |
committer='jerry@foo.com', |
81 |
timestamp=1166046004.00, timezone=0) |
|
|
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
82 |
self.assertEqual(0, tree1.merge_from_branch(tree3.branch)) |
83 |
tree1.commit('merge four', rev_id='rev-5') |
|
84 |
||
|
2182.3.4
by John Arbash Meinel
add show-ids and test that nearby areas are collapsed without full |
85 |
self.build_tree_contents([('tree4/a', |
86 |
'first\nthird\nfourth\nfifth\nsixth\n')]) |
|
87 |
tree4.commit('five and six', rev_id='rev-1_1_1_1_1_1_1', |
|
|
2182.3.12
by John Arbash Meinel
Force the timezone properly during tests which look at dates. |
88 |
committer='george@foo.com', |
89 |
timestamp=1166046005.00, timezone=0) |
|
|
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
90 |
self.assertEqual(0, tree1.merge_from_branch(tree4.branch)) |
|
2182.3.4
by John Arbash Meinel
add show-ids and test that nearby areas are collapsed without full |
91 |
tree1.commit('merge five and six', rev_id='rev-6') |
|
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
92 |
return tree1 |
93 |
||
94 |
def test_annotate_shows_dotted_revnos(self): |
|
95 |
tree1, tree2 = self.create_merged_trees() |
|
96 |
||
97 |
sio = StringIO() |
|
98 |
annotate.annotate_file(tree1.branch, 'rev-3', 'a-id', |
|
99 |
to_file=sio) |
|
100 |
self.assertEqualDiff('1 joe@foo | first\n' |
|
101 |
'2 joe@foo | second\n' |
|
102 |
'1.1.1 barry@f | third\n', |
|
103 |
sio.getvalue()) |
|
104 |
||
105 |
def test_annotate_limits_dotted_revnos(self): |
|
106 |
"""Annotate should limit dotted revnos to a depth of 12""" |
|
107 |
tree1 = self.create_deeply_merged_trees() |
|
108 |
||
109 |
sio = StringIO() |
|
110 |
annotate.annotate_file(tree1.branch, 'rev-6', 'a-id', |
|
|
2182.3.4
by John Arbash Meinel
add show-ids and test that nearby areas are collapsed without full |
111 |
to_file=sio, verbose=False, full=False) |
112 |
self.assertEqualDiff('1 joe@foo | first\n' |
|
113 |
'2 joe@foo | second\n' |
|
114 |
'1.1.1 barry@f | third\n' |
|
115 |
'1.1.1.1.1 jerry@f | fourth\n' |
|
116 |
'1.1.1.1.1.1> george@ | fifth\n' |
|
117 |
' | sixth\n', |
|
118 |
sio.getvalue()) |
|
119 |
||
120 |
sio = StringIO() |
|
121 |
annotate.annotate_file(tree1.branch, 'rev-6', 'a-id', |
|
122 |
to_file=sio, verbose=False, full=True) |
|
123 |
self.assertEqualDiff('1 joe@foo | first\n' |
|
124 |
'2 joe@foo | second\n' |
|
125 |
'1.1.1 barry@f | third\n' |
|
126 |
'1.1.1.1.1 jerry@f | fourth\n' |
|
127 |
'1.1.1.1.1.1> george@ | fifth\n' |
|
128 |
'1.1.1.1.1.1> george@ | sixth\n', |
|
|
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
129 |
sio.getvalue()) |
130 |
||
131 |
# verbose=True shows everything, the full revno, user id, and date
|
|
132 |
sio = StringIO() |
|
133 |
annotate.annotate_file(tree1.branch, 'rev-6', 'a-id', |
|
|
2182.3.4
by John Arbash Meinel
add show-ids and test that nearby areas are collapsed without full |
134 |
to_file=sio, verbose=True, full=False) |
135 |
self.assertEqualDiff('1 joe@foo.com 20061213 | first\n' |
|
136 |
'2 joe@foo.com 20061213 | second\n' |
|
137 |
'1.1.1 barry@foo.com 20061213 | third\n' |
|
138 |
'1.1.1.1.1 jerry@foo.com 20061213 | fourth\n' |
|
139 |
'1.1.1.1.1.1.1 george@foo.com 20061213 | fifth\n' |
|
140 |
' | sixth\n', |
|
141 |
sio.getvalue()) |
|
142 |
||
143 |
sio = StringIO() |
|
144 |
annotate.annotate_file(tree1.branch, 'rev-6', 'a-id', |
|
145 |
to_file=sio, verbose=True, full=True) |
|
146 |
self.assertEqualDiff('1 joe@foo.com 20061213 | first\n' |
|
147 |
'2 joe@foo.com 20061213 | second\n' |
|
148 |
'1.1.1 barry@foo.com 20061213 | third\n' |
|
149 |
'1.1.1.1.1 jerry@foo.com 20061213 | fourth\n' |
|
150 |
'1.1.1.1.1.1.1 george@foo.com 20061213 | fifth\n' |
|
151 |
'1.1.1.1.1.1.1 george@foo.com 20061213 | sixth\n', |
|
152 |
sio.getvalue()) |
|
153 |
||
154 |
def test_annotate_show_ids(self): |
|
155 |
tree1 = self.create_deeply_merged_trees() |
|
156 |
||
157 |
sio = StringIO() |
|
158 |
annotate.annotate_file(tree1.branch, 'rev-6', 'a-id', |
|
159 |
to_file=sio, show_ids=True, full=False) |
|
160 |
||
161 |
# It looks better with real revision ids :)
|
|
162 |
self.assertEqualDiff(' rev-1 | first\n' |
|
163 |
' rev-2 | second\n' |
|
164 |
' rev-1_1_1 | third\n' |
|
165 |
' rev-1_1_1_1_1 | fourth\n' |
|
166 |
'rev-1_1_1_1_1_1_1 | fifth\n' |
|
167 |
' | sixth\n', |
|
168 |
sio.getvalue()) |
|
169 |
||
170 |
sio = StringIO() |
|
171 |
annotate.annotate_file(tree1.branch, 'rev-6', 'a-id', |
|
172 |
to_file=sio, show_ids=True, full=True) |
|
173 |
||
174 |
self.assertEqualDiff(' rev-1 | first\n' |
|
175 |
' rev-2 | second\n' |
|
176 |
' rev-1_1_1 | third\n' |
|
177 |
' rev-1_1_1_1_1 | fourth\n' |
|
178 |
'rev-1_1_1_1_1_1_1 | fifth\n' |
|
179 |
'rev-1_1_1_1_1_1_1 | sixth\n', |
|
|
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
180 |
sio.getvalue()) |