Rev 3565: Fix RuleSearcher to return () not [] (Ian Clatworthy) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Jul 18 11:00:31 BST 2008
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3565
revision-id:pqm at pqm.ubuntu.com-20080718100017-segv2csk7ux2xs9p
parent: pqm at pqm.ubuntu.com-20080718030707-qimx9fv1d4xhlk1m
parent: ian.clatworthy at canonical.com-20080718093213-e86mzwqm71r6bn2x
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2008-07-18 11:00:17 +0100
message:
Fix RuleSearcher to return () not [] (Ian Clatworthy)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/rules.py properties.py-20080506032617-9k06uqalkf09ck0z-1
bzrlib/tests/test_rules.py test_properties.py-20080506033501-3p9kmuob25dho8xl-1
------------------------------------------------------------
revno: 3564.1.1
revision-id:ian.clatworthy at canonical.com-20080718093213-e86mzwqm71r6bn2x
parent: pqm at pqm.ubuntu.com-20080718030707-qimx9fv1d4xhlk1m
parent: ian.clatworthy at canonical.com-20080718084057-0gxsxkfb5eco0wh2
committer: Ian Clatworthy <ian.clatworthy at canonical.com>
branch nick: ianc-integration
timestamp: Fri 2008-07-18 19:32:13 +1000
message:
Fix RuleSearcher to return () not [] (Ian Clatworthy)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/rules.py properties.py-20080506032617-9k06uqalkf09ck0z-1
bzrlib/tests/test_rules.py test_properties.py-20080506033501-3p9kmuob25dho8xl-1
------------------------------------------------------------
revno: 3564.2.1
revision-id:ian.clatworthy at canonical.com-20080718084057-0gxsxkfb5eco0wh2
parent: pqm at pqm.ubuntu.com-20080718030707-qimx9fv1d4xhlk1m
committer: Ian Clatworthy <ian.clatworthy at canonical.com>
branch nick: bzr.rules-fix
timestamp: Fri 2008-07-18 18:40:57 +1000
message:
RuleSearchers need to return () instead of []
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/rules.py properties.py-20080506032617-9k06uqalkf09ck0z-1
bzrlib/tests/test_rules.py test_properties.py-20080506033501-3p9kmuob25dho8xl-1
=== modified file 'NEWS'
--- a/NEWS 2008-07-17 16:26:45 +0000
+++ b/NEWS 2008-07-18 08:40:57 +0000
@@ -39,6 +39,8 @@
INTERNALS:
+ * RuleSearchers return () instead of [] now when there are no matches.
+ (Ian Clatworthy)
bzr 1.6beta3 2008-07-17
=== modified file 'bzrlib/rules.py'
--- a/bzrlib/rules.py 2008-06-30 00:47:30 +0000
+++ b/bzrlib/rules.py 2008-07-18 08:40:57 +0000
@@ -43,7 +43,7 @@
"""Return the preferences for a path as name,value tuples.
:param path: tree relative path
- :return: [] if no rule matched, otherwise a sequence of name,value
+ :return: () if no rule matched, otherwise a sequence of name,value
tuples.
"""
raise NotImplementedError(self.get_items)
@@ -53,7 +53,7 @@
:param path: tree relative path
:param names: the list of preferences to lookup
- :return: [] if no rule matched, otherwise a sequence of name,value
+ :return: () if no rule matched, otherwise a sequence of name,value
tuples. The sequence is the same length as names,
tuple order matches the order in names, and
undefined preferences are given the value None.
@@ -87,10 +87,10 @@
def get_items(self, path):
"""See _RulesSearcher.get_items."""
if self._globster is None:
- return []
+ return ()
pat = self._globster.match(path)
if pat is None:
- return []
+ return ()
else:
all = self._cfg[FILE_PREFS_PREFIX + pat]
return tuple(all.items())
@@ -98,10 +98,10 @@
def get_selected_items(self, path, names):
"""See _RulesSearcher.get_selected_items."""
if self._globster is None:
- return []
+ return ()
pat = self._globster.match(path)
if pat is None:
- return []
+ return ()
else:
all = self._cfg[FILE_PREFS_PREFIX + pat]
return tuple((k, all.get(k)) for k in names)
@@ -122,7 +122,7 @@
result = searcher.get_items(path)
if result:
return result
- return []
+ return ()
def get_selected_items(self, path, names):
"""See _RulesSearcher.get_selected_items."""
@@ -130,7 +130,7 @@
result = searcher.get_selected_items(path, names)
if result:
return result
- return []
+ return ()
def rules_filename():
=== modified file 'bzrlib/tests/test_rules.py'
--- a/bzrlib/tests/test_rules.py 2008-06-30 00:47:30 +0000
+++ b/bzrlib/tests/test_rules.py 2008-07-18 08:40:57 +0000
@@ -44,17 +44,17 @@
def test_get_items_file_missing(self):
rs = self.make_searcher(None)
- self.assertEquals([], rs.get_items('a.txt'))
- self.assertEquals([], rs.get_selected_items('a.txt', ['foo']))
+ self.assertEquals((), rs.get_items('a.txt'))
+ self.assertEquals((), rs.get_selected_items('a.txt', ['foo']))
def test_get_items_file_empty(self):
rs = self.make_searcher("")
- self.assertEquals([], rs.get_items('a.txt'))
- self.assertEquals([], rs.get_selected_items('a.txt', ['foo']))
+ self.assertEquals((), rs.get_items('a.txt'))
+ self.assertEquals((), rs.get_selected_items('a.txt', ['foo']))
def test_get_items_from_extension_match(self):
rs = self.make_searcher("[name *.txt]\nfoo=bar\na=True\n")
- self.assertEquals([], rs.get_items('a.py'))
+ self.assertEquals((), rs.get_items('a.py'))
self.assertEquals((('foo', 'bar'), ('a', 'True')),
rs.get_items('a.txt'))
self.assertEquals((('foo', 'bar'), ('a', 'True')),
@@ -66,7 +66,7 @@
rs = self.make_searcher("[name ./a.txt]\nfoo=baz\n")
self.assertEquals((('foo', 'baz'),),
rs.get_items('a.txt'))
- self.assertEquals([], rs.get_items('dir/a.txt'))
+ self.assertEquals((), rs.get_items('dir/a.txt'))
def test_get_items_match_first(self):
rs = self.make_searcher(
More information about the bazaar-commits
mailing list