/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_delta.py

  • Committer: Vincent Ladeuil
  • Date: 2008-12-10 09:33:06 UTC
  • mto: (3941.1.1 bzr.integration)
  • mto: This revision was merged to the branch mainline in revision 3942.
  • Revision ID: v.ladeuil+lp@free.fr-20081210093306-j4l1wiesc76519fy
Make the filter work for paths and file ids.

* bzrlib/tests/test_delta.py:
(TestDeltaShow): Fix failing tests, the previous commit was wrong.
(TestDeltaShow._get_delta): Baah, fix status outputs.
(TestDeltaShow.test_delta_show_short_status_single_file_id_filter):
Test for file id filter.

* bzrlib/delta.py:
(TreeDelta): Rename path_filter to filter and pass it the file id
too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
258
258
        wt.commit('commit one', rev_id='1')
259
259
 
260
260
        long_status = """added:
 
261
  dir/
261
262
  f1
262
263
  f2
263
264
  f3
264
265
  f4
265
266
"""
266
 
        short_status = """A  f1
 
267
        short_status = """A  dir/
 
268
A  f1
267
269
A  f2
268
270
A  f3
269
271
A  f4
288
290
    def test_delta_show_no_filter(self):
289
291
        d, long_status, short_status = self._get_delta()
290
292
        out = StringIO()
291
 
        def not_a_filter(path):
 
293
        def not_a_filter(path, file_id):
292
294
            return True
293
 
        d.show(out, short_status=True, path_filter=not_a_filter)
 
295
        d.show(out, short_status=True, filter=not_a_filter)
294
296
        self.assertEquals(short_status, out.getvalue())
295
297
 
296
298
    def test_delta_show_short_status_single_file_filter(self):
297
299
        d, long_status, short_status = self._get_delta()
298
300
        out = StringIO()
299
 
        def only_f2(path):
 
301
        def only_f2(path, file_id):
300
302
            return path == 'f2'
301
 
        d.show(out, short_status=True, path_filter=only_f2)
 
303
        d.show(out, short_status=True, filter=only_f2)
302
304
        self.assertEquals("A  f2\n", out.getvalue())
303
305
 
304
306
    def test_delta_show_long_status_single_file_filter(self):
305
307
        d, long_status, short_status = self._get_delta()
306
308
        out = StringIO()
307
 
        def only_f2(path):
 
309
        def only_f2(path, file_id):
308
310
            return path == 'f2'
309
 
        d.show(out, short_status=False, path_filter=only_f2)
 
311
        d.show(out, short_status=False, filter=only_f2)
310
312
        self.assertEquals("added:\n  f2\n", out.getvalue())
 
313
 
 
314
    def test_delta_show_short_status_single_file_id_filter(self):
 
315
        d, long_status, short_status = self._get_delta()
 
316
        out = StringIO()
 
317
        def only_f2_id(path, file_id):
 
318
            return file_id == 'f2-id'
 
319
        d.show(out, short_status=True, filter=only_f2_id)
 
320
        self.assertEquals("A  f2\n", out.getvalue())
 
321