Rev 3884: Make the filter work for paths and file ids. in file:///net/bigmamac/Volumes/home/vila/src/bzr/cases/3232-spurious-conflict/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Wed Dec 10 09:33:16 GMT 2008
At file:///net/bigmamac/Volumes/home/vila/src/bzr/cases/3232-spurious-conflict/
------------------------------------------------------------
revno: 3884
revision-id: v.ladeuil+lp at free.fr-20081210093306-j4l1wiesc76519fy
parent: v.ladeuil+lp at free.fr-20081210084403-89803az7m7rysrsy
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: delta-show-with-path-filter
timestamp: Wed 2008-12-10 10:33:06 +0100
message:
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.
-------------- next part --------------
=== modified file 'bzrlib/delta.py'
--- a/bzrlib/delta.py 2008-12-10 08:44:03 +0000
+++ b/bzrlib/delta.py 2008-12-10 09:33:06 +0000
@@ -110,7 +110,7 @@
def show(self, to_file, show_ids=False, show_unchanged=False,
short_status=False, indent='',
- path_filter=None):
+ filter=None):
"""Output this delta in status-like form to to_file.
:param to_file: A file-like object where the output is displayed.
@@ -124,8 +124,8 @@
:param indent: Added at the beginning of all output lines (for merged
revisions).
- :param path_filter: A callable recieving a path and returning True if
- the path should be displayed.
+ :param filter: A callable receiving a path and a file id and
+ returning True if the path should be displayed.
"""
def decorate_path(path, kind, meta_modified=None):
@@ -171,7 +171,7 @@
for item in files:
path, file_id, kind = item[:3]
- if (path_filter is not None and not path_filter(path)):
+ if (filter is not None and not filter(path, file_id)):
continue
if not header_shown and not short_status:
to_file.write(indent + long_status_name + ':\n')
=== modified file 'bzrlib/tests/test_delta.py'
--- a/bzrlib/tests/test_delta.py 2008-12-10 08:44:03 +0000
+++ b/bzrlib/tests/test_delta.py 2008-12-10 09:33:06 +0000
@@ -258,12 +258,14 @@
wt.commit('commit one', rev_id='1')
long_status = """added:
+ dir/
f1
f2
f3
f4
"""
- short_status = """A f1
+ short_status = """A dir/
+A f1
A f2
A f3
A f4
@@ -288,23 +290,32 @@
def test_delta_show_no_filter(self):
d, long_status, short_status = self._get_delta()
out = StringIO()
- def not_a_filter(path):
+ def not_a_filter(path, file_id):
return True
- d.show(out, short_status=True, path_filter=not_a_filter)
+ d.show(out, short_status=True, filter=not_a_filter)
self.assertEquals(short_status, out.getvalue())
def test_delta_show_short_status_single_file_filter(self):
d, long_status, short_status = self._get_delta()
out = StringIO()
- def only_f2(path):
+ def only_f2(path, file_id):
return path == 'f2'
- d.show(out, short_status=True, path_filter=only_f2)
+ d.show(out, short_status=True, filter=only_f2)
self.assertEquals("A f2\n", out.getvalue())
def test_delta_show_long_status_single_file_filter(self):
d, long_status, short_status = self._get_delta()
out = StringIO()
- def only_f2(path):
+ def only_f2(path, file_id):
return path == 'f2'
- d.show(out, short_status=False, path_filter=only_f2)
+ d.show(out, short_status=False, filter=only_f2)
self.assertEquals("added:\n f2\n", out.getvalue())
+
+ def test_delta_show_short_status_single_file_id_filter(self):
+ d, long_status, short_status = self._get_delta()
+ out = StringIO()
+ def only_f2_id(path, file_id):
+ return file_id == 'f2-id'
+ d.show(out, short_status=True, filter=only_f2_id)
+ self.assertEquals("A f2\n", out.getvalue())
+
More information about the bazaar-commits
mailing list