Merge lp:~gz/brz/unfiltered into lp:brz

Proposed by Martin Packman
Status: Merged
Approved by: Martin Packman
Approved revision: 6635
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~gz/brz/unfiltered
Merge into: lp:brz
Prerequisite: lp:~gz/brz/i_unzipping
Diff against target: 162 lines (+30/-27)
5 files modified
breezy/delta.py (+5/-4)
breezy/log.py (+1/-1)
breezy/tests/http_server.py (+1/-2)
breezy/tests/test_delta.py (+20/-20)
doc/en/release-notes/brz-3.0.txt (+3/-0)
To merge this branch: bzr merge lp:~gz/brz/unfiltered
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+324570@code.launchpad.net

Commit message

Remove some uses of filter that confused things

Description of the change

This started as just running the 2to3 filter fixer, but ended up with a parameter rename (not used outside of tests) and some slight changes to `filter(None, ...)` constructs.

So, now Python 3 compatible but not quite how the fixer envisioned.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/delta.py'
--- breezy/delta.py 2017-05-22 00:56:52 +0000
+++ breezy/delta.py 2017-05-24 20:51:57 +0000
@@ -349,8 +349,9 @@
349 reporter.report(file_id, path, versioned_change, renamed, modified,349 reporter.report(file_id, path, versioned_change, renamed, modified,
350 exe_change, kind)350 exe_change, kind)
351351
352def report_delta(to_file, delta, short_status=False, show_ids=False, 352
353 show_unchanged=False, indent='', filter=None, classify=True):353def report_delta(to_file, delta, short_status=False, show_ids=False,
354 show_unchanged=False, indent='', predicate=None, classify=True):
354 """Output this delta in status-like form to to_file.355 """Output this delta in status-like form to to_file.
355356
356 :param to_file: A file-like object where the output is displayed.357 :param to_file: A file-like object where the output is displayed.
@@ -366,7 +367,7 @@
366 :param indent: Added at the beginning of all output lines (for merged367 :param indent: Added at the beginning of all output lines (for merged
367 revisions).368 revisions).
368369
369 :param filter: A callable receiving a path and a file id and370 :param predicate: A callable receiving a path and a file id and
370 returning True if the path should be displayed.371 returning True if the path should be displayed.
371372
372 :param classify: Add special symbols to indicate file kind.373 :param classify: Add special symbols to indicate file kind.
@@ -417,7 +418,7 @@
417418
418 for item in files:419 for item in files:
419 path, file_id, kind = item[:3]420 path, file_id, kind = item[:3]
420 if (filter is not None and not filter(path, file_id)):421 if (predicate is not None and not predicate(path, file_id)):
421 continue422 continue
422 if not header_shown and not short_status:423 if not header_shown and not short_status:
423 to_file.write(indent + long_status_name + ':\n')424 to_file.write(indent + long_status_name + ':\n')
424425
=== modified file 'breezy/log.py'
--- breezy/log.py 2017-05-24 20:51:57 +0000
+++ breezy/log.py 2017-05-24 20:51:57 +0000
@@ -889,7 +889,7 @@
889 return True889 return True
890890
891def _match_any_filter(strings, res):891def _match_any_filter(strings, res):
892 return any([filter(None, map(re.search, strings)) for re in res])892 return any(re.search(s) for re in res for s in strings)
893893
894def _make_delta_filter(branch, generate_delta, search, log_rev_iterator,894def _make_delta_filter(branch, generate_delta, search, log_rev_iterator,
895 fileids=None, direction='reverse'):895 fileids=None, direction='reverse'):
896896
=== modified file 'breezy/tests/http_server.py'
--- breezy/tests/http_server.py 2017-05-22 00:56:52 +0000
+++ breezy/tests/http_server.py 2017-05-24 20:51:57 +0000
@@ -342,9 +342,8 @@
342 path = posixpath.normpath(urlutils.unquote(path))342 path = posixpath.normpath(urlutils.unquote(path))
343 path = path.decode('utf-8')343 path = path.decode('utf-8')
344 words = path.split('/')344 words = path.split('/')
345 words = filter(None, words)
346 path = self._cwd345 path = self._cwd
347 for num, word in enumerate(words):346 for num, word in enumerate(w for w in words if w):
348 if num == 0:347 if num == 0:
349 drive, word = os.path.splitdrive(word)348 drive, word = os.path.splitdrive(word)
350 head, word = os.path.split(word)349 head, word = os.path.split(word)
351350
=== modified file 'breezy/tests/test_delta.py'
--- breezy/tests/test_delta.py 2017-05-22 00:56:52 +0000
+++ breezy/tests/test_delta.py 2017-05-24 20:51:57 +0000
@@ -22,7 +22,7 @@
22 tests,22 tests,
23 )23 )
24from ..sixish import (24from ..sixish import (
25 BytesIO,25 StringIO,
26 )26 )
2727
2828
@@ -227,7 +227,7 @@
227class TestChangesFrom(tests.TestCaseWithTransport):227class TestChangesFrom(tests.TestCaseWithTransport):
228228
229 def show_string(self, delta, *args, **kwargs):229 def show_string(self, delta, *args, **kwargs):
230 to_file = BytesIO()230 to_file = StringIO()
231 _mod_delta.report_delta(to_file, delta, *args, **kwargs)231 _mod_delta.report_delta(to_file, delta, *args, **kwargs)
232 return to_file.getvalue()232 return to_file.getvalue()
233233
@@ -319,47 +319,47 @@
319 d = wt.changes_from(repo.revision_tree(_mod_revision.NULL_REVISION))319 d = wt.changes_from(repo.revision_tree(_mod_revision.NULL_REVISION))
320 return d, long_status, short_status320 return d, long_status, short_status
321321
322 def test_delta_show_short_status_no_filter(self):322 def test_short_status(self):
323 d, long_status, short_status = self._get_delta()323 d, long_status, short_status = self._get_delta()
324 out = BytesIO()324 out = StringIO()
325 _mod_delta.report_delta(out, d, short_status=True)325 _mod_delta.report_delta(out, d, short_status=True)
326 self.assertEqual(short_status, out.getvalue())326 self.assertEqual(short_status, out.getvalue())
327327
328 def test_delta_show_long_status_no_filter(self):328 def test_long_status(self):
329 d, long_status, short_status = self._get_delta()329 d, long_status, short_status = self._get_delta()
330 out = BytesIO()330 out = StringIO()
331 _mod_delta.report_delta(out, d, short_status=False)331 _mod_delta.report_delta(out, d, short_status=False)
332 self.assertEqual(long_status, out.getvalue())332 self.assertEqual(long_status, out.getvalue())
333333
334 def test_delta_show_no_filter(self):334 def test_predicate_always(self):
335 d, long_status, short_status = self._get_delta()335 d, long_status, short_status = self._get_delta()
336 out = BytesIO()336 out = StringIO()
337 def not_a_filter(path, file_id):337 def always(path, file_id):
338 return True338 return True
339 _mod_delta.report_delta(out, d, short_status=True, filter=not_a_filter)339 _mod_delta.report_delta(out, d, short_status=True, predicate=always)
340 self.assertEqual(short_status, out.getvalue())340 self.assertEqual(short_status, out.getvalue())
341341
342 def test_delta_show_short_status_single_file_filter(self):342 def test_short_status_path_predicate(self):
343 d, long_status, short_status = self._get_delta()343 d, long_status, short_status = self._get_delta()
344 out = BytesIO()344 out = StringIO()
345 def only_f2(path, file_id):345 def only_f2(path, file_id):
346 return path == 'f2'346 return path == 'f2'
347 _mod_delta.report_delta(out, d, short_status=True, filter=only_f2)347 _mod_delta.report_delta(out, d, short_status=True, predicate=only_f2)
348 self.assertEqual("A f2\n", out.getvalue())348 self.assertEqual("A f2\n", out.getvalue())
349349
350 def test_delta_show_long_status_single_file_filter(self):350 def test_long_status_path_predicate(self):
351 d, long_status, short_status = self._get_delta()351 d, long_status, short_status = self._get_delta()
352 out = BytesIO()352 out = StringIO()
353 def only_f2(path, file_id):353 def only_f2(path, file_id):
354 return path == 'f2'354 return path == 'f2'
355 _mod_delta.report_delta(out, d, short_status=False, filter=only_f2)355 _mod_delta.report_delta(out, d, short_status=False, predicate=only_f2)
356 self.assertEqual("added:\n f2\n", out.getvalue())356 self.assertEqual("added:\n f2\n", out.getvalue())
357357
358 def test_delta_show_short_status_single_file_id_filter(self):358 def test_long_status_id_predicate(self):
359 d, long_status, short_status = self._get_delta()359 d, long_status, short_status = self._get_delta()
360 out = BytesIO()360 out = StringIO()
361 def only_f2_id(path, file_id):361 def only_f2_id(path, file_id):
362 return file_id == 'f2-id'362 return file_id == 'f2-id'
363 _mod_delta.report_delta(out, d, short_status=True, filter=only_f2_id)363 _mod_delta.report_delta(out, d, predicate=only_f2_id)
364 self.assertEqual("A f2\n", out.getvalue())364 self.assertEqual("added:\n f2\n", out.getvalue())
365365
366366
=== modified file 'doc/en/release-notes/brz-3.0.txt'
--- doc/en/release-notes/brz-3.0.txt 2017-05-24 00:57:47 +0000
+++ doc/en/release-notes/brz-3.0.txt 2017-05-24 20:51:57 +0000
@@ -55,6 +55,9 @@
55 * Signature of ``load_tests`` used by ``TestLoader`` changed to be55 * Signature of ``load_tests`` used by ``TestLoader`` changed to be
56 compatible with standard libarary unittest. (Martin Packman)56 compatible with standard libarary unittest. (Martin Packman)
5757
58 * Renamed ``breezy.delta.report_delta`` parameter ``filter=`` to
59 ``predicate=``. (Martin Packman)
60
58Internals61Internals
59*********62*********
6063

Subscribers

People subscribed via source and target branches