Rev 6404: Bogus implementation passing smoke test in file:///home/vila/src/bzr/bugs/832046-globs-store-ordered/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Thu Dec 22 10:23:42 UTC 2011
At file:///home/vila/src/bzr/bugs/832046-globs-store-ordered/
------------------------------------------------------------
revno: 6404
revision-id: v.ladeuil+lp at free.fr-20111222102342-4nr90uruiej3jhqy
parent: v.ladeuil+lp at free.fr-20111222095928-qombaohdx2q6y2vo
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 832046-globs-store-ordered
timestamp: Thu 2011-12-22 11:23:42 +0100
message:
Bogus implementation passing smoke test
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2011-12-22 09:59:28 +0000
+++ b/bzrlib/config.py 2011-12-22 10:23:42 +0000
@@ -3343,6 +3343,22 @@
return value
+class GlobOrderedMatcher(SectionMatcher):
+ """Select sections for a given location respecting the Store order."""
+
+ def __init__(self, store, location):
+ super(GlobOrderedMatcher, self).__init__(store)
+ if location.startswith('file://'):
+ location = urlutils.local_path_from_url(location)
+ self.location = location
+
+ def get_sections(self):
+ """Get all sections matching ``location``."""
+ store = self.store
+ for _, section in store.get_sections():
+ yield store, LocationSection(section, self.location)
+
+
class LocationMatcher(SectionMatcher):
def __init__(self, store, location):
=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py 2011-12-22 09:59:28 +0000
+++ b/bzrlib/tests/test_config.py 2011-12-22 10:23:42 +0000
@@ -3334,6 +3334,25 @@
self.assertLength(0, sections)
+class TestGlobOrderedMatcher(TestStore):
+
+ def setUp(self):
+ super(TestGlobOrderedMatcher, self).setUp()
+ self.matcher = config.NameMatcher
+ # Any simple store is good enough
+ self.store = config.IniFileStore()
+
+ def assertSections(self, expected, location, content):
+ self.store._load_from_string(content)
+ matcher = config.GlobOrderedMatcher(self.store, location)
+ sections = list(matcher.get_sections())
+ self.assertLength(len(expected), sections)
+ self.assertEqual(expected, sections)
+
+ def test_empty(self):
+ self.assertSections([], self.test_dir, '')
+
+
class TestBaseStackGet(tests.TestCase):
def setUp(self):
More information about the bazaar-commits
mailing list