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 |
7067.13.1
by Jelmer Vernooij
Some more fixes for Python 3. |
20 |
from io import BytesIO |
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
21 |
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
22 |
from .. import ( |
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
23 |
annotate, |
24 |
tests, |
|
25 |
)
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
26 |
from ..sixish import ( |
7045.1.11
by Jelmer Vernooij
Some annotate fixes. |
27 |
StringIO, |
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
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): |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
33 |
return [tuple(l.split(b' ', 1)) for l in text.splitlines(True)] |
34 |
||
35 |
||
36 |
parent_1 = annotation(b"""\ |
|
1551.9.19
by Aaron Bentley
Merge from bzr.dev |
37 |
rev1 a
|
38 |
rev2 b
|
|
39 |
rev3 c
|
|
40 |
rev4 d
|
|
41 |
rev5 e
|
|
42 |
""") |
|
43 |
||
44 |
||
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
45 |
parent_2 = annotation(b"""\ |
1551.9.19
by Aaron Bentley
Merge from bzr.dev |
46 |
rev1 a
|
47 |
rev3 c
|
|
48 |
rev4 d
|
|
49 |
rev6 f
|
|
50 |
rev7 e
|
|
51 |
rev8 h
|
|
52 |
""") |
|
53 |
||
54 |
||
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
55 |
expected_2_1 = annotation(b"""\ |
1551.9.19
by Aaron Bentley
Merge from bzr.dev |
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
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
72 |
expected_1_2_2 = annotation(b"""\ |
1551.9.19
by Aaron Bentley
Merge from bzr.dev |
73 |
rev1 a
|
74 |
rev2 b
|
|
75 |
rev3 c
|
|
76 |
rev4 d
|
|
77 |
blahblah e
|
|
78 |
blahblah g
|
|
79 |
rev8 h
|
|
80 |
""") |
|
81 |
||
82 |
||
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
83 |
new_1 = b"""\ |
1551.9.19
by Aaron Bentley
Merge from bzr.dev |
84 |
a
|
85 |
b
|
|
86 |
c
|
|
87 |
d
|
|
88 |
e
|
|
89 |
""".splitlines(True) |
|
90 |
||
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
91 |
expected_1 = annotation(b"""\ |
2770.1.1
by Aaron Bentley
Initial implmentation of plain knit 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 |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
100 |
new_2 = b"""\ |
1551.9.19
by Aaron Bentley
Merge from bzr.dev |
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)
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
124 |
duplicate_base = annotation(b"""\ |
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. |
125 |
rev-base first
|
126 |
rev-base second
|
|
127 |
rev-base third
|
|
128 |
rev-base fourth-base
|
|
129 |
""") |
|
130 |
||
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
131 |
duplicate_A = annotation(b"""\ |
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. |
132 |
rev-base first
|
133 |
rev-A alt-second
|
|
134 |
rev-base third
|
|
135 |
rev-A fourth-A
|
|
136 |
""") |
|
137 |
||
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
138 |
duplicate_B = annotation(b"""\ |
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. |
139 |
rev-base first
|
140 |
rev-B alt-second
|
|
141 |
rev-base third
|
|
142 |
rev-B fourth-B
|
|
143 |
""") |
|
144 |
||
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
145 |
duplicate_C = annotation(b"""\ |
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. |
146 |
rev-base first
|
147 |
rev-A alt-second
|
|
148 |
rev-base third
|
|
149 |
rev-C fourth-C
|
|
150 |
""") |
|
151 |
||
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
152 |
duplicate_D = annotation(b"""\ |
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. |
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 |
||
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
159 |
duplicate_E = annotation(b"""\ |
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. |
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) |
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
183 |
builder.build_snapshot(None, [ |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
184 |
('add', ('', b'root-id', 'directory', None)), |
7027.3.3
by Jelmer Vernooij
Add some more bees; support writing both bytes and unicode strings in build_tree_contents. |
185 |
('add', ('a', b'a-id', 'file', b'first\n')), |
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
186 |
], timestamp=1166046000.00, timezone=0, committer="joe@foo.com", |
6973.5.2
by Jelmer Vernooij
Add more bees. |
187 |
revision_id=b'rev-1') |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
188 |
builder.build_snapshot([b'rev-1'], [ |
189 |
('modify', ('a', b'first\nsecond\n')), |
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
190 |
], timestamp=1166046001.00, timezone=0, committer="joe@foo.com", |
6973.5.2
by Jelmer Vernooij
Add more bees. |
191 |
revision_id=b'rev-2') |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
192 |
builder.build_snapshot([b'rev-1'], [ |
193 |
('modify', ('a', b'first\nthird\n')), |
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
194 |
], timestamp=1166046002.00, timezone=0, committer="barry@foo.com", |
6973.5.2
by Jelmer Vernooij
Add more bees. |
195 |
revision_id=b'rev-1_1_1') |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
196 |
builder.build_snapshot([b'rev-2', b'rev-1_1_1'], [ |
197 |
('modify', ('a', b'first\nsecond\nthird\n')), |
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
198 |
], timestamp=1166046003.00, timezone=0, committer="sal@foo.com", |
6973.5.2
by Jelmer Vernooij
Add more bees. |
199 |
revision_id=b'rev-3') |
4454.3.24
by John Arbash Meinel
update BranchBuilder to support 'committer' |
200 |
return builder |
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
201 |
|
202 |
def create_deeply_merged_trees(self): |
|
2245.3.1
by John Arbash Meinel
bzr annotate should use Branch's dotted revnos. |
203 |
"""Create some trees with a more complex merge history. |
204 |
||
205 |
rev-1 --+
|
|
206 |
| |
|
|
207 |
rev-2 rev-1_1_1 --+
|
|
208 |
| | |
|
|
209 |
+------+ |
|
|
210 |
| | |
|
|
3170.3.4
by John Arbash Meinel
Update the tests for the new revision numbering. |
211 |
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. |
212 |
| | | |
|
213 |
+------+ | |
|
|
214 |
| | |
|
|
3170.3.4
by John Arbash Meinel
Update the tests for the new revision numbering. |
215 |
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. |
216 |
| | |
|
217 |
+-----------------+ |
|
|
218 |
| |
|
|
219 |
rev-5 |
|
|
220 |
| |
|
|
221 |
+--------------------------------+
|
|
222 |
|
|
|
223 |
rev-6
|
|
224 |
"""
|
|
4454.3.24
by John Arbash Meinel
update BranchBuilder to support 'committer' |
225 |
builder = self.create_merged_trees() |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
226 |
builder.build_snapshot([b'rev-1_1_1'], [], revision_id=b'rev-1_1_2') |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
227 |
builder.build_snapshot([b'rev-3', b'rev-1_1_2'], |
228 |
[], revision_id=b'rev-4') |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
229 |
builder.build_snapshot([b'rev-1_1_1'], [ |
230 |
('modify', ('a', b'first\nthird\nfourth\n')), |
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
231 |
], timestamp=1166046003.00, timezone=0, committer="jerry@foo.com", |
6973.5.2
by Jelmer Vernooij
Add more bees. |
232 |
revision_id=b'rev-1_2_1') |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
233 |
builder.build_snapshot([b'rev-1_2_1'], [], |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
234 |
timestamp=1166046004.00, timezone=0, committer="jerry@foo.com", |
235 |
revision_id=b'rev-1_2_2') |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
236 |
builder.build_snapshot([b'rev-4', b'rev-1_2_2'], [ |
237 |
('modify', ('a', b'first\nsecond\nthird\nfourth\n')), |
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
238 |
], timestamp=1166046004.00, timezone=0, committer="jerry@foo.com", |
6973.5.2
by Jelmer Vernooij
Add more bees. |
239 |
revision_id=b'rev-5') |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
240 |
builder.build_snapshot([b'rev-1_2_1'], [ |
241 |
('modify', ('a', b'first\nthird\nfourth\nfifth\nsixth\n')), |
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
242 |
], timestamp=1166046005.00, timezone=0, committer="george@foo.com", |
6973.5.2
by Jelmer Vernooij
Add more bees. |
243 |
revision_id=b'rev-1_3_1') |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
244 |
builder.build_snapshot([b'rev-5', b'rev-1_3_1'], [ |
6883.22.1
by Jelmer Vernooij
Take paths in BranchBuilder. |
245 |
('modify', ('a', |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
246 |
b'first\nsecond\nthird\nfourth\nfifth\nsixth\n')), |
6973.5.2
by Jelmer Vernooij
Add more bees. |
247 |
], revision_id=b'rev-6') |
4454.3.24
by John Arbash Meinel
update BranchBuilder to support 'committer' |
248 |
return builder |
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
249 |
|
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. |
250 |
def create_duplicate_lines_tree(self): |
4454.3.25
by John Arbash Meinel
Use BranchBuilder for duplicate_lines_tree |
251 |
builder = self.make_branch_builder('branch') |
252 |
builder.start_series() |
|
253 |
self.addCleanup(builder.finish_series) |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
254 |
base_text = b''.join(l for r, l in duplicate_base) |
255 |
a_text = b''.join(l for r, l in duplicate_A) |
|
256 |
b_text = b''.join(l for r, l in duplicate_B) |
|
257 |
c_text = b''.join(l for r, l in duplicate_C) |
|
258 |
d_text = b''.join(l for r, l in duplicate_D) |
|
259 |
e_text = b''.join(l for r, l in duplicate_E) |
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
260 |
builder.build_snapshot(None, [ |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
261 |
('add', ('', b'root-id', 'directory', None)), |
262 |
('add', ('file', b'file-id', 'file', base_text)), |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
263 |
], revision_id=b'rev-base') |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
264 |
builder.build_snapshot([b'rev-base'], [ |
6883.22.1
by Jelmer Vernooij
Take paths in BranchBuilder. |
265 |
('modify', ('file', a_text))], |
6973.5.2
by Jelmer Vernooij
Add more bees. |
266 |
revision_id=b'rev-A') |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
267 |
builder.build_snapshot([b'rev-base'], [ |
6883.22.1
by Jelmer Vernooij
Take paths in BranchBuilder. |
268 |
('modify', ('file', b_text))], |
6973.5.2
by Jelmer Vernooij
Add more bees. |
269 |
revision_id=b'rev-B') |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
270 |
builder.build_snapshot([b'rev-A'], [ |
6883.22.1
by Jelmer Vernooij
Take paths in BranchBuilder. |
271 |
('modify', ('file', c_text))], |
6973.5.2
by Jelmer Vernooij
Add more bees. |
272 |
revision_id=b'rev-C') |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
273 |
builder.build_snapshot([b'rev-B', b'rev-A'], [ |
6883.22.1
by Jelmer Vernooij
Take paths in BranchBuilder. |
274 |
('modify', ('file', d_text))], |
6973.5.2
by Jelmer Vernooij
Add more bees. |
275 |
revision_id=b'rev-D') |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
276 |
builder.build_snapshot([b'rev-C', b'rev-D'], [ |
6883.22.1
by Jelmer Vernooij
Take paths in BranchBuilder. |
277 |
('modify', ('file', e_text))], |
6973.5.2
by Jelmer Vernooij
Add more bees. |
278 |
revision_id=b'rev-E') |
4454.3.25
by John Arbash Meinel
Use BranchBuilder for duplicate_lines_tree |
279 |
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. |
280 |
|
5815.3.7
by Jelmer Vernooij
Factor out assertAnnotateEqualDiff. |
281 |
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. |
282 |
if actual != expected: |
283 |
# Create an easier to understand diff when the lines don't actually
|
|
284 |
# match
|
|
7045.1.11
by Jelmer Vernooij
Some annotate fixes. |
285 |
self.assertEqualDiff(''.join('\t'.join(l) for l in expected), |
286 |
''.join('\t'.join(l) for l in actual)) |
|
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 |
|
6809.4.3
by Jelmer Vernooij
Fix annotate tests. |
288 |
def assertBranchAnnotate(self, expected, branch, path, revision_id, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
289 |
verbose=False, full=False, show_ids=False): |
5815.3.8
by Jelmer Vernooij
Add convenience method for testing annotate_file_revision_tree. |
290 |
tree = branch.repository.revision_tree(revision_id) |
7045.1.11
by Jelmer Vernooij
Some annotate fixes. |
291 |
to_file = StringIO() |
6809.4.3
by Jelmer Vernooij
Fix annotate tests. |
292 |
annotate.annotate_file_tree(tree, path, to_file, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
293 |
verbose=verbose, full=full, show_ids=show_ids, branch=branch) |
5815.3.8
by Jelmer Vernooij
Add convenience method for testing annotate_file_revision_tree. |
294 |
self.assertAnnotateEqualDiff(to_file.getvalue(), expected) |
295 |
||
6809.4.2
by Jelmer Vernooij
Swap arguments for annotate_iter. |
296 |
def assertRepoAnnotate(self, expected, repo, path, revision_id): |
5815.3.7
by Jelmer Vernooij
Factor out assertAnnotateEqualDiff. |
297 |
"""Assert that the revision is properly annotated.""" |
6809.4.2
by Jelmer Vernooij
Swap arguments for annotate_iter. |
298 |
actual = list(repo.revision_tree(revision_id).annotate_iter(path)) |
5815.3.7
by Jelmer Vernooij
Factor out assertAnnotateEqualDiff. |
299 |
self.assertAnnotateEqualDiff(actual, expected) |
300 |
||
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. |
301 |
def test_annotate_duplicate_lines(self): |
3689.1.4
by John Arbash Meinel
Doc strings that reference repository_implementations |
302 |
# XXX: Should this be a per_repository test?
|
4454.3.25
by John Arbash Meinel
Use BranchBuilder for duplicate_lines_tree |
303 |
builder = self.create_duplicate_lines_tree() |
304 |
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. |
305 |
repo.lock_read() |
306 |
self.addCleanup(repo.unlock) |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
307 |
self.assertRepoAnnotate(duplicate_base, repo, 'file', b'rev-base') |
308 |
self.assertRepoAnnotate(duplicate_A, repo, 'file', b'rev-A') |
|
309 |
self.assertRepoAnnotate(duplicate_B, repo, 'file', b'rev-B') |
|
310 |
self.assertRepoAnnotate(duplicate_C, repo, 'file', b'rev-C') |
|
311 |
self.assertRepoAnnotate(duplicate_D, repo, 'file', b'rev-D') |
|
312 |
self.assertRepoAnnotate(duplicate_E, repo, 'file', b'rev-E') |
|
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. |
313 |
|
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
314 |
def test_annotate_shows_dotted_revnos(self): |
4454.3.24
by John Arbash Meinel
update BranchBuilder to support 'committer' |
315 |
builder = self.create_merged_trees() |
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
316 |
|
7045.1.11
by Jelmer Vernooij
Some annotate fixes. |
317 |
self.assertBranchAnnotate('1 joe@foo | first\n' |
318 |
'2 joe@foo | second\n' |
|
319 |
'1.1.1 barry@f | third\n', |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
320 |
builder.get_branch(), 'a', b'rev-3') |
5815.3.9
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
321 |
|
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
322 |
def test_annotate_limits_dotted_revnos(self): |
323 |
"""Annotate should limit dotted revnos to a depth of 12""" |
|
4454.3.24
by John Arbash Meinel
update BranchBuilder to support 'committer' |
324 |
builder = self.create_deeply_merged_trees() |
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
325 |
|
7045.1.11
by Jelmer Vernooij
Some annotate fixes. |
326 |
self.assertBranchAnnotate('1 joe@foo | first\n' |
327 |
'2 joe@foo | second\n' |
|
328 |
'1.1.1 barry@f | third\n' |
|
329 |
'1.2.1 jerry@f | fourth\n' |
|
330 |
'1.3.1 george@ | fifth\n' |
|
331 |
' | sixth\n', |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
332 |
builder.get_branch(), 'a', b'rev-6', |
5815.3.9
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
333 |
verbose=False, full=False) |
2182.3.4
by John Arbash Meinel
add show-ids and test that nearby areas are collapsed without full |
334 |
|
7045.1.11
by Jelmer Vernooij
Some annotate fixes. |
335 |
self.assertBranchAnnotate('1 joe@foo | first\n' |
336 |
'2 joe@foo | second\n' |
|
337 |
'1.1.1 barry@f | third\n' |
|
338 |
'1.2.1 jerry@f | fourth\n' |
|
339 |
'1.3.1 george@ | fifth\n' |
|
340 |
'1.3.1 george@ | sixth\n', |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
341 |
builder.get_branch(), 'a', b'rev-6', |
5815.3.9
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
342 |
verbose=False, full=True) |
2182.3.3
by John Arbash Meinel
Add tests for annotate with dotted revnos. |
343 |
|
344 |
# verbose=True shows everything, the full revno, user id, and date
|
|
7045.1.11
by Jelmer Vernooij
Some annotate fixes. |
345 |
self.assertBranchAnnotate('1 joe@foo.com 20061213 | first\n' |
346 |
'2 joe@foo.com 20061213 | second\n' |
|
347 |
'1.1.1 barry@foo.com 20061213 | third\n' |
|
348 |
'1.2.1 jerry@foo.com 20061213 | fourth\n' |
|
349 |
'1.3.1 george@foo.com 20061213 | fifth\n' |
|
350 |
' | sixth\n', |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
351 |
builder.get_branch(), 'a', b'rev-6', |
5815.3.9
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
352 |
verbose=True, full=False) |
2182.3.4
by John Arbash Meinel
add show-ids and test that nearby areas are collapsed without full |
353 |
|
7045.1.11
by Jelmer Vernooij
Some annotate fixes. |
354 |
self.assertBranchAnnotate('1 joe@foo.com 20061213 | first\n' |
355 |
'2 joe@foo.com 20061213 | second\n' |
|
356 |
'1.1.1 barry@foo.com 20061213 | third\n' |
|
357 |
'1.2.1 jerry@foo.com 20061213 | fourth\n' |
|
358 |
'1.3.1 george@foo.com 20061213 | fifth\n' |
|
359 |
'1.3.1 george@foo.com 20061213 | sixth\n', |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
360 |
builder.get_branch(), 'a', b'rev-6', |
5815.3.9
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
361 |
verbose=True, full=True) |
2245.3.1
by John Arbash Meinel
bzr annotate should use Branch's dotted revnos. |
362 |
|
363 |
def test_annotate_uses_branch_context(self): |
|
364 |
"""Dotted revnos should use the Branch context. |
|
365 |
||
366 |
When annotating a non-mainline revision, the annotation should still
|
|
367 |
use dotted revnos from the mainline.
|
|
368 |
"""
|
|
4454.3.24
by John Arbash Meinel
update BranchBuilder to support 'committer' |
369 |
builder = self.create_deeply_merged_trees() |
2245.3.1
by John Arbash Meinel
bzr annotate should use Branch's dotted revnos. |
370 |
|
7045.1.11
by Jelmer Vernooij
Some annotate fixes. |
371 |
self.assertBranchAnnotate('1 joe@foo | first\n' |
372 |
'1.1.1 barry@f | third\n' |
|
373 |
'1.2.1 jerry@f | fourth\n' |
|
374 |
'1.3.1 george@ | fifth\n' |
|
375 |
' | sixth\n', |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
376 |
builder.get_branch(), 'a', b'rev-1_3_1', |
5815.3.9
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
377 |
verbose=False, full=False) |
2245.3.1
by John Arbash Meinel
bzr annotate should use Branch's dotted revnos. |
378 |
|
2182.3.4
by John Arbash Meinel
add show-ids and test that nearby areas are collapsed without full |
379 |
def test_annotate_show_ids(self): |
4454.3.24
by John Arbash Meinel
update BranchBuilder to support 'committer' |
380 |
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 |
381 |
|
382 |
# It looks better with real revision ids :)
|
|
7045.1.11
by Jelmer Vernooij
Some annotate fixes. |
383 |
self.assertBranchAnnotate(' rev-1 | first\n' |
384 |
' rev-2 | second\n' |
|
385 |
'rev-1_1_1 | third\n' |
|
386 |
'rev-1_2_1 | fourth\n' |
|
387 |
'rev-1_3_1 | fifth\n' |
|
388 |
' | sixth\n', |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
389 |
builder.get_branch(), 'a', b'rev-6', |
5815.3.9
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
390 |
show_ids=True, full=False) |
391 |
||
7045.1.11
by Jelmer Vernooij
Some annotate fixes. |
392 |
self.assertBranchAnnotate(' rev-1 | first\n' |
393 |
' rev-2 | second\n' |
|
394 |
'rev-1_1_1 | third\n' |
|
395 |
'rev-1_2_1 | fourth\n' |
|
396 |
'rev-1_3_1 | fifth\n' |
|
397 |
'rev-1_3_1 | sixth\n', |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
398 |
builder.get_branch(), 'a', b'rev-6', |
5815.3.9
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
399 |
show_ids=True, full=True) |
1551.9.19
by Aaron Bentley
Merge from bzr.dev |
400 |
|
2593.1.1
by Adeodato Simó
Improve annotate to prevent unicode exceptions in certain situations. |
401 |
def test_annotate_unicode_author(self): |
402 |
tree1 = self.make_branch_and_tree('tree1') |
|
403 |
||
6855.4.1
by Jelmer Vernooij
Yet more bees. |
404 |
self.build_tree_contents([('tree1/a', b'adi\xc3\xb3s')]) |
405 |
tree1.add(['a'], [b'a-id']) |
|
406 |
tree1.commit('a', rev_id=b'rev-1', |
|
2593.1.1
by Adeodato Simó
Improve annotate to prevent unicode exceptions in certain situations. |
407 |
committer=u'Pepe P\xe9rez <pperez@ejemplo.com>', |
408 |
timestamp=1166046000.00, timezone=0) |
|
409 |
||
6855.4.1
by Jelmer Vernooij
Yet more bees. |
410 |
self.build_tree_contents([('tree1/b', b'bye')]) |
411 |
tree1.add(['b'], [b'b-id']) |
|
412 |
tree1.commit('b', rev_id=b'rev-2', |
|
2593.1.1
by Adeodato Simó
Improve annotate to prevent unicode exceptions in certain situations. |
413 |
committer=u'p\xe9rez', |
414 |
timestamp=1166046000.00, timezone=0) |
|
415 |
||
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. |
416 |
tree1.lock_read() |
417 |
self.addCleanup(tree1.unlock) |
|
5815.3.10
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
418 |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
419 |
revtree_1 = tree1.branch.repository.revision_tree(b'rev-1') |
420 |
revtree_2 = tree1.branch.repository.revision_tree(b'rev-2') |
|
5815.3.10
by Jelmer Vernooij
Convert more tests to use annotate_file_revision_tree. |
421 |
|
2593.1.2
by Adeodato Simó
Improve tests a bit, actually checking for the replace encoding. |
422 |
# this passes if no exception is raised
|
7045.1.11
by Jelmer Vernooij
Some annotate fixes. |
423 |
to_file = StringIO() |
6809.4.3
by Jelmer Vernooij
Fix annotate tests. |
424 |
annotate.annotate_file_tree(revtree_1, 'a', |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
425 |
to_file=to_file, branch=tree1.branch) |
2593.1.1
by Adeodato Simó
Improve annotate to prevent unicode exceptions in certain situations. |
426 |
|
7067.13.1
by Jelmer Vernooij
Some more fixes for Python 3. |
427 |
sio = BytesIO() |
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
428 |
to_file = codecs.getwriter('ascii')(sio, 'replace') |
6809.4.3
by Jelmer Vernooij
Fix annotate tests. |
429 |
annotate.annotate_file_tree(revtree_2, 'b', |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
430 |
to_file=to_file, branch=tree1.branch) |
7067.13.1
by Jelmer Vernooij
Some more fixes for Python 3. |
431 |
self.assertEqualDiff(b'2 p?rez | bye\n', sio.getvalue()) |
2593.1.1
by Adeodato Simó
Improve annotate to prevent unicode exceptions in certain situations. |
432 |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
433 |
# test now with unicode file-like
|
434 |
to_file = StringIOWithEncoding() |
|
6809.4.3
by Jelmer Vernooij
Fix annotate tests. |
435 |
annotate.annotate_file_tree(revtree_2, 'b', |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
436 |
to_file=to_file, branch=tree1.branch) |
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
437 |
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. |
438 |
|
2671.5.3
by Lukáš Lalinsky
Use the author name in annotate. |
439 |
def test_annotate_author_or_committer(self): |
440 |
tree1 = self.make_branch_and_tree('tree1') |
|
441 |
||
6855.4.1
by Jelmer Vernooij
Yet more bees. |
442 |
self.build_tree_contents([('tree1/a', b'hello')]) |
443 |
tree1.add(['a'], [b'a-id']) |
|
444 |
tree1.commit('a', rev_id=b'rev-1', |
|
2671.5.3
by Lukáš Lalinsky
Use the author name in annotate. |
445 |
committer='Committer <committer@example.com>', |
446 |
timestamp=1166046000.00, timezone=0) |
|
447 |
||
6855.4.1
by Jelmer Vernooij
Yet more bees. |
448 |
self.build_tree_contents([('tree1/b', b'bye')]) |
449 |
tree1.add(['b'], [b'b-id']) |
|
450 |
tree1.commit('b', rev_id=b'rev-2', |
|
2671.5.3
by Lukáš Lalinsky
Use the author name in annotate. |
451 |
committer='Committer <committer@example.com>', |
4056.2.1
by James Westby
Allow specifying multiple authors for a revision. |
452 |
authors=['Author <author@example.com>'], |
2671.5.3
by Lukáš Lalinsky
Use the author name in annotate. |
453 |
timestamp=1166046000.00, timezone=0) |
454 |
||
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. |
455 |
tree1.lock_read() |
456 |
self.addCleanup(tree1.unlock) |
|
5815.3.11
by Jelmer Vernooij
Remove last use of deprecated method. |
457 |
|
7045.1.11
by Jelmer Vernooij
Some annotate fixes. |
458 |
self.assertBranchAnnotate('1 committ | hello\n', tree1.branch, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
459 |
'a', b'rev-1') |
5815.3.11
by Jelmer Vernooij
Remove last use of deprecated method. |
460 |
|
7045.1.11
by Jelmer Vernooij
Some annotate fixes. |
461 |
self.assertBranchAnnotate('2 author@ | bye\n', tree1.branch, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
462 |
'b', b'rev-2') |
2671.5.3
by Lukáš Lalinsky
Use the author name in annotate. |
463 |
|
1551.9.19
by Aaron Bentley
Merge from bzr.dev |
464 |
|
465 |
class TestReannotate(tests.TestCase): |
|
466 |
||
2770.1.5
by Aaron Bentley
Clean up docs, test matching blocks for reannotate |
467 |
def annotateEqual(self, expected, parents, newlines, revision_id, |
468 |
blocks=None): |
|
1551.9.19
by Aaron Bentley
Merge from bzr.dev |
469 |
annotate_list = list(annotate.reannotate(parents, newlines, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
470 |
revision_id, blocks)) |
1551.9.19
by Aaron Bentley
Merge from bzr.dev |
471 |
self.assertEqual(len(expected), len(annotate_list)) |
472 |
for e, a in zip(expected, annotate_list): |
|
473 |
self.assertEqual(e, a) |
|
474 |
||
475 |
def test_reannotate(self): |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
476 |
self.annotateEqual(parent_1, [parent_1], new_1, b'blahblah') |
477 |
self.annotateEqual(expected_2_1, [parent_2], new_1, b'blahblah') |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
478 |
self.annotateEqual(expected_1_2_2, [parent_1, parent_2], new_2, |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
479 |
b'blahblah') |
2770.1.1
by Aaron Bentley
Initial implmentation of plain knit annotation |
480 |
|
481 |
def test_reannotate_no_parents(self): |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
482 |
self.annotateEqual(expected_1, [], new_1, b'blahblah') |
2770.1.5
by Aaron Bentley
Clean up docs, test matching blocks for reannotate |
483 |
|
484 |
def test_reannotate_left_matching_blocks(self): |
|
485 |
"""Ensure that left_matching_blocks has an impact. |
|
486 |
||
487 |
In this case, the annotation is ambiguous, so the hint isn't actually
|
|
488 |
lying.
|
|
489 |
"""
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
490 |
parent = [(b'rev1', b'a\n')] |
491 |
new_text = [b'a\n', b'a\n'] |
|
2770.1.5
by Aaron Bentley
Clean up docs, test matching blocks for reannotate |
492 |
blocks = [(0, 0, 1), (1, 2, 0)] |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
493 |
self.annotateEqual([(b'rev1', b'a\n'), (b'rev2', b'a\n')], [parent], |
494 |
new_text, b'rev2', blocks) |
|
2770.1.5
by Aaron Bentley
Clean up docs, test matching blocks for reannotate |
495 |
blocks = [(0, 1, 1), (1, 2, 0)] |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
496 |
self.annotateEqual([(b'rev2', b'a\n'), (b'rev1', b'a\n')], [parent], |
497 |
new_text, b'rev2', blocks) |