bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
4183.6.2
by Martin Pool
Add better message and test for 251352 |
1 |
# Copyright (C) 2005, 2006, 2007, 2009 Canonical Ltd
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
|
1540.2.6
by Robey Pointer
make 'log' and 'status' treat '-r N..' as implicitly '-r N..-1' |
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.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
|
1540.2.6
by Robey Pointer
make 'log' and 'status' treat '-r N..' as implicitly '-r N..-1' |
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.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
|
1540.2.6
by Robey Pointer
make 'log' and 'status' treat '-r N..' as implicitly '-r N..-1' |
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
|
|
1540.2.6
by Robey Pointer
make 'log' and 'status' treat '-r N..' as implicitly '-r N..-1' |
16 |
|
17 |
||
|
1624.1.3
by Robert Collins
Convert log to use the new tsort.merge_sort routine. |
18 |
"""Black-box tests for bzr log."""
|
|
1540.2.6
by Robey Pointer
make 'log' and 'status' treat '-r N..' as implicitly '-r N..-1' |
19 |
|
|
4955.4.11
by Vincent Ladeuil
Give some tests a better focus and simplify them accordingly. |
20 |
from itertools import izip |
|
4325.4.3
by Vincent Ladeuil
More cleanups. |
21 |
import os |
22 |
import re |
|
|
1540.2.6
by Robey Pointer
make 'log' and 'status' treat '-r N..' as implicitly '-r N..-1' |
23 |
|
|
4325.4.3
by Vincent Ladeuil
More cleanups. |
24 |
from bzrlib import ( |
|
4955.4.6
by Vincent Ladeuil
Switch to branchbuilder to avoid the cost of test.script. |
25 |
branchbuilder, |
|
4955.5.2
by Vincent Ladeuil
Simplify tests. |
26 |
log, |
|
4325.4.3
by Vincent Ladeuil
More cleanups. |
27 |
osutils, |
28 |
tests, |
|
|
2978.6.1
by Kent Gibson
Use normalize_log to more accurately test blackbox log output. |
29 |
)
|
|
4955.4.5
by Vincent Ladeuil
Start reproducing the problems reported in the bug. |
30 |
from bzrlib.tests import ( |
31 |
script, |
|
32 |
test_log, |
|
33 |
)
|
|
|
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
34 |
|
35 |
||
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
36 |
class TestLog(tests.TestCaseWithTransport, test_log.TestLogMixin): |
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
37 |
|
38 |
def make_minimal_branch(self, path='.', format=None): |
|
39 |
tree = self.make_branch_and_tree(path, format=format) |
|
40 |
self.build_tree([path + '/hello.txt']) |
|
41 |
tree.add('hello.txt') |
|
42 |
tree.commit(message='message1') |
|
43 |
return tree |
|
44 |
||
45 |
def make_linear_branch(self, path='.', format=None): |
|
|
2809.1.2
by Daniel Watkins
Removed unnecessary check as per abentley's on-list comments. |
46 |
tree = self.make_branch_and_tree(path, format=format) |
|
2664.14.1
by Daniel Watkins
Fixed tests.blackbox.test_log to use internals where appropriate. |
47 |
self.build_tree( |
48 |
[path + '/hello.txt', path + '/goodbye.txt', path + '/meep.txt']) |
|
49 |
tree.add('hello.txt') |
|
50 |
tree.commit(message='message1') |
|
51 |
tree.add('goodbye.txt') |
|
52 |
tree.commit(message='message2') |
|
53 |
tree.add('meep.txt') |
|
54 |
tree.commit(message='message3') |
|
55 |
return tree |
|
|
1553.4.2
by Michael Ellerman
Make bzr log -r .. work, fixes bug #4609. Add a bunch of tests to make sure |
56 |
|
|
4369.2.1
by Marius Kruger
add some leftover log tests |
57 |
def make_merged_branch(self, path='.', format=None): |
|
4369.2.2
by Marius Kruger
use make_linear_branch in make_merged_branch |
58 |
tree = self.make_linear_branch(path, format) |
59 |
tree2 = tree.bzrdir.sprout('tree2', |
|
60 |
revision_id=tree.branch.get_rev_id(1)).open_workingtree() |
|
|
4369.2.1
by Marius Kruger
add some leftover log tests |
61 |
tree2.commit(message='tree2 message2') |
62 |
tree2.commit(message='tree2 message3') |
|
63 |
tree.merge_from_branch(tree2.branch) |
|
64 |
tree.commit(message='merge') |
|
65 |
return tree |
|
66 |
||
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
67 |
|
|
4955.5.2
by Vincent Ladeuil
Simplify tests. |
68 |
class TestLogWithLogCatcher(TestLog): |
69 |
||
70 |
def setUp(self): |
|
71 |
super(TestLogWithLogCatcher, self).setUp() |
|
|
4955.4.5
by Vincent Ladeuil
Start reproducing the problems reported in the bug. |
72 |
# Capture log formatter creations
|
|
4955.5.2
by Vincent Ladeuil
Simplify tests. |
73 |
class MyLogFormatter(test_log.LogCatcher): |
74 |
||
75 |
def __new__(klass, *args, **kwargs): |
|
|
4955.4.5
by Vincent Ladeuil
Start reproducing the problems reported in the bug. |
76 |
self.log_catcher = test_log.LogCatcher(*args, **kwargs) |
77 |
# Always return our own log formatter
|
|
|
4955.5.2
by Vincent Ladeuil
Simplify tests. |
78 |
return self.log_catcher |
79 |
||
80 |
def getme(branch): |
|
81 |
# Always return our own log formatter class hijacking the
|
|
82 |
# default behavior (which requires setting up a config
|
|
83 |
# variable)
|
|
84 |
return MyLogFormatter |
|
|
4985.1.5
by Vincent Ladeuil
Deploying the new overrideAttr facility further reduces the complexity |
85 |
self.overrideAttr(log.log_formatter_registry, 'get_default', getme) |
|
4955.5.2
by Vincent Ladeuil
Simplify tests. |
86 |
|
|
4955.4.8
by Vincent Ladeuil
Simplify more tests. |
87 |
def get_captured_revisions(self): |
88 |
return self.log_catcher.revisions |
|
89 |
||
90 |
def assertLogRevnos(self, args, expected_revnos, working_dir='.'): |
|
91 |
self.run_bzr(['log'] + args, working_dir=working_dir) |
|
92 |
self.assertEqual(expected_revnos, |
|
93 |
[r.revno for r in self.get_captured_revisions()]) |
|
94 |
||
95 |
def assertLogRevnosAndDepths(self, args, expected_revnos_and_depths, |
|
96 |
working_dir='.'): |
|
97 |
self.run_bzr(['log'] + args, working_dir=working_dir) |
|
98 |
self.assertEqual(expected_revnos_and_depths, |
|
99 |
[(r.revno, r.merge_depth) |
|
100 |
for r in self.get_captured_revisions()]) |
|
|
4955.5.2
by Vincent Ladeuil
Simplify tests. |
101 |
|
102 |
||
103 |
class TestLogRevSpecs(TestLogWithLogCatcher): |
|
104 |
||
105 |
def test_log_no_revspec(self): |
|
106 |
self.make_linear_branch() |
|
107 |
self.assertLogRevnos([], ['3', '2', '1']) |
|
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
108 |
|
|
1553.4.2
by Michael Ellerman
Make bzr log -r .. work, fixes bug #4609. Add a bunch of tests to make sure |
109 |
def test_log_null_end_revspec(self): |
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
110 |
self.make_linear_branch() |
|
4955.5.2
by Vincent Ladeuil
Simplify tests. |
111 |
self.assertLogRevnos(['-r1..'], ['3', '2', '1']) |
|
1553.4.2
by Michael Ellerman
Make bzr log -r .. work, fixes bug #4609. Add a bunch of tests to make sure |
112 |
|
113 |
def test_log_null_begin_revspec(self): |
|
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
114 |
self.make_linear_branch() |
|
4955.5.2
by Vincent Ladeuil
Simplify tests. |
115 |
self.assertLogRevnos(['-r..3'], ['3', '2', '1']) |
|
1553.4.2
by Michael Ellerman
Make bzr log -r .. work, fixes bug #4609. Add a bunch of tests to make sure |
116 |
|
117 |
def test_log_null_both_revspecs(self): |
|
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
118 |
self.make_linear_branch() |
|
4955.5.2
by Vincent Ladeuil
Simplify tests. |
119 |
self.assertLogRevnos(['-r..'], ['3', '2', '1']) |
|
2978.4.1
by Kent Gibson
Logging revision 0 returns error. |
120 |
|
|
1553.4.2
by Michael Ellerman
Make bzr log -r .. work, fixes bug #4609. Add a bunch of tests to make sure |
121 |
def test_log_negative_begin_revspec_full_log(self): |
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
122 |
self.make_linear_branch() |
|
4955.5.2
by Vincent Ladeuil
Simplify tests. |
123 |
self.assertLogRevnos(['-r-3..'], ['3', '2', '1']) |
|
1553.4.2
by Michael Ellerman
Make bzr log -r .. work, fixes bug #4609. Add a bunch of tests to make sure |
124 |
|
125 |
def test_log_negative_both_revspec_full_log(self): |
|
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
126 |
self.make_linear_branch() |
|
4955.5.2
by Vincent Ladeuil
Simplify tests. |
127 |
self.assertLogRevnos(['-r-3..-1'], ['3', '2', '1']) |
|
1553.4.2
by Michael Ellerman
Make bzr log -r .. work, fixes bug #4609. Add a bunch of tests to make sure |
128 |
|
129 |
def test_log_negative_both_revspec_partial(self): |
|
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
130 |
self.make_linear_branch() |
|
4955.5.2
by Vincent Ladeuil
Simplify tests. |
131 |
self.assertLogRevnos(['-r-3..-2'], ['2', '1']) |
|
1553.4.2
by Michael Ellerman
Make bzr log -r .. work, fixes bug #4609. Add a bunch of tests to make sure |
132 |
|
133 |
def test_log_negative_begin_revspec(self): |
|
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
134 |
self.make_linear_branch() |
|
4955.5.2
by Vincent Ladeuil
Simplify tests. |
135 |
self.assertLogRevnos(['-r-2..'], ['3', '2']) |
|
1553.4.2
by Michael Ellerman
Make bzr log -r .. work, fixes bug #4609. Add a bunch of tests to make sure |
136 |
|
|
2978.4.1
by Kent Gibson
Logging revision 0 returns error. |
137 |
def test_log_positive_revspecs(self): |
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
138 |
self.make_linear_branch() |
|
4955.5.2
by Vincent Ladeuil
Simplify tests. |
139 |
self.assertLogRevnos(['-r1..3'], ['3', '2', '1']) |
|
1624.1.3
by Robert Collins
Convert log to use the new tsort.merge_sort routine. |
140 |
|
|
4369.2.1
by Marius Kruger
add some leftover log tests |
141 |
def test_log_dotted_revspecs(self): |
142 |
self.make_merged_branch() |
|
|
4955.5.2
by Vincent Ladeuil
Simplify tests. |
143 |
self.assertLogRevnos(['-n0', '-r1..1.1.1'], ['1.1.1', '1']) |
|
3734.1.1
by Vincent Ladeuil
Fix bug #248427 by adding a --change option to log. |
144 |
|
|
4955.5.1
by Vincent Ladeuil
Split some tests to better characterize the classes |
145 |
def test_log_limit(self): |
146 |
tree = self.make_branch_and_tree('.') |
|
147 |
# We want more commits than our batch size starts at
|
|
148 |
for pos in range(10): |
|
149 |
tree.commit("%s" % pos) |
|
|
4955.5.2
by Vincent Ladeuil
Simplify tests. |
150 |
self.assertLogRevnos(['--limit', '2'], ['10', '9']) |
|
4955.5.1
by Vincent Ladeuil
Split some tests to better characterize the classes |
151 |
|
152 |
def test_log_limit_short(self): |
|
153 |
self.make_linear_branch() |
|
|
4955.5.2
by Vincent Ladeuil
Simplify tests. |
154 |
self.assertLogRevnos(['-l', '2'], ['3', '2']) |
155 |
||
|
4955.4.7
by Vincent Ladeuil
Some more cleanup. |
156 |
def test_log_change_revno(self): |
157 |
self.make_linear_branch() |
|
158 |
self.assertLogRevnos(['-c1'], ['1']) |
|
159 |
||
|
4955.4.6
by Vincent Ladeuil
Switch to branchbuilder to avoid the cost of test.script. |
160 |
|
|
4955.4.5
by Vincent Ladeuil
Start reproducing the problems reported in the bug. |
161 |
class TestBug474807(TestLogWithLogCatcher): |
162 |
||
163 |
def setUp(self): |
|
164 |
super(TestBug474807, self).setUp() |
|
|
4955.4.6
by Vincent Ladeuil
Switch to branchbuilder to avoid the cost of test.script. |
165 |
# FIXME: Using a MemoryTree would be even better here (but until we
|
166 |
# stop calling run_bzr, there is no point) --vila 100118.
|
|
167 |
builder = branchbuilder.BranchBuilder(self.get_transport()) |
|
168 |
builder.start_series() |
|
169 |
# mainline
|
|
170 |
builder.build_snapshot('1', None, [ |
|
171 |
('add', ('', 'root-id', 'directory', ''))]) |
|
172 |
builder.build_snapshot('2', ['1'], []) |
|
173 |
# branch
|
|
174 |
builder.build_snapshot('1.1.1', ['1'], []) |
|
175 |
# merge branch into mainline
|
|
176 |
builder.build_snapshot('3', ['2', '1.1.1'], []) |
|
177 |
# new commits in branch
|
|
178 |
builder.build_snapshot('1.1.2', ['1.1.1'], []) |
|
179 |
builder.build_snapshot('1.1.3', ['1.1.2'], []) |
|
180 |
# merge branch into mainline
|
|
181 |
builder.build_snapshot('4', ['3', '1.1.3'], []) |
|
182 |
# merge mainline into branch
|
|
183 |
builder.build_snapshot('1.1.4', ['1.1.3', '4'], []) |
|
184 |
# merge branch into mainline
|
|
185 |
builder.build_snapshot('5', ['4', '1.1.4'], []) |
|
186 |
builder.finish_series() |
|
|
4955.4.5
by Vincent Ladeuil
Start reproducing the problems reported in the bug. |
187 |
|
188 |
def test_n0(self): |
|
189 |
self.assertLogRevnos(['-n0', '-r1.1.1..1.1.4'], |
|
190 |
['1.1.4', '4', '1.1.3', '1.1.2', '3', '1.1.1']) |
|
191 |
def test_n0_forward(self): |
|
192 |
self.assertLogRevnos(['-n0', '-r1.1.1..1.1.4', '--forward'], |
|
193 |
['3', '1.1.1', '4', '1.1.2', '1.1.3', '1.1.4']) |
|
194 |
||
195 |
def test_n1(self): |
|
|
4955.4.6
by Vincent Ladeuil
Switch to branchbuilder to avoid the cost of test.script. |
196 |
# starting from 1.1.4 we follow the left-hand ancestry
|
|
4955.4.5
by Vincent Ladeuil
Start reproducing the problems reported in the bug. |
197 |
self.assertLogRevnos(['-n1', '-r1.1.1..1.1.4'], |
198 |
['1.1.4', '1.1.3', '1.1.2', '1.1.1']) |
|
199 |
||
200 |
def test_n1_forward(self): |
|
201 |
self.assertLogRevnos(['-n1', '-r1.1.1..1.1.4', '--forward'], |
|
202 |
['1.1.1', '1.1.2', '1.1.3', '1.1.4']) |
|
203 |
||
|
4955.5.2
by Vincent Ladeuil
Simplify tests. |
204 |
|
205 |
class TestLogRevSpecsWithPaths(TestLogWithLogCatcher): |
|
206 |
||
207 |
def test_log_revno_n_path_wrong_namespace(self): |
|
208 |
self.make_linear_branch('branch1') |
|
209 |
self.make_linear_branch('branch2') |
|
210 |
# There is no guarantee that a path exist between two arbitrary
|
|
211 |
# revisions.
|
|
212 |
self.run_bzr("log -r revno:2:branch1..revno:3:branch2", retcode=3) |
|
213 |
# But may be it's worth trying though ? -- vila 100115
|
|
214 |
||
215 |
def test_log_revno_n_path_correct_order(self): |
|
216 |
self.make_linear_branch('branch2') |
|
217 |
self.assertLogRevnos(['-rrevno:1:branch2..revno:3:branch2'], |
|
218 |
['3', '2','1']) |
|
219 |
||
220 |
def test_log_revno_n_path(self): |
|
221 |
self.make_linear_branch('branch2') |
|
222 |
self.assertLogRevnos(['-rrevno:1:branch2'], |
|
223 |
['1']) |
|
224 |
rev_props = self.log_catcher.revisions[0].rev.properties |
|
225 |
self.assertEqual('branch2', rev_props['branch-nick']) |
|
|
4955.5.1
by Vincent Ladeuil
Split some tests to better characterize the classes |
226 |
|
227 |
||
228 |
class TestLogErrors(TestLog): |
|
229 |
||
|
4955.5.2
by Vincent Ladeuil
Simplify tests. |
230 |
def test_log_zero_revspec(self): |
231 |
self.make_minimal_branch() |
|
232 |
self.run_bzr_error(['bzr: ERROR: Logging revision 0 is invalid.'], |
|
233 |
['log', '-r0']) |
|
234 |
||
235 |
def test_log_zero_begin_revspec(self): |
|
236 |
self.make_linear_branch() |
|
237 |
self.run_bzr_error(['bzr: ERROR: Logging revision 0 is invalid.'], |
|
238 |
['log', '-r0..2']) |
|
239 |
||
240 |
def test_log_zero_end_revspec(self): |
|
241 |
self.make_linear_branch() |
|
242 |
self.run_bzr_error(['bzr: ERROR: Logging revision 0 is invalid.'], |
|
243 |
['log', '-r-2..0']) |
|
244 |
||
|
3878.3.3
by Marius Kruger
Add tests for log -r with non-exising revno's |
245 |
def test_log_nonexistent_revno(self): |
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
246 |
self.make_minimal_branch() |
|
4955.4.7
by Vincent Ladeuil
Some more cleanup. |
247 |
self.run_bzr_error(["bzr: ERROR: Requested revision: '1234' " |
248 |
"does not exist in branch:"], |
|
249 |
['log', '-r1234']) |
|
|
3878.3.3
by Marius Kruger
Add tests for log -r with non-exising revno's |
250 |
|
251 |
def test_log_nonexistent_dotted_revno(self): |
|
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
252 |
self.make_minimal_branch() |
|
4955.4.7
by Vincent Ladeuil
Some more cleanup. |
253 |
self.run_bzr_error(["bzr: ERROR: Requested revision: '123.123' " |
254 |
"does not exist in branch:"], |
|
255 |
['log', '-r123.123']) |
|
|
3734.1.1
by Vincent Ladeuil
Fix bug #248427 by adding a --change option to log. |
256 |
|
|
3878.3.2
by Marius Kruger
Add tests for log -c with non-exising revno's |
257 |
def test_log_change_nonexistent_revno(self): |
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
258 |
self.make_minimal_branch() |
|
4955.4.7
by Vincent Ladeuil
Some more cleanup. |
259 |
self.run_bzr_error(["bzr: ERROR: Requested revision: '1234' " |
260 |
"does not exist in branch:"], |
|
261 |
['log', '-c1234']) |
|
|
3878.3.2
by Marius Kruger
Add tests for log -c with non-exising revno's |
262 |
|
263 |
def test_log_change_nonexistent_dotted_revno(self): |
|
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
264 |
self.make_minimal_branch() |
|
4955.4.7
by Vincent Ladeuil
Some more cleanup. |
265 |
self.run_bzr_error(["bzr: ERROR: Requested revision: '123.123' " |
266 |
"does not exist in branch:"], |
|
267 |
['log', '-c123.123']) |
|
|
3878.3.2
by Marius Kruger
Add tests for log -c with non-exising revno's |
268 |
|
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
269 |
def test_log_change_single_revno_only(self): |
270 |
self.make_minimal_branch() |
|
|
4325.4.6
by Vincent Ladeuil
Fixed as per John's and Markus reviews. |
271 |
self.run_bzr_error(['bzr: ERROR: Option --change does not' |
272 |
' accept revision ranges'], |
|
|
3734.1.1
by Vincent Ladeuil
Fix bug #248427 by adding a --change option to log. |
273 |
['log', '--change', '2..3']) |
274 |
||
275 |
def test_log_change_incompatible_with_revision(self): |
|
|
4325.4.6
by Vincent Ladeuil
Fixed as per John's and Markus reviews. |
276 |
self.run_bzr_error(['bzr: ERROR: --revision and --change' |
277 |
' are mutually exclusive'], |
|
|
3734.1.1
by Vincent Ladeuil
Fix bug #248427 by adding a --change option to log. |
278 |
['log', '--change', '2', '--revision', '3']) |
279 |
||
|
2100.1.1
by wang
Running ``bzr log`` on nonexistent file gives an error instead of the |
280 |
def test_log_nonexistent_file(self): |
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
281 |
self.make_minimal_branch() |
|
2100.1.1
by wang
Running ``bzr log`` on nonexistent file gives an error instead of the |
282 |
# files that don't exist in either the basis tree or working tree
|
283 |
# should give an error
|
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
284 |
out, err = self.run_bzr('log does-not-exist', retcode=3) |
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
285 |
self.assertContainsRe(err, |
286 |
'Path unknown at end or start of revision range: '
|
|
287 |
'does-not-exist') |
|
|
2388.1.11
by Alexander Belchenko
changes after John's review |
288 |
|
|
4955.5.2
by Vincent Ladeuil
Simplify tests. |
289 |
def test_log_reversed_revspecs(self): |
290 |
self.make_linear_branch() |
|
291 |
self.run_bzr_error(('bzr: ERROR: Start revision must be older than ' |
|
292 |
'the end revision.\n',), |
|
293 |
['log', '-r3..1']) |
|
294 |
||
295 |
def test_log_reversed_dotted_revspecs(self): |
|
296 |
self.make_merged_branch() |
|
297 |
self.run_bzr_error(('bzr: ERROR: Start revision not found in ' |
|
298 |
'left-hand history of end revision.\n',), |
|
299 |
"log -r 1.1.1..1") |
|
300 |
||
|
4955.5.1
by Vincent Ladeuil
Split some tests to better characterize the classes |
301 |
def test_log_bad_message_re(self): |
302 |
"""Bad --message argument gives a sensible message |
|
303 |
|
|
304 |
See https://bugs.launchpad.net/bzr/+bug/251352
|
|
305 |
"""
|
|
306 |
self.make_minimal_branch() |
|
307 |
out, err = self.run_bzr(['log', '-m', '*'], retcode=3) |
|
308 |
self.assertEqual("bzr: ERROR: Invalid regular expression" |
|
309 |
" in log message filter"
|
|
310 |
": '*'"
|
|
311 |
": nothing to repeat\n", err) |
|
312 |
self.assertEqual('', out) |
|
313 |
||
|
4955.4.7
by Vincent Ladeuil
Some more cleanup. |
314 |
def test_log_unsupported_timezone(self): |
315 |
self.make_linear_branch() |
|
316 |
self.run_bzr_error(['bzr: ERROR: Unsupported timezone format "foo", ' |
|
317 |
'options are "utc", "original", "local".'], |
|
318 |
['log', '--timezone', 'foo']) |
|
|
4955.5.1
by Vincent Ladeuil
Split some tests to better characterize the classes |
319 |
|
320 |
||
321 |
class TestLogTags(TestLog): |
|
322 |
||
|
2388.1.3
by Erik Bagfors
tests for tags in log output |
323 |
def test_log_with_tags(self): |
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
324 |
tree = self.make_linear_branch(format='dirstate-tags') |
|
2664.14.1
by Daniel Watkins
Fixed tests.blackbox.test_log to use internals where appropriate. |
325 |
branch = tree.branch |
326 |
branch.tags.set_tag('tag1', branch.get_rev_id(1)) |
|
327 |
branch.tags.set_tag('tag1.1', branch.get_rev_id(1)) |
|
|
3842.2.5
by Vincent Ladeuil
Better fix for bug #300055. |
328 |
branch.tags.set_tag('tag3', branch.last_revision()) |
329 |
||
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
330 |
log = self.run_bzr("log -r-1")[0] |
|
2388.1.3
by Erik Bagfors
tests for tags in log output |
331 |
self.assertTrue('tags: tag3' in log) |
332 |
||
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
333 |
log = self.run_bzr("log -r1")[0] |
|
2388.1.3
by Erik Bagfors
tests for tags in log output |
334 |
# I guess that we can't know the order of tags in the output
|
335 |
# since dicts are unordered, need to check both possibilities
|
|
|
2388.1.11
by Alexander Belchenko
changes after John's review |
336 |
self.assertContainsRe(log, r'tags: (tag1, tag1\.1|tag1\.1, tag1)') |
337 |
||
|
2388.1.9
by Erik Bagfors
test for merges with tags in log |
338 |
def test_merged_log_with_tags(self): |
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
339 |
branch1_tree = self.make_linear_branch('branch1', |
340 |
format='dirstate-tags') |
|
|
2664.14.1
by Daniel Watkins
Fixed tests.blackbox.test_log to use internals where appropriate. |
341 |
branch1 = branch1_tree.branch |
342 |
branch2_tree = branch1_tree.bzrdir.sprout('branch2').open_workingtree() |
|
343 |
branch1_tree.commit(message='foobar', allow_pointless=True) |
|
344 |
branch1.tags.set_tag('tag1', branch1.last_revision()) |
|
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
345 |
# tags don't propagate if we don't merge
|
346 |
self.run_bzr('merge ../branch1', working_dir='branch2') |
|
|
2664.14.1
by Daniel Watkins
Fixed tests.blackbox.test_log to use internals where appropriate. |
347 |
branch2_tree.commit(message='merge branch 1') |
|
4511.3.11
by Marius Kruger
* fix tests again |
348 |
log = self.run_bzr("log -n0 -r-1", working_dir='branch2')[0] |
|
2388.1.11
by Alexander Belchenko
changes after John's review |
349 |
self.assertContainsRe(log, r' tags: tag1') |
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
350 |
log = self.run_bzr("log -n0 -r3.1.1", working_dir='branch2')[0] |
|
2466.12.2
by Kent Gibson
shift log output with only merge revisions to the left margin |
351 |
self.assertContainsRe(log, r'tags: tag1') |
|
2388.1.3
by Erik Bagfors
tests for tags in log output |
352 |
|
|
4202.2.1
by Ian Clatworthy
get directory logging working again |
353 |
|
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
354 |
class TestLogVerbose(TestLog): |
|
3874.1.8
by Vincent Ladeuil
Fixed as ber Robert's review. |
355 |
|
356 |
def setUp(self): |
|
357 |
super(TestLogVerbose, self).setUp() |
|
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
358 |
self.make_minimal_branch() |
|
3874.1.8
by Vincent Ladeuil
Fixed as ber Robert's review. |
359 |
|
360 |
def assertUseShortDeltaFormat(self, cmd): |
|
361 |
log = self.run_bzr(cmd)[0] |
|
362 |
# Check that we use the short status format
|
|
|
3947.1.7
by Ian Clatworthy
tweak indenting/offsetting for --short given dotted revno lengths |
363 |
self.assertContainsRe(log, '(?m)^\s*A hello.txt$') |
364 |
self.assertNotContainsRe(log, '(?m)^\s*added:$') |
|
|
3874.1.4
by Vincent Ladeuil
Fixed as per Aarons' comment. |
365 |
|
|
3874.1.8
by Vincent Ladeuil
Fixed as ber Robert's review. |
366 |
def assertUseLongDeltaFormat(self, cmd): |
367 |
log = self.run_bzr(cmd)[0] |
|
368 |
# Check that we use the long status format
|
|
|
3947.1.7
by Ian Clatworthy
tweak indenting/offsetting for --short given dotted revno lengths |
369 |
self.assertNotContainsRe(log, '(?m)^\s*A hello.txt$') |
370 |
self.assertContainsRe(log, '(?m)^\s*added:$') |
|
|
3874.1.8
by Vincent Ladeuil
Fixed as ber Robert's review. |
371 |
|
372 |
def test_log_short_verbose(self): |
|
373 |
self.assertUseShortDeltaFormat(['log', '--short', '-v']) |
|
374 |
||
|
3874.1.4
by Vincent Ladeuil
Fixed as per Aarons' comment. |
375 |
def test_log_short_verbose_verbose(self): |
|
3874.1.8
by Vincent Ladeuil
Fixed as ber Robert's review. |
376 |
self.assertUseLongDeltaFormat(['log', '--short', '-vv']) |
|
3874.1.4
by Vincent Ladeuil
Fixed as per Aarons' comment. |
377 |
|
378 |
def test_log_long_verbose(self): |
|
|
3874.1.7
by Vincent Ladeuil
Restrict '-v' change to log --short only. |
379 |
# Check that we use the long status format, ignoring the verbosity
|
380 |
# level
|
|
|
3874.1.8
by Vincent Ladeuil
Fixed as ber Robert's review. |
381 |
self.assertUseLongDeltaFormat(['log', '--long', '-v']) |
|
3874.1.4
by Vincent Ladeuil
Fixed as per Aarons' comment. |
382 |
|
383 |
def test_log_long_verbose_verbose(self): |
|
|
3874.1.7
by Vincent Ladeuil
Restrict '-v' change to log --short only. |
384 |
# Check that we use the long status format, ignoring the verbosity
|
385 |
# level
|
|
|
3874.1.8
by Vincent Ladeuil
Fixed as ber Robert's review. |
386 |
self.assertUseLongDeltaFormat(['log', '--long', '-vv']) |
|
3874.1.1
by Vincent Ladeuil
Fix #87179 by using the short status format when the short format is used for log. |
387 |
|
|
3144.7.9
by Guillermo Gonzalez
* bzrlib.log.show_roperties don't hide handler errors |
388 |
|
|
4955.4.8
by Vincent Ladeuil
Simplify more tests. |
389 |
class TestLogMerges(TestLogWithLogCatcher): |
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
390 |
|
391 |
def setUp(self): |
|
392 |
super(TestLogMerges, self).setUp() |
|
393 |
self.make_branches_with_merges() |
|
394 |
||
395 |
def make_branches_with_merges(self): |
|
396 |
level0 = self.make_branch_and_tree('level0') |
|
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
397 |
self.wt_commit(level0, 'in branch level0') |
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
398 |
level1 = level0.bzrdir.sprout('level1').open_workingtree() |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
399 |
self.wt_commit(level1, 'in branch level1') |
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
400 |
level2 = level1.bzrdir.sprout('level2').open_workingtree() |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
401 |
self.wt_commit(level2, 'in branch level2') |
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
402 |
level1.merge_from_branch(level2.branch) |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
403 |
self.wt_commit(level1, 'merge branch level2') |
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
404 |
level0.merge_from_branch(level1.branch) |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
405 |
self.wt_commit(level0, 'merge branch level1') |
|
3947.1.3
by Ian Clatworthy
blackbox tests |
406 |
|
|
2466.12.1
by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions. |
407 |
def test_merges_are_indented_by_level(self): |
|
4955.4.8
by Vincent Ladeuil
Simplify more tests. |
408 |
self.run_bzr(['log', '-n0'], working_dir='level0') |
409 |
revnos_and_depth = [(r.revno, r.merge_depth) |
|
410 |
for r in self.get_captured_revisions()] |
|
411 |
self.assertEqual([('2', 0), ('1.1.2', 1), ('1.2.1', 2), ('1.1.1', 1), |
|
412 |
('1', 0)], |
|
413 |
[(r.revno, r.merge_depth) |
|
414 |
for r in self.get_captured_revisions()]) |
|
|
1685.1.5
by John Arbash Meinel
Merged test_log.py.moved into test_log.py |
415 |
|
|
3947.1.3
by Ian Clatworthy
blackbox tests |
416 |
def test_force_merge_revisions_off(self): |
|
4955.4.8
by Vincent Ladeuil
Simplify more tests. |
417 |
self.assertLogRevnos(['-n1'], ['2', '1'], working_dir='level0') |
|
3947.1.3
by Ian Clatworthy
blackbox tests |
418 |
|
419 |
def test_force_merge_revisions_on(self): |
|
|
4955.4.8
by Vincent Ladeuil
Simplify more tests. |
420 |
self.assertLogRevnos(['-n0'], ['2', '1.1.2', '1.2.1', '1.1.1', '1'], |
421 |
working_dir='level0') |
|
|
3947.1.7
by Ian Clatworthy
tweak indenting/offsetting for --short given dotted revno lengths |
422 |
|
|
4221.2.1
by Ian Clatworthy
--include-merges as an alias for --levels 0 in log |
423 |
def test_include_merges(self): |
424 |
# Confirm --include-merges gives the same output as -n0
|
|
|
4955.4.8
by Vincent Ladeuil
Simplify more tests. |
425 |
self.assertLogRevnos(['--include-merges'], |
426 |
['2', '1.1.2', '1.2.1', '1.1.1', '1'], |
|
427 |
working_dir='level0') |
|
428 |
self.assertLogRevnos(['--include-merges'], |
|
429 |
['2', '1.1.2', '1.2.1', '1.1.1', '1'], |
|
430 |
working_dir='level0') |
|
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
431 |
out_im, err_im = self.run_bzr('log --include-merges', |
432 |
working_dir='level0') |
|
433 |
out_n0, err_n0 = self.run_bzr('log -n0', working_dir='level0') |
|
434 |
self.assertEqual('', err_im) |
|
435 |
self.assertEqual('', err_n0) |
|
|
4221.2.1
by Ian Clatworthy
--include-merges as an alias for --levels 0 in log |
436 |
self.assertEqual(out_im, out_n0) |
437 |
||
|
3947.1.7
by Ian Clatworthy
tweak indenting/offsetting for --short given dotted revno lengths |
438 |
def test_force_merge_revisions_N(self): |
|
4955.4.8
by Vincent Ladeuil
Simplify more tests. |
439 |
self.assertLogRevnos(['-n2'], |
440 |
['2', '1.1.2', '1.1.1', '1'], |
|
441 |
working_dir='level0') |
|
|
3947.1.3
by Ian Clatworthy
blackbox tests |
442 |
|
|
2466.12.1
by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions. |
443 |
def test_merges_single_merge_rev(self): |
|
4955.4.8
by Vincent Ladeuil
Simplify more tests. |
444 |
self.assertLogRevnosAndDepths(['-n0', '-r1.1.2'], |
445 |
[('1.1.2', 0), ('1.2.1', 1)], |
|
446 |
working_dir='level0') |
|
|
2466.12.1
by Kent Gibson
Fix ``bzr log -r`` to support selecting merge revisions. |
447 |
|
448 |
def test_merges_partial_range(self): |
|
|
4955.4.8
by Vincent Ladeuil
Simplify more tests. |
449 |
self.assertLogRevnosAndDepths( |
450 |
['-n0', '-r1.1.1..1.1.2'], |
|
451 |
[('1.1.2', 0), ('1.2.1', 1), ('1.1.1', 0)], |
|
452 |
working_dir='level0') |
|
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
453 |
|
|
4511.3.1
by Marius Kruger
add test_merges_partial_range_ignore_before_lower_bound |
454 |
def test_merges_partial_range_ignore_before_lower_bound(self): |
|
4511.3.11
by Marius Kruger
* fix tests again |
455 |
"""Dont show revisions before the lower bound's merged revs""" |
|
4955.4.8
by Vincent Ladeuil
Simplify more tests. |
456 |
self.assertLogRevnosAndDepths( |
457 |
['-n0', '-r1.1.2..2'], |
|
458 |
[('2', 0), ('1.1.2', 1), ('1.2.1', 2)], |
|
459 |
working_dir='level0') |
|
|
4511.3.1
by Marius Kruger
add test_merges_partial_range_ignore_before_lower_bound |
460 |
|
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
461 |
|
|
4955.4.11
by Vincent Ladeuil
Give some tests a better focus and simplify them accordingly. |
462 |
class TestLogDiff(TestLogWithLogCatcher): |
463 |
||
464 |
# FIXME: We need specific tests for each LogFormatter about how the diffs
|
|
465 |
# are displayed: --long indent them by depth, --short use a fixed
|
|
466 |
# indent and --line does't display them. -- vila 10019
|
|
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
467 |
|
468 |
def setUp(self): |
|
469 |
super(TestLogDiff, self).setUp() |
|
470 |
self.make_branch_with_diffs() |
|
471 |
||
472 |
def make_branch_with_diffs(self): |
|
473 |
level0 = self.make_branch_and_tree('level0') |
|
474 |
self.build_tree(['level0/file1', 'level0/file2']) |
|
475 |
level0.add('file1') |
|
476 |
level0.add('file2') |
|
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
477 |
self.wt_commit(level0, 'in branch level0') |
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
478 |
|
479 |
level1 = level0.bzrdir.sprout('level1').open_workingtree() |
|
480 |
self.build_tree_contents([('level1/file2', 'hello\n')]) |
|
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
481 |
self.wt_commit(level1, 'in branch level1') |
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
482 |
level0.merge_from_branch(level1.branch) |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
483 |
self.wt_commit(level0, 'merge branch level1') |
|
3943.5.3
by Ian Clatworthy
add tests |
484 |
|
|
4955.4.11
by Vincent Ladeuil
Give some tests a better focus and simplify them accordingly. |
485 |
def _diff_file1_revno1(self): |
486 |
return """=== added file 'file1' |
|
|
4325.4.6
by Vincent Ladeuil
Fixed as per John's and Markus reviews. |
487 |
--- file1\t1970-01-01 00:00:00 +0000 |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
488 |
+++ file1\t2005-11-22 00:00:00 +0000 |
|
3943.5.6
by Ian Clatworthy
feedback from jam's review |
489 |
@@ -0,0 +1,1 @@
|
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
490 |
+contents of level0/file1
|
|
3943.5.6
by Ian Clatworthy
feedback from jam's review |
491 |
|
|
4955.4.11
by Vincent Ladeuil
Give some tests a better focus and simplify them accordingly. |
492 |
"""
|
493 |
||
494 |
def _diff_file2_revno2(self): |
|
495 |
return """=== modified file 'file2' |
|
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
496 |
--- file2\t2005-11-22 00:00:00 +0000 |
497 |
+++ file2\t2005-11-22 00:00:01 +0000 |
|
|
4955.4.11
by Vincent Ladeuil
Give some tests a better focus and simplify them accordingly. |
498 |
@@ -1,1 +1,1 @@
|
499 |
-contents of level0/file2
|
|
500 |
+hello
|
|
501 |
||
502 |
"""
|
|
503 |
||
504 |
def _diff_file2_revno1_1_1(self): |
|
505 |
return """=== modified file 'file2' |
|
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
506 |
--- file2\t2005-11-22 00:00:00 +0000 |
507 |
+++ file2\t2005-11-22 00:00:01 +0000 |
|
|
4955.4.11
by Vincent Ladeuil
Give some tests a better focus and simplify them accordingly. |
508 |
@@ -1,1 +1,1 @@
|
509 |
-contents of level0/file2
|
|
510 |
+hello
|
|
511 |
||
512 |
"""
|
|
513 |
||
514 |
def _diff_file2_revno1(self): |
|
515 |
return """=== added file 'file2' |
|
|
4325.4.6
by Vincent Ladeuil
Fixed as per John's and Markus reviews. |
516 |
--- file2\t1970-01-01 00:00:00 +0000 |
|
4955.4.17
by Vincent Ladeuil
Use a data factory for commit properties and reduce code duplication. |
517 |
+++ file2\t2005-11-22 00:00:00 +0000 |
|
3943.5.6
by Ian Clatworthy
feedback from jam's review |
518 |
@@ -0,0 +1,1 @@
|
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
519 |
+contents of level0/file2
|
|
4955.4.11
by Vincent Ladeuil
Give some tests a better focus and simplify them accordingly. |
520 |
|
521 |
"""
|
|
522 |
||
|
4955.4.13
by Vincent Ladeuil
Remove dead code. |
523 |
def assertLogRevnosAndDiff(self, args, expected, |
|
4955.4.11
by Vincent Ladeuil
Give some tests a better focus and simplify them accordingly. |
524 |
working_dir='.'): |
525 |
self.run_bzr(['log', '-p'] + args, working_dir=working_dir) |
|
526 |
expected_revnos_and_depths = [ |
|
527 |
(revno, depth) for revno, depth, diff in expected] |
|
528 |
# Check the revnos and depths first to make debugging easier
|
|
529 |
self.assertEqual(expected_revnos_and_depths, |
|
530 |
[(r.revno, r.merge_depth) |
|
531 |
for r in self.get_captured_revisions()]) |
|
532 |
# Now check the diffs, adding the revno in case of failure
|
|
533 |
fmt = 'In revno %s\n%s' |
|
534 |
for expected_rev, actual_rev in izip(expected, |
|
535 |
self.get_captured_revisions()): |
|
536 |
revno, depth, expected_diff = expected_rev |
|
537 |
actual_diff = actual_rev.diff |
|
538 |
self.assertEqualDiff(fmt % (revno, expected_diff), |
|
539 |
fmt % (revno, actual_diff)) |
|
540 |
||
541 |
def test_log_diff_with_merges(self): |
|
|
4955.4.13
by Vincent Ladeuil
Remove dead code. |
542 |
self.assertLogRevnosAndDiff( |
543 |
['-n0'], |
|
544 |
[('2', 0, self._diff_file2_revno2()), |
|
545 |
('1.1.1', 1, self._diff_file2_revno1_1_1()), |
|
546 |
('1', 0, self._diff_file1_revno1() |
|
547 |
+ self._diff_file2_revno1())], |
|
548 |
working_dir='level0') |
|
|
4955.4.11
by Vincent Ladeuil
Give some tests a better focus and simplify them accordingly. |
549 |
|
550 |
||
551 |
def test_log_diff_file1(self): |
|
|
4955.4.13
by Vincent Ladeuil
Remove dead code. |
552 |
self.assertLogRevnosAndDiff(['-n0', 'file1'], |
553 |
[('1', 0, self._diff_file1_revno1())], |
|
554 |
working_dir='level0') |
|
|
4955.4.11
by Vincent Ladeuil
Give some tests a better focus and simplify them accordingly. |
555 |
|
556 |
def test_log_diff_file2(self): |
|
|
4955.4.13
by Vincent Ladeuil
Remove dead code. |
557 |
self.assertLogRevnosAndDiff(['-n1', 'file2'], |
558 |
[('2', 0, self._diff_file2_revno2()), |
|
559 |
('1', 0, self._diff_file2_revno1())], |
|
560 |
working_dir='level0') |
|
|
4325.4.5
by Vincent Ladeuil
Some cleanup in blackbox log tests. |
561 |
|
562 |
||
563 |
class TestLogUnicodeDiff(TestLog): |
|
|
3943.5.4
by Ian Clatworthy
filter diff by file |
564 |
|
|
4110.1.1
by Alexander Belchenko
Fixed problem with `log -p` and non-ascii content of files: show_diff should write the diff to exact [stdout] stream. |
565 |
def test_log_show_diff_non_ascii(self): |
566 |
# Smoke test for bug #328007 UnicodeDecodeError on 'log -p'
|
|
567 |
message = u'Message with \xb5' |
|
568 |
body = 'Body with \xb5\n' |
|
569 |
wt = self.make_branch_and_tree('.') |
|
570 |
self.build_tree_contents([('foo', body)]) |
|
571 |
wt.add('foo') |
|
572 |
wt.commit(message=message) |
|
573 |
# check that command won't fail with unicode error
|
|
574 |
# don't care about exact output because we have other tests for this
|
|
575 |
out,err = self.run_bzr('log -p --long') |
|
576 |
self.assertNotEqual('', out) |
|
577 |
self.assertEqual('', err) |
|
578 |
out,err = self.run_bzr('log -p --short') |
|
579 |
self.assertNotEqual('', out) |
|
580 |
self.assertEqual('', err) |
|
581 |
out,err = self.run_bzr('log -p --line') |
|
582 |
self.assertNotEqual('', out) |
|
583 |
self.assertEqual('', err) |
|
584 |
||
|
3943.5.3
by Ian Clatworthy
add tests |
585 |
|
|
4325.4.3
by Vincent Ladeuil
More cleanups. |
586 |
class TestLogEncodings(tests.TestCaseInTempDir): |
|
1685.1.5
by John Arbash Meinel
Merged test_log.py.moved into test_log.py |
587 |
|
588 |
_mu = u'\xb5' |
|
589 |
_message = u'Message with \xb5' |
|
590 |
||
591 |
# Encodings which can encode mu
|
|
592 |
good_encodings = [ |
|
593 |
'utf-8', |
|
594 |
'latin-1', |
|
595 |
'iso-8859-1', |
|
596 |
'cp437', # Common windows encoding |
|
|
4110.1.1
by Alexander Belchenko
Fixed problem with `log -p` and non-ascii content of files: show_diff should write the diff to exact [stdout] stream. |
597 |
'cp1251', # Russian windows encoding |
|
1685.1.5
by John Arbash Meinel
Merged test_log.py.moved into test_log.py |
598 |
'cp1258', # Common windows encoding |
599 |
]
|
|
600 |
# Encodings which cannot encode mu
|
|
601 |
bad_encodings = [ |
|
602 |
'ascii', |
|
603 |
'iso-8859-2', |
|
604 |
'koi8_r', |
|
605 |
]
|
|
606 |
||
607 |
def setUp(self): |
|
|
4325.4.3
by Vincent Ladeuil
More cleanups. |
608 |
super(TestLogEncodings, self).setUp() |
|
4985.1.5
by Vincent Ladeuil
Deploying the new overrideAttr facility further reduces the complexity |
609 |
self.overrideAttr(osutils, '_cached_user_encoding') |
|
1685.1.5
by John Arbash Meinel
Merged test_log.py.moved into test_log.py |
610 |
|
611 |
def create_branch(self): |
|
612 |
bzr = self.run_bzr |
|
613 |
bzr('init') |
|
|
4955.4.16
by Vincent Ladeuil
Be windows-friendly and don't left opened files behind. |
614 |
self.build_tree_contents([('a', 'some stuff\n')]) |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
615 |
bzr('add a') |
616 |
bzr(['commit', '-m', self._message]) |
|
|
1685.1.5
by John Arbash Meinel
Merged test_log.py.moved into test_log.py |
617 |
|
618 |
def try_encoding(self, encoding, fail=False): |
|
619 |
bzr = self.run_bzr |
|
620 |
if fail: |
|
621 |
self.assertRaises(UnicodeEncodeError, |
|
622 |
self._mu.encode, encoding) |
|
623 |
encoded_msg = self._message.encode(encoding, 'replace') |
|
624 |
else: |
|
625 |
encoded_msg = self._message.encode(encoding) |
|
626 |
||
|
3224.5.4
by Andrew Bennetts
Fix test suite, mainly weeding out uses of bzrlib.user_encoding. |
627 |
old_encoding = osutils._cached_user_encoding |
|
1685.1.5
by John Arbash Meinel
Merged test_log.py.moved into test_log.py |
628 |
# This test requires that 'run_bzr' uses the current
|
629 |
# bzrlib, because we override user_encoding, and expect
|
|
630 |
# it to be used
|
|
631 |
try: |
|
|
3224.5.4
by Andrew Bennetts
Fix test suite, mainly weeding out uses of bzrlib.user_encoding. |
632 |
osutils._cached_user_encoding = 'ascii' |
|
1685.1.5
by John Arbash Meinel
Merged test_log.py.moved into test_log.py |
633 |
# We should be able to handle any encoding
|
634 |
out, err = bzr('log', encoding=encoding) |
|
635 |
if not fail: |
|
636 |
# Make sure we wrote mu as we expected it to exist
|
|
637 |
self.assertNotEqual(-1, out.find(encoded_msg)) |
|
638 |
out_unicode = out.decode(encoding) |
|
639 |
self.assertNotEqual(-1, out_unicode.find(self._message)) |
|
640 |
else: |
|
641 |
self.assertNotEqual(-1, out.find('Message with ?')) |
|
642 |
finally: |
|
|
3224.5.4
by Andrew Bennetts
Fix test suite, mainly weeding out uses of bzrlib.user_encoding. |
643 |
osutils._cached_user_encoding = old_encoding |
|
1685.1.5
by John Arbash Meinel
Merged test_log.py.moved into test_log.py |
644 |
|
645 |
def test_log_handles_encoding(self): |
|
646 |
self.create_branch() |
|
647 |
||
648 |
for encoding in self.good_encodings: |
|
649 |
self.try_encoding(encoding) |
|
650 |
||
651 |
def test_log_handles_bad_encoding(self): |
|
652 |
self.create_branch() |
|
653 |
||
654 |
for encoding in self.bad_encodings: |
|
655 |
self.try_encoding(encoding, fail=True) |
|
656 |
||
657 |
def test_stdout_encoding(self): |
|
658 |
bzr = self.run_bzr |
|
|
3224.5.4
by Andrew Bennetts
Fix test suite, mainly weeding out uses of bzrlib.user_encoding. |
659 |
osutils._cached_user_encoding = "cp1251" |
|
1685.1.5
by John Arbash Meinel
Merged test_log.py.moved into test_log.py |
660 |
|
661 |
bzr('init') |
|
662 |
self.build_tree(['a']) |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
663 |
bzr('add a') |
664 |
bzr(['commit', '-m', u'\u0422\u0435\u0441\u0442']) |
|
|
1685.1.5
by John Arbash Meinel
Merged test_log.py.moved into test_log.py |
665 |
stdout, stderr = self.run_bzr('log', encoding='cp866') |
666 |
||
667 |
message = stdout.splitlines()[-1] |
|
668 |
||
669 |
# explanation of the check:
|
|
670 |
# u'\u0422\u0435\u0441\u0442' is word 'Test' in russian
|
|
671 |
# in cp866 encoding this is string '\x92\xa5\xe1\xe2'
|
|
672 |
# in cp1251 encoding this is string '\xd2\xe5\xf1\xf2'
|
|
673 |
# This test should check that output of log command
|
|
674 |
# encoded to sys.stdout.encoding
|
|
675 |
test_in_cp866 = '\x92\xa5\xe1\xe2' |
|
676 |
test_in_cp1251 = '\xd2\xe5\xf1\xf2' |
|
677 |
# Make sure the log string is encoded in cp866
|
|
678 |
self.assertEquals(test_in_cp866, message[2:]) |
|
679 |
# Make sure the cp1251 string is not found anywhere
|
|
680 |
self.assertEquals(-1, stdout.find(test_in_cp1251)) |
|
681 |
||
|
1551.10.18
by Aaron Bentley
Log works in local treeless branches (#84247) |
682 |
|
|
4955.4.9
by Vincent Ladeuil
More simplifications. |
683 |
class TestLogFile(TestLogWithLogCatcher): |
|
1551.10.18
by Aaron Bentley
Log works in local treeless branches (#84247) |
684 |
|
685 |
def test_log_local_branch_file(self): |
|
686 |
"""We should be able to log files in local treeless branches""" |
|
687 |
tree = self.make_branch_and_tree('tree') |
|
688 |
self.build_tree(['tree/file']) |
|
689 |
tree.add('file') |
|
690 |
tree.commit('revision 1') |
|
691 |
tree.bzrdir.destroy_workingtree() |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
692 |
self.run_bzr('log tree/file') |
|
2359.1.1
by Kent Gibson
Fix ``bzr log <file>`` so it only logs the revisions that changed the file, and does it faster. |
693 |
|
|
3943.6.1
by Ian Clatworthy
find file using the end revision |
694 |
def prepare_tree(self, complex=False): |
|
3943.6.3
by Ian Clatworthy
search the start tree if the end tree doesn't have a file |
695 |
# The complex configuration includes deletes and renames
|
|
2359.1.1
by Kent Gibson
Fix ``bzr log <file>`` so it only logs the revisions that changed the file, and does it faster. |
696 |
tree = self.make_branch_and_tree('parent') |
697 |
self.build_tree(['parent/file1', 'parent/file2', 'parent/file3']) |
|
698 |
tree.add('file1') |
|
699 |
tree.commit('add file1') |
|
700 |
tree.add('file2') |
|
701 |
tree.commit('add file2') |
|
702 |
tree.add('file3') |
|
703 |
tree.commit('add file3') |
|
|
2664.14.1
by Daniel Watkins
Fixed tests.blackbox.test_log to use internals where appropriate. |
704 |
child_tree = tree.bzrdir.sprout('child').open_workingtree() |
705 |
self.build_tree_contents([('child/file2', 'hello')]) |
|
706 |
child_tree.commit(message='branch 1') |
|
707 |
tree.merge_from_branch(child_tree.branch) |
|
708 |
tree.commit(message='merge child branch') |
|
|
3943.6.1
by Ian Clatworthy
find file using the end revision |
709 |
if complex: |
|
3943.6.3
by Ian Clatworthy
search the start tree if the end tree doesn't have a file |
710 |
tree.remove('file2') |
711 |
tree.commit('remove file2') |
|
712 |
tree.rename_one('file3', 'file4') |
|
713 |
tree.commit('file3 is now called file4') |
|
|
3943.6.1
by Ian Clatworthy
find file using the end revision |
714 |
tree.remove('file1') |
|
3943.6.3
by Ian Clatworthy
search the start tree if the end tree doesn't have a file |
715 |
tree.commit('remove file1') |
|
2359.1.1
by Kent Gibson
Fix ``bzr log <file>`` so it only logs the revisions that changed the file, and does it faster. |
716 |
os.chdir('parent') |
|
3940.1.2
by Ian Clatworthy
add test |
717 |
|
|
4955.4.9
by Vincent Ladeuil
More simplifications. |
718 |
# FIXME: It would be good to parametrize the following tests against all
|
719 |
# formatters. But the revisions selection is not *currently* part of the
|
|
720 |
# LogFormatter contract, so using LogCatcher is sufficient -- vila 100118
|
|
721 |
def test_log_file1(self): |
|
722 |
self.prepare_tree() |
|
723 |
self.assertLogRevnos(['-n0', 'file1'], ['1']) |
|
724 |
||
725 |
def test_log_file2(self): |
|
726 |
self.prepare_tree() |
|
727 |
# file2 full history
|
|
728 |
self.assertLogRevnos(['-n0', 'file2'], ['4', '3.1.1', '2']) |
|
729 |
# file2 in a merge revision
|
|
730 |
self.assertLogRevnos(['-n0', '-r3.1.1', 'file2'], ['3.1.1']) |
|
731 |
# file2 in a mainline revision
|
|
732 |
self.assertLogRevnos(['-n0', '-r4', 'file2'], ['4', '3.1.1']) |
|
733 |
# file2 since a revision
|
|
734 |
self.assertLogRevnos(['-n0', '-r3..', 'file2'], ['4', '3.1.1']) |
|
735 |
# file2 up to a revision
|
|
736 |
self.assertLogRevnos(['-n0', '-r..3', 'file2'], ['2']) |
|
737 |
||
738 |
def test_log_file3(self): |
|
739 |
self.prepare_tree() |
|
740 |
self.assertLogRevnos(['-n0', 'file3'], ['3']) |
|
|
3940.1.2
by Ian Clatworthy
add test |
741 |
|
|
3943.6.4
by Ian Clatworthy
review feedback from vila |
742 |
def test_log_file_historical_missing(self): |
|
3943.6.3
by Ian Clatworthy
search the start tree if the end tree doesn't have a file |
743 |
# Check logging a deleted file gives an error if the
|
744 |
# file isn't found at the end or start of the revision range
|
|
|
3943.6.4
by Ian Clatworthy
review feedback from vila |
745 |
self.prepare_tree(complex=True) |
|
3943.6.3
by Ian Clatworthy
search the start tree if the end tree doesn't have a file |
746 |
err_msg = "Path unknown at end or start of revision range: file2" |
747 |
err = self.run_bzr('log file2', retcode=3)[1] |
|
|
3943.6.1
by Ian Clatworthy
find file using the end revision |
748 |
self.assertContainsRe(err, err_msg) |
749 |
||
|
3943.6.4
by Ian Clatworthy
review feedback from vila |
750 |
def test_log_file_historical_end(self): |
|
3943.6.3
by Ian Clatworthy
search the start tree if the end tree doesn't have a file |
751 |
# Check logging a deleted file is ok if the file existed
|
752 |
# at the end the revision range
|
|
|
3943.6.4
by Ian Clatworthy
review feedback from vila |
753 |
self.prepare_tree(complex=True) |
|
4955.4.9
by Vincent Ladeuil
More simplifications. |
754 |
self.assertLogRevnos(['-n0', '-r..4', 'file2'], ['4', '3.1.1', '2']) |
|
3943.6.3
by Ian Clatworthy
search the start tree if the end tree doesn't have a file |
755 |
|
|
3943.6.4
by Ian Clatworthy
review feedback from vila |
756 |
def test_log_file_historical_start(self): |
|
3943.6.3
by Ian Clatworthy
search the start tree if the end tree doesn't have a file |
757 |
# Check logging a deleted file is ok if the file existed
|
758 |
# at the start of the revision range
|
|
|
3943.6.4
by Ian Clatworthy
review feedback from vila |
759 |
self.prepare_tree(complex=True) |
|
4955.4.9
by Vincent Ladeuil
More simplifications. |
760 |
self.assertLogRevnos(['file1'], ['1']) |
|
3943.6.1
by Ian Clatworthy
find file using the end revision |
761 |
|
762 |
def test_log_file_renamed(self): |
|
|
3943.6.3
by Ian Clatworthy
search the start tree if the end tree doesn't have a file |
763 |
"""File matched against revision range, not current tree.""" |
|
3943.6.1
by Ian Clatworthy
find file using the end revision |
764 |
self.prepare_tree(complex=True) |
|
3943.6.3
by Ian Clatworthy
search the start tree if the end tree doesn't have a file |
765 |
|
|
3943.6.1
by Ian Clatworthy
find file using the end revision |
766 |
# Check logging a renamed file gives an error by default
|
|
3943.6.3
by Ian Clatworthy
search the start tree if the end tree doesn't have a file |
767 |
err_msg = "Path unknown at end or start of revision range: file3" |
|
3943.6.1
by Ian Clatworthy
find file using the end revision |
768 |
err = self.run_bzr('log file3', retcode=3)[1] |
769 |
self.assertContainsRe(err, err_msg) |
|
770 |
||
771 |
# Check we can see a renamed file if we give the right end revision
|
|
|
4955.4.9
by Vincent Ladeuil
More simplifications. |
772 |
self.assertLogRevnos(['-r..4', 'file3'], ['3']) |
|
4202.2.1
by Ian Clatworthy
get directory logging working again |
773 |
|
774 |
||
|
4955.4.10
by Vincent Ladeuil
More simplification. |
775 |
class TestLogMultiple(TestLogWithLogCatcher): |
|
4202.2.1
by Ian Clatworthy
get directory logging working again |
776 |
|
777 |
def prepare_tree(self): |
|
778 |
tree = self.make_branch_and_tree('parent') |
|
779 |
self.build_tree([ |
|
780 |
'parent/file1', |
|
781 |
'parent/file2', |
|
782 |
'parent/dir1/', |
|
783 |
'parent/dir1/file5', |
|
784 |
'parent/dir1/dir2/', |
|
785 |
'parent/dir1/dir2/file3', |
|
786 |
'parent/file4']) |
|
787 |
tree.add('file1') |
|
|
4202.2.2
by Ian Clatworthy
improve signal-to-noise ratio in tests |
788 |
tree.commit('add file1') |
|
4202.2.1
by Ian Clatworthy
get directory logging working again |
789 |
tree.add('file2') |
|
4202.2.2
by Ian Clatworthy
improve signal-to-noise ratio in tests |
790 |
tree.commit('add file2') |
|
4202.2.1
by Ian Clatworthy
get directory logging working again |
791 |
tree.add(['dir1', 'dir1/dir2', 'dir1/dir2/file3']) |
|
4202.2.2
by Ian Clatworthy
improve signal-to-noise ratio in tests |
792 |
tree.commit('add file3') |
|
4202.2.1
by Ian Clatworthy
get directory logging working again |
793 |
tree.add('file4') |
|
4202.2.2
by Ian Clatworthy
improve signal-to-noise ratio in tests |
794 |
tree.commit('add file4') |
|
4202.2.1
by Ian Clatworthy
get directory logging working again |
795 |
tree.add('dir1/file5') |
|
4202.2.2
by Ian Clatworthy
improve signal-to-noise ratio in tests |
796 |
tree.commit('add file5') |
|
4202.2.1
by Ian Clatworthy
get directory logging working again |
797 |
child_tree = tree.bzrdir.sprout('child').open_workingtree() |
798 |
self.build_tree_contents([('child/file2', 'hello')]) |
|
|
4202.2.2
by Ian Clatworthy
improve signal-to-noise ratio in tests |
799 |
child_tree.commit(message='branch 1') |
|
4202.2.1
by Ian Clatworthy
get directory logging working again |
800 |
tree.merge_from_branch(child_tree.branch) |
|
4202.2.2
by Ian Clatworthy
improve signal-to-noise ratio in tests |
801 |
tree.commit(message='merge child branch') |
|
4202.2.1
by Ian Clatworthy
get directory logging working again |
802 |
os.chdir('parent') |
803 |
||
804 |
def test_log_files(self): |
|
805 |
"""The log for multiple file should only list revs for those files""" |
|
806 |
self.prepare_tree() |
|
|
4955.4.10
by Vincent Ladeuil
More simplification. |
807 |
self.assertLogRevnos(['file1', 'file2', 'dir1/dir2/file3'], |
808 |
['6', '5.1.1', '3', '2', '1']) |
|
|
4202.2.1
by Ian Clatworthy
get directory logging working again |
809 |
|
810 |
def test_log_directory(self): |
|
811 |
"""The log for a directory should show all nested files.""" |
|
812 |
self.prepare_tree() |
|
|
4955.4.10
by Vincent Ladeuil
More simplification. |
813 |
self.assertLogRevnos(['dir1'], ['5', '3']) |
|
4202.2.1
by Ian Clatworthy
get directory logging working again |
814 |
|
815 |
def test_log_nested_directory(self): |
|
816 |
"""The log for a directory should show all nested files.""" |
|
817 |
self.prepare_tree() |
|
|
4955.4.10
by Vincent Ladeuil
More simplification. |
818 |
self.assertLogRevnos(['dir1/dir2'], ['3']) |
|
4202.2.1
by Ian Clatworthy
get directory logging working again |
819 |
|
820 |
def test_log_in_nested_directory(self): |
|
821 |
"""The log for a directory should show all nested files.""" |
|
822 |
self.prepare_tree() |
|
823 |
os.chdir("dir1") |
|
|
4955.4.10
by Vincent Ladeuil
More simplification. |
824 |
self.assertLogRevnos(['.'], ['5', '3']) |
|
4202.2.1
by Ian Clatworthy
get directory logging working again |
825 |
|
826 |
def test_log_files_and_directories(self): |
|
827 |
"""Logging files and directories together should be fine.""" |
|
828 |
self.prepare_tree() |
|
|
4955.4.10
by Vincent Ladeuil
More simplification. |
829 |
self.assertLogRevnos(['file4', 'dir1/dir2'], ['4', '3']) |
|
4202.2.1
by Ian Clatworthy
get directory logging working again |
830 |
|
831 |
def test_log_files_and_dirs_in_nested_directory(self): |
|
832 |
"""The log for a directory should show all nested files.""" |
|
833 |
self.prepare_tree() |
|
834 |
os.chdir("dir1") |
|
|
4955.4.10
by Vincent Ladeuil
More simplification. |
835 |
self.assertLogRevnos(['dir2', 'file5'], ['5', '3']) |