/brz/remove-bazaar

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