5557.1.15
by John Arbash Meinel
Merge bzr.dev 5597 to resolve NEWS, aka bzr-2.3.txt |
1 |
# Copyright (C) 2006-2009, 2011 Canonical Ltd
|
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
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
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
16 |
|
17 |
"""Whitebox tests for annotate functionality."""
|
|
18 |
||
2593.1.1
by Adeodato Simó
Improve annotate to prevent unicode exceptions in certain situations. |
19 |
import codecs |
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
20 |
from cStringIO import StringIO |
21 |
||
22 |
from bzrlib import ( |
|
23 |
annotate, |
|
5815.3.9
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
24 |
symbol_versioning, |
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
25 |
tests, |
26 |
)
|
|
27 |
||
28 |
||
1551.9.19
by Aaron Bentley
Merge from bzr.dev |
29 |
def annotation(text): |
30 |
return [tuple(l.split(' ', 1)) for l in text.splitlines(True)] |
|
31 |
||
32 |
||
33 |
parent_1 = annotation("""\ |
|
34 |
rev1 a
|
|
35 |
rev2 b
|
|
36 |
rev3 c
|
|
37 |
rev4 d
|
|
38 |
rev5 e
|
|
39 |
""") |
|
40 |
||
41 |
||
42 |
parent_2 = annotation("""\ |
|
43 |
rev1 a
|
|
44 |
rev3 c
|
|
45 |
rev4 d
|
|
46 |
rev6 f
|
|
47 |
rev7 e
|
|
48 |
rev8 h
|
|
49 |
""") |
|
50 |
||
51 |
||
52 |
expected_2_1 = annotation("""\ |
|
53 |
rev1 a
|
|
54 |
blahblah b
|
|
55 |
rev3 c
|
|
56 |
rev4 d
|
|
57 |
rev7 e
|
|
58 |
""") |
|
59 |
||
60 |
||
61 |
# a: in both, same value, kept
|
|
62 |
# b: in 1, kept
|
|
63 |
# c: in both, same value, kept
|
|
64 |
# d: in both, same value, kept
|
|
65 |
# e: 1 and 2 disagree, so it goes to blahblah
|
|
66 |
# f: in 2, but not in new, so ignored
|
|
67 |
# g: not in 1 or 2, so it goes to blahblah
|
|
68 |
# h: only in parent 2, so 2 gets it
|
|
69 |
expected_1_2_2 = annotation("""\ |
|
70 |
rev1 a
|
|
71 |
rev2 b
|
|
72 |
rev3 c
|
|
73 |
rev4 d
|
|
74 |
blahblah e
|
|
75 |
blahblah g
|
|
76 |
rev8 h
|
|
77 |
""") |
|
78 |
||
79 |
||
80 |
new_1 = """\ |
|
81 |
a
|
|
82 |
b
|
|
83 |
c
|
|
84 |
d
|
|
85 |
e
|
|
86 |
""".splitlines(True) |
|
87 |
||
2770.1.1
by Aaron Bentley
Initial implmentation of plain knit annotation |
88 |
expected_1 = annotation("""\ |
89 |
blahblah a
|
|
90 |
blahblah b
|
|
91 |
blahblah c
|
|
92 |
blahblah d
|
|
93 |
blahblah e
|
|
94 |
""") |
|
95 |
||
1551.9.19
by Aaron Bentley
Merge from bzr.dev |
96 |
|
97 |
new_2 = """\ |
|
98 |
a
|
|
99 |
b
|
|
100 |
c
|
|
101 |
d
|
|
102 |
e
|
|
103 |
g
|
|
104 |
h
|
|
105 |
""".splitlines(True) |
|
106 |
||
107 |
||
3224.1.4
by John Arbash Meinel
Add a *failing* test to expose why we need better handling when a line is introduced on two sides of a merge. |
108 |
# For the 'duplicate' series, both sides introduce the same change, which then
|
109 |
# gets merged around. The last-modified should properly reflect this.
|
|
110 |
# We always change the fourth line so that the file is properly tracked as
|
|
111 |
# being modified in each revision. In reality, this probably would happen over
|
|
112 |
# many revisions, and it would be a different line that changes.
|
|
113 |
# BASE
|
|
114 |
# |\
|
|
115 |
# A B # line should be annotated as new for A and B
|
|
116 |
# |\|
|
|
3588.3.1
by John Arbash Meinel
Simple patch to the annotate logic to handle bug #232188 |
117 |
# C D # line should 'converge' and say A
|
3224.1.4
by John Arbash Meinel
Add a *failing* test to expose why we need better handling when a line is introduced on two sides of a merge. |
118 |
# |/
|
119 |
# E # D should supersede A and stay as D (not become E because C references
|
|
120 |
# A)
|
|
121 |
duplicate_base = annotation("""\ |
|
122 |
rev-base first
|
|
123 |
rev-base second
|
|
124 |
rev-base third
|
|
125 |
rev-base fourth-base
|
|
126 |
""") |
|
127 |
||
128 |
duplicate_A = annotation("""\ |
|
129 |
rev-base first
|
|
130 |
rev-A alt-second
|
|
131 |
rev-base third
|
|
132 |
rev-A fourth-A
|
|
133 |
""") |
|
134 |
||
135 |
duplicate_B = annotation("""\ |
|
136 |
rev-base first
|
|
137 |
rev-B alt-second
|
|
138 |
rev-base third
|
|
139 |
rev-B fourth-B
|
|
140 |
""") |
|
141 |
||
142 |
duplicate_C = annotation("""\ |
|
143 |
rev-base first
|
|
144 |
rev-A alt-second
|
|
145 |
rev-base third
|
|
146 |
rev-C fourth-C
|
|
147 |
""") |
|
148 |
||
149 |
duplicate_D = annotation("""\ |
|
150 |
rev-base first
|
|
3588.3.1
by John Arbash Meinel
Simple patch to the annotate logic to handle bug #232188 |
151 |
rev-A alt-second
|
3224.1.4
by John Arbash Meinel
Add a *failing* test to expose why we need better handling when a line is introduced on two sides of a merge. |
152 |
rev-base third
|
153 |
rev-D fourth-D
|
|
154 |
""") |
|
155 |
||
156 |
duplicate_E = annotation("""\ |
|
157 |
rev-base first
|
|
3588.3.1
by John Arbash Meinel
Simple patch to the annotate logic to handle bug #232188 |
158 |
rev-A alt-second
|
3224.1.4
by John Arbash Meinel
Add a *failing* test to expose why we need better handling when a line is introduced on two sides of a merge. |
159 |
rev-base third
|
160 |
rev-E fourth-E
|
|
161 |
""") |
|
162 |
||
163 |
||
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
164 |
class TestAnnotate(tests.TestCaseWithTransport): |
165 |
||
166 |
def create_merged_trees(self): |
|
2245.3.1
by John Arbash Meinel
bzr annotate should use Branch's dotted revnos. |
167 |
"""create 2 trees with merges between them.
|
168 |
||
169 |
rev-1 --+
|
|
170 |
| |
|
|
171 |
rev-2 rev-1_1_1
|
|
172 |
| |
|
|
173 |
+------+
|
|
174 |
|
|
|
175 |
rev-3
|
|
176 |
"""
|
|
4454.3.24
by John Arbash Meinel
update BranchBuilder to support 'committer' |
177 |
builder = self.make_branch_builder('branch') |
178 |
builder.start_series() |
|
179 |
self.addCleanup(builder.finish_series) |
|
180 |
builder.build_snapshot('rev-1', None, [ |
|
181 |
('add', ('', 'root-id', 'directory', None)), |
|
182 |
('add', ('a', 'a-id', 'file', 'first\n')), |
|
4523.2.1
by Vincent Ladeuil
Fix TZ-dependent tests. |
183 |
], timestamp=1166046000.00, timezone=0, committer="joe@foo.com") |
4454.3.24
by John Arbash Meinel
update BranchBuilder to support 'committer' |
184 |
builder.build_snapshot('rev-2', ['rev-1'], [ |
185 |
('modify', ('a-id', 'first\nsecond\n')), |
|
4523.2.1
by Vincent Ladeuil
Fix TZ-dependent tests. |
186 |
], timestamp=1166046001.00, timezone=0, committer="joe@foo.com") |
4454.3.24
by John Arbash Meinel
update BranchBuilder to support 'committer' |
187 |
builder.build_snapshot('rev-1_1_1', ['rev-1'], [ |
188 |
('modify', ('a-id', 'first\nthird\n')), |
|
4523.2.1
by Vincent Ladeuil
Fix TZ-dependent tests. |
189 |
], timestamp=1166046002.00, timezone=0, committer="barry@foo.com") |
4454.3.24
by John Arbash Meinel
update BranchBuilder to support 'committer' |
190 |
builder.build_snapshot('rev-3', ['rev-2', 'rev-1_1_1'], [ |
191 |
('modify', ('a-id', 'first\nsecond\nthird\n')), |
|
4523.2.1
by Vincent Ladeuil
Fix TZ-dependent tests. |
192 |
], timestamp=1166046003.00, timezone=0, committer="sal@foo.com") |
4454.3.24
by John Arbash Meinel
update BranchBuilder to support 'committer' |
193 |
return builder |
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
194 |
|
195 |
def create_deeply_merged_trees(self): |
|
2245.3.1
by John Arbash Meinel
bzr annotate should use Branch's dotted revnos. |
196 |
"""Create some trees with a more complex merge history.
|
197 |
||
198 |
rev-1 --+
|
|
199 |
| |
|
|
200 |
rev-2 rev-1_1_1 --+
|
|
201 |
| | |
|
|
202 |
+------+ |
|
|
203 |
| | |
|
|
3170.3.4
by John Arbash Meinel
Update the tests for the new revision numbering. |
204 |
rev-3 rev-1_1_2 rev-1_2_1 ------+
|
2245.3.1
by John Arbash Meinel
bzr annotate should use Branch's dotted revnos. |
205 |
| | | |
|
206 |
+------+ | |
|
|
207 |
| | |
|
|
3170.3.4
by John Arbash Meinel
Update the tests for the new revision numbering. |
208 |
rev-4 rev-1_2_2 rev-1_3_1
|
2245.3.1
by John Arbash Meinel
bzr annotate should use Branch's dotted revnos. |
209 |
| | |
|
210 |
+-----------------+ |
|
|
211 |
| |
|
|
212 |
rev-5 |
|
|
213 |
| |
|
|
214 |
+--------------------------------+
|
|
215 |
|
|
|
216 |
rev-6
|
|
217 |
"""
|
|
4454.3.24
by John Arbash Meinel
update BranchBuilder to support 'committer' |
218 |
builder = self.create_merged_trees() |
219 |
builder.build_snapshot('rev-1_1_2', ['rev-1_1_1'], []) |
|
220 |
builder.build_snapshot('rev-4', ['rev-3', 'rev-1_1_2'], []) |
|
221 |
builder.build_snapshot('rev-1_2_1', ['rev-1_1_1'], [ |
|
222 |
('modify', ('a-id', 'first\nthird\nfourth\n')), |
|
4523.2.1
by Vincent Ladeuil
Fix TZ-dependent tests. |
223 |
], timestamp=1166046003.00, timezone=0, committer="jerry@foo.com") |
4454.3.24
by John Arbash Meinel
update BranchBuilder to support 'committer' |
224 |
builder.build_snapshot('rev-1_2_2', ['rev-1_2_1'], [], |
4523.2.1
by Vincent Ladeuil
Fix TZ-dependent tests. |
225 |
timestamp=1166046004.00, timezone=0, committer="jerry@foo.com") |
4454.3.24
by John Arbash Meinel
update BranchBuilder to support 'committer' |
226 |
builder.build_snapshot('rev-5', ['rev-4', 'rev-1_2_2'], [ |
227 |
('modify', ('a-id', 'first\nsecond\nthird\nfourth\n')), |
|
4523.2.1
by Vincent Ladeuil
Fix TZ-dependent tests. |
228 |
], timestamp=1166046004.00, timezone=0, committer="jerry@foo.com") |
4454.3.24
by John Arbash Meinel
update BranchBuilder to support 'committer' |
229 |
builder.build_snapshot('rev-1_3_1', ['rev-1_2_1'], [ |
230 |
('modify', ('a-id', 'first\nthird\nfourth\nfifth\nsixth\n')), |
|
4523.2.1
by Vincent Ladeuil
Fix TZ-dependent tests. |
231 |
], timestamp=1166046005.00, timezone=0, committer="george@foo.com") |
4454.3.24
by John Arbash Meinel
update BranchBuilder to support 'committer' |
232 |
builder.build_snapshot('rev-6', ['rev-5', 'rev-1_3_1'], [ |
233 |
('modify', ('a-id', |
|
234 |
'first\nsecond\nthird\nfourth\nfifth\nsixth\n')), |
|
235 |
])
|
|
236 |
return builder |
|
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
237 |
|
3224.1.4
by John Arbash Meinel
Add a *failing* test to expose why we need better handling when a line is introduced on two sides of a merge. |
238 |
def create_duplicate_lines_tree(self): |
4454.3.25
by John Arbash Meinel
Use BranchBuilder for duplicate_lines_tree |
239 |
builder = self.make_branch_builder('branch') |
240 |
builder.start_series() |
|
241 |
self.addCleanup(builder.finish_series) |
|
3224.1.4
by John Arbash Meinel
Add a *failing* test to expose why we need better handling when a line is introduced on two sides of a merge. |
242 |
base_text = ''.join(l for r, l in duplicate_base) |
243 |
a_text = ''.join(l for r, l in duplicate_A) |
|
244 |
b_text = ''.join(l for r, l in duplicate_B) |
|
245 |
c_text = ''.join(l for r, l in duplicate_C) |
|
246 |
d_text = ''.join(l for r, l in duplicate_D) |
|
247 |
e_text = ''.join(l for r, l in duplicate_E) |
|
4454.3.25
by John Arbash Meinel
Use BranchBuilder for duplicate_lines_tree |
248 |
builder.build_snapshot('rev-base', None, [ |
249 |
('add', ('', 'root-id', 'directory', None)), |
|
250 |
('add', ('file', 'file-id', 'file', base_text)), |
|
251 |
])
|
|
252 |
builder.build_snapshot('rev-A', ['rev-base'], [ |
|
253 |
('modify', ('file-id', a_text))]) |
|
254 |
builder.build_snapshot('rev-B', ['rev-base'], [ |
|
255 |
('modify', ('file-id', b_text))]) |
|
256 |
builder.build_snapshot('rev-C', ['rev-A'], [ |
|
257 |
('modify', ('file-id', c_text))]) |
|
258 |
builder.build_snapshot('rev-D', ['rev-B', 'rev-A'], [ |
|
259 |
('modify', ('file-id', d_text))]) |
|
260 |
builder.build_snapshot('rev-E', ['rev-C', 'rev-D'], [ |
|
261 |
('modify', ('file-id', e_text))]) |
|
262 |
return builder |
|
3224.1.4
by John Arbash Meinel
Add a *failing* test to expose why we need better handling when a line is introduced on two sides of a merge. |
263 |
|
5815.3.7
by Jelmer Vernooij
Factor out assertAnnotateEqualDiff. |
264 |
def assertAnnotateEqualDiff(self, actual, expected): |
3224.1.4
by John Arbash Meinel
Add a *failing* test to expose why we need better handling when a line is introduced on two sides of a merge. |
265 |
if actual != expected: |
266 |
# Create an easier to understand diff when the lines don't actually
|
|
267 |
# match
|
|
268 |
self.assertEqualDiff(''.join('\t'.join(l) for l in expected), |
|
269 |
''.join('\t'.join(l) for l in actual)) |
|
270 |
||
5815.3.8
by Jelmer Vernooij
Add convenience method for testing annotate_file_revision_tree. |
271 |
def assertBranchAnnotate(self, expected, branch, file_id, revision_id, |
272 |
verbose=False, full=False, show_ids=False): |
|
273 |
tree = branch.repository.revision_tree(revision_id) |
|
274 |
to_file = StringIO() |
|
5815.3.14
by Jelmer Vernooij
Kill annotate_file_revision_tree() in favor annotate_file_tree(). |
275 |
annotate.annotate_file_tree(tree, file_id, to_file, |
5815.3.8
by Jelmer Vernooij
Add convenience method for testing annotate_file_revision_tree. |
276 |
verbose=verbose, full=full, show_ids=show_ids, branch=branch) |
277 |
self.assertAnnotateEqualDiff(to_file.getvalue(), expected) |
|
278 |
||
5815.3.7
by Jelmer Vernooij
Factor out assertAnnotateEqualDiff. |
279 |
def assertRepoAnnotate(self, expected, repo, file_id, revision_id): |
280 |
"""Assert that the revision is properly annotated."""
|
|
281 |
actual = list(repo.revision_tree(revision_id).annotate_iter(file_id)) |
|
282 |
self.assertAnnotateEqualDiff(actual, expected) |
|
283 |
||
3224.1.4
by John Arbash Meinel
Add a *failing* test to expose why we need better handling when a line is introduced on two sides of a merge. |
284 |
def test_annotate_duplicate_lines(self): |
3689.1.4
by John Arbash Meinel
Doc strings that reference repository_implementations |
285 |
# XXX: Should this be a per_repository test?
|
4454.3.25
by John Arbash Meinel
Use BranchBuilder for duplicate_lines_tree |
286 |
builder = self.create_duplicate_lines_tree() |
287 |
repo = builder.get_branch().repository |
|
3224.1.4
by John Arbash Meinel
Add a *failing* test to expose why we need better handling when a line is introduced on two sides of a merge. |
288 |
repo.lock_read() |
289 |
self.addCleanup(repo.unlock) |
|
290 |
self.assertRepoAnnotate(duplicate_base, repo, 'file-id', 'rev-base') |
|
291 |
self.assertRepoAnnotate(duplicate_A, repo, 'file-id', 'rev-A') |
|
292 |
self.assertRepoAnnotate(duplicate_B, repo, 'file-id', 'rev-B') |
|
293 |
self.assertRepoAnnotate(duplicate_C, repo, 'file-id', 'rev-C') |
|
294 |
self.assertRepoAnnotate(duplicate_D, repo, 'file-id', 'rev-D') |
|
295 |
self.assertRepoAnnotate(duplicate_E, repo, 'file-id', 'rev-E') |
|
296 |
||
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
297 |
def test_annotate_shows_dotted_revnos(self): |
4454.3.24
by John Arbash Meinel
update BranchBuilder to support 'committer' |
298 |
builder = self.create_merged_trees() |
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
299 |
|
5815.3.8
by Jelmer Vernooij
Add convenience method for testing annotate_file_revision_tree. |
300 |
self.assertBranchAnnotate('1 joe@foo | first\n' |
5815.3.9
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
301 |
'2 joe@foo | second\n' |
302 |
'1.1.1 barry@f | third\n', |
|
303 |
builder.get_branch(), 'a-id', 'rev-3') |
|
304 |
||
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
305 |
def test_annotate_limits_dotted_revnos(self): |
306 |
"""Annotate should limit dotted revnos to a depth of 12"""
|
|
4454.3.24
by John Arbash Meinel
update BranchBuilder to support 'committer' |
307 |
builder = self.create_deeply_merged_trees() |
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
308 |
|
5815.3.9
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
309 |
self.assertBranchAnnotate('1 joe@foo | first\n' |
310 |
'2 joe@foo | second\n' |
|
311 |
'1.1.1 barry@f | third\n' |
|
312 |
'1.2.1 jerry@f | fourth\n' |
|
313 |
'1.3.1 george@ | fifth\n' |
|
314 |
' | sixth\n', |
|
315 |
builder.get_branch(), 'a-id', 'rev-6', |
|
316 |
verbose=False, full=False) |
|
2182.3.4
by John Arbash Meinel
add show-ids and test that nearby areas are collapsed without full |
317 |
|
5815.3.9
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
318 |
self.assertBranchAnnotate('1 joe@foo | first\n' |
319 |
'2 joe@foo | second\n' |
|
320 |
'1.1.1 barry@f | third\n' |
|
321 |
'1.2.1 jerry@f | fourth\n' |
|
322 |
'1.3.1 george@ | fifth\n' |
|
323 |
'1.3.1 george@ | sixth\n', |
|
324 |
builder.get_branch(), 'a-id', 'rev-6', |
|
325 |
verbose=False, full=True) |
|
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
326 |
|
327 |
# verbose=True shows everything, the full revno, user id, and date
|
|
5815.3.9
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
328 |
self.assertBranchAnnotate('1 joe@foo.com 20061213 | first\n' |
329 |
'2 joe@foo.com 20061213 | second\n' |
|
330 |
'1.1.1 barry@foo.com 20061213 | third\n' |
|
331 |
'1.2.1 jerry@foo.com 20061213 | fourth\n' |
|
332 |
'1.3.1 george@foo.com 20061213 | fifth\n' |
|
333 |
' | sixth\n', |
|
334 |
builder.get_branch(), 'a-id', 'rev-6', |
|
335 |
verbose=True, full=False) |
|
2182.3.4
by John Arbash Meinel
add show-ids and test that nearby areas are collapsed without full |
336 |
|
5815.3.9
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
337 |
self.assertBranchAnnotate('1 joe@foo.com 20061213 | first\n' |
338 |
'2 joe@foo.com 20061213 | second\n' |
|
339 |
'1.1.1 barry@foo.com 20061213 | third\n' |
|
340 |
'1.2.1 jerry@foo.com 20061213 | fourth\n' |
|
341 |
'1.3.1 george@foo.com 20061213 | fifth\n' |
|
342 |
'1.3.1 george@foo.com 20061213 | sixth\n', |
|
343 |
builder.get_branch(), 'a-id', 'rev-6', |
|
344 |
verbose=True, full=True) |
|
2245.3.1
by John Arbash Meinel
bzr annotate should use Branch's dotted revnos. |
345 |
|
346 |
def test_annotate_uses_branch_context(self): |
|
347 |
"""Dotted revnos should use the Branch context.
|
|
348 |
||
349 |
When annotating a non-mainline revision, the annotation should still
|
|
350 |
use dotted revnos from the mainline.
|
|
351 |
"""
|
|
4454.3.24
by John Arbash Meinel
update BranchBuilder to support 'committer' |
352 |
builder = self.create_deeply_merged_trees() |
2245.3.1
by John Arbash Meinel
bzr annotate should use Branch's dotted revnos. |
353 |
|
5815.3.9
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
354 |
self.assertBranchAnnotate('1 joe@foo | first\n' |
355 |
'1.1.1 barry@f | third\n' |
|
356 |
'1.2.1 jerry@f | fourth\n' |
|
357 |
'1.3.1 george@ | fifth\n' |
|
358 |
' | sixth\n', |
|
359 |
builder.get_branch(), 'a-id', 'rev-1_3_1', |
|
360 |
verbose=False, full=False) |
|
2245.3.1
by John Arbash Meinel
bzr annotate should use Branch's dotted revnos. |
361 |
|
2182.3.4
by John Arbash Meinel
add show-ids and test that nearby areas are collapsed without full |
362 |
def test_annotate_show_ids(self): |
4454.3.24
by John Arbash Meinel
update BranchBuilder to support 'committer' |
363 |
builder = self.create_deeply_merged_trees() |
2182.3.4
by John Arbash Meinel
add show-ids and test that nearby areas are collapsed without full |
364 |
|
365 |
# It looks better with real revision ids :)
|
|
5815.3.9
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
366 |
self.assertBranchAnnotate(' rev-1 | first\n' |
367 |
' rev-2 | second\n' |
|
368 |
'rev-1_1_1 | third\n' |
|
369 |
'rev-1_2_1 | fourth\n' |
|
370 |
'rev-1_3_1 | fifth\n' |
|
371 |
' | sixth\n', |
|
372 |
builder.get_branch(), 'a-id', 'rev-6', |
|
373 |
show_ids=True, full=False) |
|
374 |
||
375 |
self.assertBranchAnnotate(' rev-1 | first\n' |
|
376 |
' rev-2 | second\n' |
|
377 |
'rev-1_1_1 | third\n' |
|
378 |
'rev-1_2_1 | fourth\n' |
|
379 |
'rev-1_3_1 | fifth\n' |
|
380 |
'rev-1_3_1 | sixth\n', |
|
381 |
builder.get_branch(), 'a-id', 'rev-6', |
|
382 |
show_ids=True, full=True) |
|
1551.9.19
by Aaron Bentley
Merge from bzr.dev |
383 |
|
2593.1.1
by Adeodato Simó
Improve annotate to prevent unicode exceptions in certain situations. |
384 |
def test_annotate_unicode_author(self): |
385 |
tree1 = self.make_branch_and_tree('tree1') |
|
386 |
||
387 |
self.build_tree_contents([('tree1/a', 'adi\xc3\xb3s')]) |
|
388 |
tree1.add(['a'], ['a-id']) |
|
389 |
tree1.commit('a', rev_id='rev-1', |
|
390 |
committer=u'Pepe P\xe9rez <pperez@ejemplo.com>', |
|
391 |
timestamp=1166046000.00, timezone=0) |
|
392 |
||
393 |
self.build_tree_contents([('tree1/b', 'bye')]) |
|
394 |
tree1.add(['b'], ['b-id']) |
|
395 |
tree1.commit('b', rev_id='rev-2', |
|
396 |
committer=u'p\xe9rez', |
|
397 |
timestamp=1166046000.00, timezone=0) |
|
398 |
||
3010.1.1
by Robert Collins
Lock the tree's used to test annotate_file, and add a docstring for annotate_file explaining its needs. |
399 |
tree1.lock_read() |
400 |
self.addCleanup(tree1.unlock) |
|
5815.3.10
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
401 |
|
402 |
revtree_1 = tree1.branch.repository.revision_tree('rev-1') |
|
403 |
revtree_2 = tree1.branch.repository.revision_tree('rev-2') |
|
404 |
||
2593.1.2
by Adeodato Simó
Improve tests a bit, actually checking for the replace encoding. |
405 |
# this passes if no exception is raised
|
406 |
to_file = StringIO() |
|
5815.3.14
by Jelmer Vernooij
Kill annotate_file_revision_tree() in favor annotate_file_tree(). |
407 |
annotate.annotate_file_tree(revtree_1, 'a-id', |
5815.3.10
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
408 |
to_file=to_file, branch=tree1.branch) |
2593.1.1
by Adeodato Simó
Improve annotate to prevent unicode exceptions in certain situations. |
409 |
|
2593.1.2
by Adeodato Simó
Improve tests a bit, actually checking for the replace encoding. |
410 |
sio = StringIO() |
411 |
to_file = codecs.getwriter('ascii')(sio) |
|
2593.1.1
by Adeodato Simó
Improve annotate to prevent unicode exceptions in certain situations. |
412 |
to_file.encoding = 'ascii' # codecs does not set it |
5815.3.14
by Jelmer Vernooij
Kill annotate_file_revision_tree() in favor annotate_file_tree(). |
413 |
annotate.annotate_file_tree(revtree_2, 'b-id', |
5815.3.10
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
414 |
to_file=to_file, branch=tree1.branch) |
2593.1.2
by Adeodato Simó
Improve tests a bit, actually checking for the replace encoding. |
415 |
self.assertEqualDiff('2 p?rez | bye\n', sio.getvalue()) |
2593.1.1
by Adeodato Simó
Improve annotate to prevent unicode exceptions in certain situations. |
416 |
|
2593.1.3
by Adeodato Simó
Cope with to_file.encoding being None or not present. |
417 |
# test now with to_file.encoding = None
|
418 |
to_file = tests.StringIOWrapper() |
|
419 |
to_file.encoding = None |
|
5815.3.14
by Jelmer Vernooij
Kill annotate_file_revision_tree() in favor annotate_file_tree(). |
420 |
annotate.annotate_file_tree(revtree_2, 'b-id', |
5815.3.10
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
421 |
to_file=to_file, branch=tree1.branch) |
2593.1.5
by Adeodato Simó
Fix copy&paste bug in test, catched by John. |
422 |
self.assertContainsRe('2 p.rez | bye\n', to_file.getvalue()) |
2593.1.3
by Adeodato Simó
Cope with to_file.encoding being None or not present. |
423 |
|
424 |
# and when it does not exist
|
|
425 |
to_file = StringIO() |
|
5815.3.14
by Jelmer Vernooij
Kill annotate_file_revision_tree() in favor annotate_file_tree(). |
426 |
annotate.annotate_file_tree(revtree_2, 'b-id', |
5815.3.10
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
427 |
to_file=to_file, branch=tree1.branch) |
2593.1.5
by Adeodato Simó
Fix copy&paste bug in test, catched by John. |
428 |
self.assertContainsRe('2 p.rez | bye\n', to_file.getvalue()) |
2593.1.3
by Adeodato Simó
Cope with to_file.encoding being None or not present. |
429 |
|
2671.5.3
by Lukáš Lalinsky
Use the author name in annotate. |
430 |
def test_annotate_author_or_committer(self): |
431 |
tree1 = self.make_branch_and_tree('tree1') |
|
432 |
||
433 |
self.build_tree_contents([('tree1/a', 'hello')]) |
|
434 |
tree1.add(['a'], ['a-id']) |
|
435 |
tree1.commit('a', rev_id='rev-1', |
|
436 |
committer='Committer <committer@example.com>', |
|
437 |
timestamp=1166046000.00, timezone=0) |
|
438 |
||
439 |
self.build_tree_contents([('tree1/b', 'bye')]) |
|
440 |
tree1.add(['b'], ['b-id']) |
|
441 |
tree1.commit('b', rev_id='rev-2', |
|
442 |
committer='Committer <committer@example.com>', |
|
4056.2.1
by James Westby
Allow specifying multiple authors for a revision. |
443 |
authors=['Author <author@example.com>'], |
2671.5.3
by Lukáš Lalinsky
Use the author name in annotate. |
444 |
timestamp=1166046000.00, timezone=0) |
445 |
||
3010.1.1
by Robert Collins
Lock the tree's used to test annotate_file, and add a docstring for annotate_file explaining its needs. |
446 |
tree1.lock_read() |
447 |
self.addCleanup(tree1.unlock) |
|
5815.3.11
by Jelmer Vernooij
Remove last use of deprecated method. |
448 |
|
449 |
self.assertBranchAnnotate('1 committ | hello\n', tree1.branch, |
|
450 |
'a-id', 'rev-1') |
|
451 |
||
452 |
to_file = StringIO() |
|
453 |
self.assertBranchAnnotate('2 author@ | bye\n', tree1.branch, |
|
454 |
'b-id', 'rev-2') |
|
2671.5.3
by Lukáš Lalinsky
Use the author name in annotate. |
455 |
|
1551.9.19
by Aaron Bentley
Merge from bzr.dev |
456 |
|
457 |
class TestReannotate(tests.TestCase): |
|
458 |
||
2770.1.5
by Aaron Bentley
Clean up docs, test matching blocks for reannotate |
459 |
def annotateEqual(self, expected, parents, newlines, revision_id, |
460 |
blocks=None): |
|
1551.9.19
by Aaron Bentley
Merge from bzr.dev |
461 |
annotate_list = list(annotate.reannotate(parents, newlines, |
2770.1.5
by Aaron Bentley
Clean up docs, test matching blocks for reannotate |
462 |
revision_id, blocks)) |
1551.9.19
by Aaron Bentley
Merge from bzr.dev |
463 |
self.assertEqual(len(expected), len(annotate_list)) |
464 |
for e, a in zip(expected, annotate_list): |
|
465 |
self.assertEqual(e, a) |
|
466 |
||
467 |
def test_reannotate(self): |
|
468 |
self.annotateEqual(parent_1, [parent_1], new_1, 'blahblah') |
|
469 |
self.annotateEqual(expected_2_1, [parent_2], new_1, 'blahblah') |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
470 |
self.annotateEqual(expected_1_2_2, [parent_1, parent_2], new_2, |
1551.9.19
by Aaron Bentley
Merge from bzr.dev |
471 |
'blahblah') |
2770.1.1
by Aaron Bentley
Initial implmentation of plain knit annotation |
472 |
|
473 |
def test_reannotate_no_parents(self): |
|
474 |
self.annotateEqual(expected_1, [], new_1, 'blahblah') |
|
2770.1.5
by Aaron Bentley
Clean up docs, test matching blocks for reannotate |
475 |
|
476 |
def test_reannotate_left_matching_blocks(self): |
|
477 |
"""Ensure that left_matching_blocks has an impact.
|
|
478 |
||
479 |
In this case, the annotation is ambiguous, so the hint isn't actually
|
|
480 |
lying.
|
|
481 |
"""
|
|
482 |
parent = [('rev1', 'a\n')] |
|
483 |
new_text = ['a\n', 'a\n'] |
|
484 |
blocks = [(0, 0, 1), (1, 2, 0)] |
|
485 |
self.annotateEqual([('rev1', 'a\n'), ('rev2', 'a\n')], [parent], |
|
486 |
new_text, 'rev2', blocks) |
|
487 |
blocks = [(0, 1, 1), (1, 2, 0)] |
|
488 |
self.annotateEqual([('rev2', 'a\n'), ('rev1', 'a\n')], [parent], |
|
489 |
new_text, 'rev2', blocks) |