bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2007-2010, 2016 Canonical Ltd
|
|
2225.1.1
by Aaron Bentley
Added revert change display, with tests |
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
|
|
2225.1.1
by Aaron Bentley
Added revert change display, with tests |
16 |
|
|
1551.10.6
by Aaron Bentley
Support kind changes in tree deltas |
17 |
import os |
18 |
||
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
19 |
from .. import ( |
|
1551.10.6
by Aaron Bentley
Support kind changes in tree deltas |
20 |
delta as _mod_delta, |
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
21 |
revision as _mod_revision, |
|
2225.1.1
by Aaron Bentley
Added revert change display, with tests |
22 |
tests, |
23 |
)
|
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
24 |
from ..sixish import ( |
|
7067.13.1
by Jelmer Vernooij
Some more fixes for Python 3. |
25 |
PY3, |
|
6631.4.1
by Martin
Rename report_delta param from filter to predicate with tests and release notes |
26 |
StringIO, |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
27 |
)
|
|
2225.1.1
by Aaron Bentley
Added revert change display, with tests |
28 |
|
29 |
||
|
2225.1.2
by Aaron Bentley
Ensure that changes are detected correctly |
30 |
class InstrumentedReporter(object): |
31 |
def __init__(self): |
|
32 |
self.calls = [] |
|
33 |
||
34 |
def report(self, file_id, path, versioned, renamed, modified, exe_change, |
|
35 |
kind): |
|
36 |
self.calls.append((file_id, path, versioned, renamed, modified, |
|
37 |
exe_change, kind)) |
|
38 |
||
|
2225.1.4
by Aaron Bentley
PEP8 cleanup |
39 |
|
|
2225.1.1
by Aaron Bentley
Added revert change display, with tests |
40 |
class TestReportChanges(tests.TestCase): |
|
2225.1.4
by Aaron Bentley
PEP8 cleanup |
41 |
"""Test the new change reporting infrastructure""" |
|
2225.1.1
by Aaron Bentley
Added revert change display, with tests |
42 |
|
|
7067.13.11
by Jelmer Vernooij
File ids are bytestrings. |
43 |
def assertReport(self, expected, file_id=b'fid', path='path', |
|
2225.1.3
by Aaron Bentley
change method names to assertFoo |
44 |
versioned_change='unchanged', renamed=False, |
45 |
modified='unchanged', exe_change=False, |
|
|
2255.7.97
by Robert Collins
Teach delta.report_changes about unversioned files, removing all inventory access during status --short. |
46 |
kind=('file', 'file'), old_path=None, |
|
3586.1.30
by Ian Clatworthy
add view support to change reporting |
47 |
unversioned_filter=None, view_info=None): |
48 |
if expected is None: |
|
49 |
expected_lines = None |
|
50 |
else: |
|
51 |
expected_lines = [expected] |
|
52 |
self.assertReportLines(expected_lines, file_id, path, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
53 |
versioned_change, renamed, |
54 |
modified, exe_change, |
|
55 |
kind, old_path, |
|
56 |
unversioned_filter, view_info) |
|
|
3586.1.30
by Ian Clatworthy
add view support to change reporting |
57 |
|
|
7067.13.11
by Jelmer Vernooij
File ids are bytestrings. |
58 |
def assertReportLines(self, expected_lines, file_id=b'fid', path='path', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
59 |
versioned_change='unchanged', renamed=False, |
60 |
modified='unchanged', exe_change=False, |
|
61 |
kind=('file', 'file'), old_path=None, |
|
62 |
unversioned_filter=None, view_info=None): |
|
|
2225.1.1
by Aaron Bentley
Added revert change display, with tests |
63 |
result = [] |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
64 |
|
|
2225.1.1
by Aaron Bentley
Added revert change display, with tests |
65 |
def result_line(format, *args): |
66 |
result.append(format % args) |
|
|
1551.10.25
by Aaron Bentley
Make ChangeReporter private |
67 |
reporter = _mod_delta._ChangeReporter(result_line, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
68 |
unversioned_filter=unversioned_filter, view_info=view_info) |
|
2255.7.96
by Robert Collins
Change _iter_changes interface to yield both old and new paths. |
69 |
reporter.report(file_id, (old_path, path), versioned_change, renamed, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
70 |
modified, exe_change, kind) |
|
3586.1.30
by Ian Clatworthy
add view support to change reporting |
71 |
if expected_lines is not None: |
|
5422.3.8
by Martin Pool
Try for a better failure message in test_delta |
72 |
self.assertEqualDiff('\n'.join(expected_lines), '\n'.join(result)) |
|
2255.7.97
by Robert Collins
Teach delta.report_changes about unversioned files, removing all inventory access during status --short. |
73 |
else: |
74 |
self.assertEqual([], result) |
|
|
2225.1.1
by Aaron Bentley
Added revert change display, with tests |
75 |
|
76 |
def test_rename(self): |
|
|
2225.1.3
by Aaron Bentley
change method names to assertFoo |
77 |
self.assertReport('R old => path', renamed=True, old_path='old') |
78 |
self.assertReport(' path') |
|
|
1551.10.12
by Aaron Bentley
Handle simultaneous creation+rename |
79 |
self.assertReport('RN old => path', renamed=True, old_path='old', |
80 |
modified='created', kind=(None, 'file')) |
|
|
2225.1.1
by Aaron Bentley
Added revert change display, with tests |
81 |
|
82 |
def test_kind(self): |
|
|
2225.1.3
by Aaron Bentley
change method names to assertFoo |
83 |
self.assertReport(' K path => path/', modified='kind changed', |
|
2255.7.96
by Robert Collins
Change _iter_changes interface to yield both old and new paths. |
84 |
kind=('file', 'directory'), old_path='path') |
|
2225.1.3
by Aaron Bentley
change method names to assertFoo |
85 |
self.assertReport(' K path/ => path', modified='kind changed', |
86 |
kind=('directory', 'file'), old_path='old') |
|
87 |
self.assertReport('RK old => path/', renamed=True, |
|
|
2225.1.5
by Aaron Bentley
Clean up whitespace changes |
88 |
modified='kind changed', |
|
2225.1.3
by Aaron Bentley
change method names to assertFoo |
89 |
kind=('file', 'directory'), old_path='old') |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
90 |
|
|
2225.1.1
by Aaron Bentley
Added revert change display, with tests |
91 |
def test_new(self): |
|
2225.1.3
by Aaron Bentley
change method names to assertFoo |
92 |
self.assertReport(' N path/', modified='created', |
93 |
kind=(None, 'directory')) |
|
94 |
self.assertReport('+ path/', versioned_change='added', |
|
95 |
modified='unchanged', kind=(None, 'directory')) |
|
|
1551.10.11
by Aaron Bentley
Handle case where file-id only is added |
96 |
self.assertReport('+ path', versioned_change='added', |
97 |
modified='unchanged', kind=(None, None)) |
|
|
2225.1.3
by Aaron Bentley
change method names to assertFoo |
98 |
self.assertReport('+N path/', versioned_change='added', |
99 |
modified='created', kind=(None, 'directory')) |
|
100 |
self.assertReport('+M path/', versioned_change='added', |
|
101 |
modified='modified', kind=(None, 'directory')) |
|
|
2225.1.1
by Aaron Bentley
Added revert change display, with tests |
102 |
|
103 |
def test_removal(self): |
|
|
2225.1.3
by Aaron Bentley
change method names to assertFoo |
104 |
self.assertReport(' D path/', modified='deleted', |
105 |
kind=('directory', None), old_path='old') |
|
106 |
self.assertReport('- path/', versioned_change='removed', |
|
|
2255.2.232
by Robert Collins
Make WorkingTree4 report support for references based on the repositories capabilities. |
107 |
old_path='path', |
|
2225.1.3
by Aaron Bentley
change method names to assertFoo |
108 |
kind=(None, 'directory')) |
109 |
self.assertReport('-D path', versioned_change='removed', |
|
|
2255.2.232
by Robert Collins
Make WorkingTree4 report support for references based on the repositories capabilities. |
110 |
old_path='path', |
|
2225.1.3
by Aaron Bentley
change method names to assertFoo |
111 |
modified='deleted', kind=('file', 'directory')) |
|
2225.1.1
by Aaron Bentley
Added revert change display, with tests |
112 |
|
113 |
def test_modification(self): |
|
|
2225.1.3
by Aaron Bentley
change method names to assertFoo |
114 |
self.assertReport(' M path', modified='modified') |
115 |
self.assertReport(' M* path', modified='modified', exe_change=True) |
|
|
2225.1.2
by Aaron Bentley
Ensure that changes are detected correctly |
116 |
|
|
2255.7.97
by Robert Collins
Teach delta.report_changes about unversioned files, removing all inventory access during status --short. |
117 |
def test_unversioned(self): |
118 |
# by default any unversioned file is output
|
|
119 |
self.assertReport('? subdir/foo~', file_id=None, path='subdir/foo~', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
120 |
old_path=None, versioned_change='unversioned', |
121 |
renamed=False, modified='created', exe_change=False, |
|
122 |
kind=(None, 'file')) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
123 |
# but we can choose to filter these. Probably that should be done
|
|
2255.7.97
by Robert Collins
Teach delta.report_changes about unversioned files, removing all inventory access during status --short. |
124 |
# close to the tree, but this is a reasonable starting point.
|
125 |
self.assertReport(None, file_id=None, path='subdir/foo~', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
126 |
old_path=None, versioned_change='unversioned', |
127 |
renamed=False, modified='created', exe_change=False, |
|
128 |
kind=(None, 'file'), unversioned_filter=lambda x: True) |
|
|
2255.7.97
by Robert Collins
Teach delta.report_changes about unversioned files, removing all inventory access during status --short. |
129 |
|
|
5504.5.1
by Rory Yorke
Show missing files in bzr status (bug 134168). |
130 |
def test_missing(self): |
131 |
self.assertReport('+! missing.c', file_id=None, path='missing.c', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
132 |
old_path=None, versioned_change='added', |
133 |
renamed=False, modified='missing', exe_change=False, |
|
134 |
kind=(None, None)) |
|
|
5504.5.1
by Rory Yorke
Show missing files in bzr status (bug 134168). |
135 |
|
|
3586.1.30
by Ian Clatworthy
add view support to change reporting |
136 |
def test_view_filtering(self): |
137 |
# If a file in within the view, it should appear in the output
|
|
138 |
expected_lines = [ |
|
139 |
"Operating on whole tree but only reporting on 'my' view.", |
|
140 |
" M path"] |
|
141 |
self.assertReportLines(expected_lines, modified='modified', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
142 |
view_info=('my', ['path'])) |
|
3586.1.30
by Ian Clatworthy
add view support to change reporting |
143 |
# If a file in outside the view, it should not appear in the output
|
144 |
expected_lines = [ |
|
145 |
"Operating on whole tree but only reporting on 'my' view."] |
|
146 |
self.assertReportLines(expected_lines, modified='modified', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
147 |
path="foo", view_info=('my', ['path'])) |
|
3586.1.30
by Ian Clatworthy
add view support to change reporting |
148 |
|
|
2225.1.3
by Aaron Bentley
change method names to assertFoo |
149 |
def assertChangesEqual(self, |
|
7067.13.11
by Jelmer Vernooij
File ids are bytestrings. |
150 |
file_id=b'fid', |
|
2255.7.97
by Robert Collins
Teach delta.report_changes about unversioned files, removing all inventory access during status --short. |
151 |
paths=('path', 'path'), |
|
2225.1.3
by Aaron Bentley
change method names to assertFoo |
152 |
content_change=False, |
153 |
versioned=(True, True), |
|
154 |
parent_id=('pid', 'pid'), |
|
155 |
name=('name', 'name'), |
|
156 |
kind=('file', 'file'), |
|
157 |
executable=(False, False), |
|
158 |
versioned_change='unchanged', |
|
159 |
renamed=False, |
|
160 |
modified='unchanged', |
|
161 |
exe_change=False): |
|
|
2225.1.2
by Aaron Bentley
Ensure that changes are detected correctly |
162 |
reporter = InstrumentedReporter() |
|
2255.7.97
by Robert Collins
Teach delta.report_changes about unversioned files, removing all inventory access during status --short. |
163 |
_mod_delta.report_changes([(file_id, paths, content_change, versioned, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
164 |
parent_id, name, kind, executable)], reporter) |
|
2225.1.2
by Aaron Bentley
Ensure that changes are detected correctly |
165 |
output = reporter.calls[0] |
166 |
self.assertEqual(file_id, output[0]) |
|
|
2255.7.97
by Robert Collins
Teach delta.report_changes about unversioned files, removing all inventory access during status --short. |
167 |
self.assertEqual(paths, output[1]) |
|
2225.1.2
by Aaron Bentley
Ensure that changes are detected correctly |
168 |
self.assertEqual(versioned_change, output[2]) |
169 |
self.assertEqual(renamed, output[3]) |
|
170 |
self.assertEqual(modified, output[4]) |
|
171 |
self.assertEqual(exe_change, output[5]) |
|
172 |
self.assertEqual(kind, output[6]) |
|
173 |
||
174 |
def test_report_changes(self): |
|
175 |
"""Test change detection of report_changes""" |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
176 |
# Ensure no changes are detected by default
|
|
2225.1.3
by Aaron Bentley
change method names to assertFoo |
177 |
self.assertChangesEqual(modified='unchanged', renamed=False, |
178 |
versioned_change='unchanged', |
|
179 |
exe_change=False) |
|
180 |
self.assertChangesEqual(modified='kind changed', |
|
181 |
kind=('file', 'directory')) |
|
182 |
self.assertChangesEqual(modified='created', kind=(None, 'directory')) |
|
183 |
self.assertChangesEqual(modified='deleted', kind=('directory', None)) |
|
184 |
self.assertChangesEqual(content_change=True, modified='modified') |
|
185 |
self.assertChangesEqual(renamed=True, name=('old', 'new')) |
|
186 |
self.assertChangesEqual(renamed=True, |
|
187 |
parent_id=('old-parent', 'new-parent')) |
|
188 |
self.assertChangesEqual(versioned_change='added', |
|
189 |
versioned=(False, True)) |
|
190 |
self.assertChangesEqual(versioned_change='removed', |
|
191 |
versioned=(True, False)) |
|
|
2225.1.2
by Aaron Bentley
Ensure that changes are detected correctly |
192 |
# execute bit is only detected as "changed" if the file is and was
|
193 |
# a regular file.
|
|
|
2225.1.3
by Aaron Bentley
change method names to assertFoo |
194 |
self.assertChangesEqual(exe_change=True, executable=(True, False)) |
195 |
self.assertChangesEqual(exe_change=False, executable=(True, False), |
|
196 |
kind=('directory', 'directory')) |
|
197 |
self.assertChangesEqual(exe_change=False, modified='kind changed', |
|
198 |
executable=(False, True), |
|
199 |
kind=('directory', 'file')) |
|
|
1551.11.3
by Aaron Bentley
Use tree transform to emit upcoming change list |
200 |
self.assertChangesEqual(parent_id=('pid', None)) |
|
2225.1.2
by Aaron Bentley
Ensure that changes are detected correctly |
201 |
|
202 |
# Now make sure they all work together
|
|
|
2225.1.3
by Aaron Bentley
change method names to assertFoo |
203 |
self.assertChangesEqual(versioned_change='removed', |
204 |
modified='deleted', versioned=(True, False), |
|
205 |
kind=('directory', None)) |
|
206 |
self.assertChangesEqual(versioned_change='removed', |
|
207 |
modified='created', versioned=(True, False), |
|
208 |
kind=(None, 'file')) |
|
209 |
self.assertChangesEqual(versioned_change='removed', |
|
210 |
modified='modified', renamed=True, |
|
211 |
exe_change=True, versioned=(True, False), |
|
212 |
content_change=True, name=('old', 'new'), |
|
213 |
executable=(False, True)) |
|
|
1551.10.6
by Aaron Bentley
Support kind changes in tree deltas |
214 |
|
|
2255.7.97
by Robert Collins
Teach delta.report_changes about unversioned files, removing all inventory access during status --short. |
215 |
def test_report_unversioned(self): |
216 |
"""Unversioned entries are reported well.""" |
|
217 |
self.assertChangesEqual(file_id=None, paths=(None, 'full/path'), |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
218 |
content_change=True, |
219 |
versioned=(False, False), |
|
220 |
parent_id=(None, None), |
|
221 |
name=(None, 'path'), |
|
222 |
kind=(None, 'file'), |
|
223 |
executable=(None, False), |
|
224 |
versioned_change='unversioned', |
|
225 |
renamed=False, |
|
226 |
modified='created', |
|
227 |
exe_change=False) |
|
|
2255.7.97
by Robert Collins
Teach delta.report_changes about unversioned files, removing all inventory access during status --short. |
228 |
|
|
1551.10.6
by Aaron Bentley
Support kind changes in tree deltas |
229 |
|
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
230 |
class TestChangesFrom(tests.TestCaseWithTransport): |
|
1551.10.6
by Aaron Bentley
Support kind changes in tree deltas |
231 |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
232 |
def show_string(self, delta, *args, **kwargs): |
|
6631.4.1
by Martin
Rename report_delta param from filter to predicate with tests and release notes |
233 |
to_file = StringIO() |
|
5076.4.8
by Arnaud Jeansen
Correct last delta.show() call in test_delta |
234 |
_mod_delta.report_delta(to_file, delta, *args, **kwargs) |
|
1551.10.6
by Aaron Bentley
Support kind changes in tree deltas |
235 |
return to_file.getvalue() |
236 |
||
237 |
def test_kind_change(self): |
|
238 |
"""Doing a status when a file has changed kind should work""" |
|
239 |
tree = self.make_branch_and_tree('.') |
|
240 |
self.build_tree(['filename']) |
|
|
6855.3.1
by Jelmer Vernooij
Several more fixes. |
241 |
tree.add('filename', b'file-id') |
|
1551.10.6
by Aaron Bentley
Support kind changes in tree deltas |
242 |
tree.commit('added filename') |
243 |
os.unlink('filename') |
|
244 |
self.build_tree(['filename/']) |
|
245 |
delta = tree.changes_from(tree.basis_tree()) |
|
|
6855.3.1
by Jelmer Vernooij
Several more fixes. |
246 |
self.assertEqual([('filename', b'file-id', 'file', 'directory')], |
|
1551.10.6
by Aaron Bentley
Support kind changes in tree deltas |
247 |
delta.kind_changed) |
248 |
self.assertEqual([], delta.added) |
|
249 |
self.assertEqual([], delta.removed) |
|
250 |
self.assertEqual([], delta.renamed) |
|
251 |
self.assertEqual([], delta.modified) |
|
252 |
self.assertEqual([], delta.unchanged) |
|
253 |
self.assertTrue(delta.has_changed()) |
|
|
6855.3.1
by Jelmer Vernooij
Several more fixes. |
254 |
self.assertTrue(delta.touches_file_id(b'file-id')) |
|
1551.10.6
by Aaron Bentley
Support kind changes in tree deltas |
255 |
self.assertEqual('kind changed:\n filename (file => directory)\n', |
256 |
self.show_string(delta)) |
|
257 |
other_delta = _mod_delta.TreeDelta() |
|
258 |
self.assertNotEqual(other_delta, delta) |
|
|
6855.3.1
by Jelmer Vernooij
Several more fixes. |
259 |
other_delta.kind_changed = [('filename', b'file-id', 'file', |
|
1551.10.6
by Aaron Bentley
Support kind changes in tree deltas |
260 |
'symlink')] |
261 |
self.assertNotEqual(other_delta, delta) |
|
|
6855.3.1
by Jelmer Vernooij
Several more fixes. |
262 |
other_delta.kind_changed = [('filename', b'file-id', 'file', |
|
1551.10.6
by Aaron Bentley
Support kind changes in tree deltas |
263 |
'directory')] |
264 |
self.assertEqual(other_delta, delta) |
|
|
7067.13.1
by Jelmer Vernooij
Some more fixes for Python 3. |
265 |
if PY3: |
266 |
self.assertEqualDiff("TreeDelta(added=[], removed=[], renamed=[]," |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
267 |
" kind_changed=[('filename', b'file-id', 'file', 'directory')],"
|
268 |
" modified=[], unchanged=[], unversioned=[])", repr(delta)) |
|
|
7067.13.1
by Jelmer Vernooij
Some more fixes for Python 3. |
269 |
else: |
270 |
self.assertEqualDiff("TreeDelta(added=[], removed=[], renamed=[]," |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
271 |
" kind_changed=[(u'filename', 'file-id', 'file', 'directory')],"
|
272 |
" modified=[], unchanged=[], unversioned=[])", repr(delta)) |
|
|
7067.13.1
by Jelmer Vernooij
Some more fixes for Python 3. |
273 |
|
|
1551.10.6
by Aaron Bentley
Support kind changes in tree deltas |
274 |
self.assertEqual('K filename (file => directory) file-id\n', |
275 |
self.show_string(delta, show_ids=True, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
276 |
short_status=True)) |
|
1551.10.6
by Aaron Bentley
Support kind changes in tree deltas |
277 |
|
278 |
tree.rename_one('filename', 'dirname') |
|
279 |
delta = tree.changes_from(tree.basis_tree()) |
|
280 |
self.assertEqual([], delta.kind_changed) |
|
281 |
# This loses the fact that kind changed, remembering it as a
|
|
282 |
# modification
|
|
|
6855.3.1
by Jelmer Vernooij
Several more fixes. |
283 |
self.assertEqual([('filename', 'dirname', b'file-id', 'directory', |
|
1551.10.6
by Aaron Bentley
Support kind changes in tree deltas |
284 |
True, False)], delta.renamed) |
285 |
self.assertTrue(delta.has_changed()) |
|
|
6855.3.1
by Jelmer Vernooij
Several more fixes. |
286 |
self.assertTrue(delta.touches_file_id(b'file-id')) |
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
287 |
|
288 |
||
289 |
class TestDeltaShow(tests.TestCaseWithTransport): |
|
290 |
||
291 |
def _get_delta(self): |
|
292 |
# We build the delta from a real tree to avoid depending on internal
|
|
293 |
# implementation details.
|
|
294 |
wt = self.make_branch_and_tree('branch') |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
295 |
self.build_tree_contents([('branch/f1', b'1\n'), |
296 |
('branch/f2', b'2\n'), |
|
297 |
('branch/f3', b'3\n'), |
|
298 |
('branch/f4', b'4\n'), |
|
299 |
('branch/f5', b'5\n'), |
|
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
300 |
('branch/dir/',), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
301 |
])
|
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
302 |
wt.add(['f1', 'f2', 'f3', 'f4', 'dir'], |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
303 |
[b'f1-id', b'f2-id', b'f3-id', b'f4-id', b'dir-id']) |
304 |
wt.commit('commit one', rev_id=b'1') |
|
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
305 |
|
|
5504.5.1
by Rory Yorke
Show missing files in bzr status (bug 134168). |
306 |
# TODO add rename,removed,etc. here?
|
307 |
wt.add('f5') |
|
308 |
os.unlink('branch/f5') |
|
309 |
||
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
310 |
long_status = """added: |
|
3874.3.6
by Vincent Ladeuil
Make the filter work for paths and file ids. |
311 |
dir/
|
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
312 |
f1
|
313 |
f2
|
|
314 |
f3
|
|
315 |
f4
|
|
|
5504.5.1
by Rory Yorke
Show missing files in bzr status (bug 134168). |
316 |
missing:
|
317 |
f5
|
|
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
318 |
"""
|
|
3874.3.6
by Vincent Ladeuil
Make the filter work for paths and file ids. |
319 |
short_status = """A dir/ |
320 |
A f1
|
|
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
321 |
A f2
|
322 |
A f3
|
|
323 |
A f4
|
|
|
5504.5.1
by Rory Yorke
Show missing files in bzr status (bug 134168). |
324 |
! f5
|
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
325 |
"""
|
326 |
||
327 |
repo = wt.branch.repository |
|
328 |
d = wt.changes_from(repo.revision_tree(_mod_revision.NULL_REVISION)) |
|
329 |
return d, long_status, short_status |
|
330 |
||
|
6631.4.1
by Martin
Rename report_delta param from filter to predicate with tests and release notes |
331 |
def test_short_status(self): |
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
332 |
d, long_status, short_status = self._get_delta() |
|
6631.4.1
by Martin
Rename report_delta param from filter to predicate with tests and release notes |
333 |
out = StringIO() |
|
5076.4.5
by Arnaud Jeansen
Ported test_delta to the report_delta method |
334 |
_mod_delta.report_delta(out, d, short_status=True) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
335 |
self.assertEqual(short_status, out.getvalue()) |
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
336 |
|
|
6631.4.1
by Martin
Rename report_delta param from filter to predicate with tests and release notes |
337 |
def test_long_status(self): |
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
338 |
d, long_status, short_status = self._get_delta() |
|
6631.4.1
by Martin
Rename report_delta param from filter to predicate with tests and release notes |
339 |
out = StringIO() |
|
5076.4.5
by Arnaud Jeansen
Ported test_delta to the report_delta method |
340 |
_mod_delta.report_delta(out, d, short_status=False) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
341 |
self.assertEqual(long_status, out.getvalue()) |
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
342 |
|
|
6631.4.1
by Martin
Rename report_delta param from filter to predicate with tests and release notes |
343 |
def test_predicate_always(self): |
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
344 |
d, long_status, short_status = self._get_delta() |
|
6631.4.1
by Martin
Rename report_delta param from filter to predicate with tests and release notes |
345 |
out = StringIO() |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
346 |
|
|
6631.4.1
by Martin
Rename report_delta param from filter to predicate with tests and release notes |
347 |
def always(path, file_id): |
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
348 |
return True |
|
6631.4.1
by Martin
Rename report_delta param from filter to predicate with tests and release notes |
349 |
_mod_delta.report_delta(out, d, short_status=True, predicate=always) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
350 |
self.assertEqual(short_status, out.getvalue()) |
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
351 |
|
|
6631.4.1
by Martin
Rename report_delta param from filter to predicate with tests and release notes |
352 |
def test_short_status_path_predicate(self): |
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
353 |
d, long_status, short_status = self._get_delta() |
|
6631.4.1
by Martin
Rename report_delta param from filter to predicate with tests and release notes |
354 |
out = StringIO() |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
355 |
|
|
3874.3.6
by Vincent Ladeuil
Make the filter work for paths and file ids. |
356 |
def only_f2(path, file_id): |
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
357 |
return path == 'f2' |
|
6631.4.1
by Martin
Rename report_delta param from filter to predicate with tests and release notes |
358 |
_mod_delta.report_delta(out, d, short_status=True, predicate=only_f2) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
359 |
self.assertEqual("A f2\n", out.getvalue()) |
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
360 |
|
|
6631.4.1
by Martin
Rename report_delta param from filter to predicate with tests and release notes |
361 |
def test_long_status_path_predicate(self): |
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
362 |
d, long_status, short_status = self._get_delta() |
|
6631.4.1
by Martin
Rename report_delta param from filter to predicate with tests and release notes |
363 |
out = StringIO() |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
364 |
|
|
3874.3.6
by Vincent Ladeuil
Make the filter work for paths and file ids. |
365 |
def only_f2(path, file_id): |
|
3874.3.5
by Vincent Ladeuil
Add a 'path_filter' parameter to delta.show(). |
366 |
return path == 'f2' |
|
6631.4.1
by Martin
Rename report_delta param from filter to predicate with tests and release notes |
367 |
_mod_delta.report_delta(out, d, short_status=False, predicate=only_f2) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
368 |
self.assertEqual("added:\n f2\n", out.getvalue()) |
|
3874.3.6
by Vincent Ladeuil
Make the filter work for paths and file ids. |
369 |
|
|
6631.4.1
by Martin
Rename report_delta param from filter to predicate with tests and release notes |
370 |
def test_long_status_id_predicate(self): |
|
3874.3.6
by Vincent Ladeuil
Make the filter work for paths and file ids. |
371 |
d, long_status, short_status = self._get_delta() |
|
6631.4.1
by Martin
Rename report_delta param from filter to predicate with tests and release notes |
372 |
out = StringIO() |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
373 |
|
|
3874.3.6
by Vincent Ladeuil
Make the filter work for paths and file ids. |
374 |
def only_f2_id(path, file_id): |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
375 |
return file_id == b'f2-id' |
|
6631.4.1
by Martin
Rename report_delta param from filter to predicate with tests and release notes |
376 |
_mod_delta.report_delta(out, d, predicate=only_f2_id) |
377 |
self.assertEqual("added:\n f2\n", out.getvalue()) |