Rev 6091: (vila) Merge 2.4 into trunk (including fix for bug #829237) (Vincent in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Sun Aug 21 17:21:06 UTC 2011
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6091 [merge]
revision-id: pqm at pqm.ubuntu.com-20110821172104-y77ef15d94kom6hl
parent: pqm at pqm.ubuntu.com-20110821113535-5pi9vz6tx6wdf62m
parent: v.ladeuil+lp at free.fr-20110821151457-bppnur2h290un2nt
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Sun 2011-08-21 17:21:04 +0000
message:
(vila) Merge 2.4 into trunk (including fix for bug #829237) (Vincent
Ladeuil)
modified:
bzrlib/config.py config.py-20051011043216-070c74f4e9e338e8
bzrlib/tests/test_config.py testconfig.py-20051011041908-742d0c15d8d8c8eb
doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2011-08-20 22:42:34 +0000
+++ b/bzrlib/config.py 2011-08-21 15:14:57 +0000
@@ -2865,30 +2865,34 @@
# We slightly diverge from LocalConfig here by allowing the no-name
# section as the most generic one and the lower priority.
no_name_section = None
- sections = []
+ all_sections = []
# Filter out the no_name_section so _iter_for_location_by_parts can be
# used (it assumes all sections have a name).
for section in self.store.get_sections():
if section.id is None:
no_name_section = section
else:
- sections.append(section)
+ all_sections.append(section)
# Unfortunately _iter_for_location_by_parts deals with section names so
# we have to resync.
filtered_sections = _iter_for_location_by_parts(
- [s.id for s in sections], self.location)
- iter_sections = iter(sections)
+ [s.id for s in all_sections], self.location)
+ iter_all_sections = iter(all_sections)
matching_sections = []
if no_name_section is not None:
matching_sections.append(
LocationSection(no_name_section, 0, self.location))
for section_id, extra_path, length in filtered_sections:
- # a section id is unique for a given store so it's safe to iterate
- # again
- section = iter_sections.next()
- if section_id == section.id:
- matching_sections.append(
- LocationSection(section, length, extra_path))
+ # a section id is unique for a given store so it's safe to take the
+ # first matching section while iterating. Also, all filtered
+ # sections are part of 'all_sections' and will always be found
+ # there.
+ while True:
+ section = iter_all_sections.next()
+ if section_id == section.id:
+ matching_sections.append(
+ LocationSection(section, length, extra_path))
+ break
return matching_sections
def get_sections(self):
=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py 2011-08-20 05:22:49 +0000
+++ b/bzrlib/tests/test_config.py 2011-08-21 15:14:57 +0000
@@ -2857,6 +2857,32 @@
def get_store(self, file_name):
return config.IniFileStore(self.get_readonly_transport(), file_name)
+ def test_unrelated_section_excluded(self):
+ store = self.get_store('foo.conf')
+ store._load_from_string('''
+[/foo]
+section=/foo
+[/foo/baz]
+section=/foo/baz
+[/foo/bar]
+section=/foo/bar
+[/foo/bar/baz]
+section=/foo/bar/baz
+[/quux/quux]
+section=/quux/quux
+''')
+ self.assertEquals(['/foo', '/foo/baz', '/foo/bar', '/foo/bar/baz',
+ '/quux/quux'],
+ [section.id for section in store.get_sections()])
+ matcher = config.LocationMatcher(store, '/foo/bar/quux')
+ sections = list(matcher.get_sections())
+ self.assertEquals([3, 2],
+ [section.length for section in sections])
+ self.assertEquals(['/foo/bar', '/foo'],
+ [section.id for section in sections])
+ self.assertEquals(['quux', 'bar/quux'],
+ [section.extra_path for section in sections])
+
def test_more_specific_sections_first(self):
store = self.get_store('foo.conf')
store._load_from_string('''
=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt 2011-08-21 09:24:01 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt 2011-08-21 15:14:57 +0000
@@ -32,6 +32,9 @@
.. Fixes for situations where bzr would previously crash or give incorrect
or undesirable results.
+* ``config.LocationMatcher`` properly excludes unrelated sections.
+ (Vincent Ladeuil, #829237)
+
Documentation
*************
More information about the bazaar-commits
mailing list