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