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