Rev 6403: Get rid of LocationSection.length as its not needed in the general case. in file:///home/vila/src/bzr/bugs/832046-globs-store-ordered/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Thu Dec 22 09:59:29 UTC 2011
At file:///home/vila/src/bzr/bugs/832046-globs-store-ordered/
------------------------------------------------------------
revno: 6403
revision-id: v.ladeuil+lp at free.fr-20111222095928-qombaohdx2q6y2vo
parent: pqm at pqm.ubuntu.com-20111221215631-coxvalt3phw8jaza
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 832046-globs-store-ordered
timestamp: Thu 2011-12-22 10:59:28 +0100
message:
Get rid of LocationSection.length as its not needed in the general case.
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2011-12-21 21:31:03 +0000
+++ b/bzrlib/config.py 2011-12-22 09:59:28 +0000
@@ -3314,9 +3314,8 @@
class LocationSection(Section):
- def __init__(self, section, length, extra_path):
+ def __init__(self, section, extra_path):
super(LocationSection, self).__init__(section.id, section.options)
- self.length = length
self.extra_path = extra_path
self.locals = {'relpath': extra_path,
'basename': urlutils.basename(extra_path)}
@@ -3373,7 +3372,7 @@
matching_sections = []
if no_name_section is not None:
matching_sections.append(
- LocationSection(no_name_section, 0, self.location))
+ (0, LocationSection(no_name_section, 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 take the
# first matching section while iterating. Also, all filtered
@@ -3383,7 +3382,7 @@
section = iter_all_sections.next()
if section_id == section.id:
matching_sections.append(
- LocationSection(section, length, extra_path))
+ (length, LocationSection(section, extra_path)))
break
return matching_sections
@@ -3392,10 +3391,10 @@
matching_sections = self._get_matching_sections()
# We want the longest (aka more specific) locations first
sections = sorted(matching_sections,
- key=lambda section: (section.length, section.id),
+ key=lambda (length, section): (length, section.id),
reverse=True)
# Sections mentioning 'ignore_parents' restrict the selection
- for section in sections:
+ for _, section in sections:
# FIXME: We really want to use as_bool below -- vila 2011-04-07
ignore = section.get('ignore_parents', None)
if ignore is not None:
=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py 2011-12-21 20:32:50 +0000
+++ b/bzrlib/tests/test_config.py 2011-12-22 09:59:28 +0000
@@ -3212,8 +3212,7 @@
def get_section(self, options, extra_path):
section = config.Section('foo', options)
- # We don't care about the length so we use '0'
- return config.LocationSection(section, 0, extra_path)
+ return config.LocationSection(section, extra_path)
def test_simple_option(self):
section = self.get_section({'foo': 'bar'}, '')
@@ -3257,8 +3256,6 @@
[section.id for _, section in store.get_sections()])
matcher = config.LocationMatcher(store, '/foo/bar/quux')
sections = [section for s, section in 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'],
@@ -3276,8 +3273,6 @@
[section.id for _, section in store.get_sections()])
matcher = config.LocationMatcher(store, '/foo/bar/baz')
sections = [section for s, section in 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(['baz', 'bar/baz'],
More information about the bazaar-commits
mailing list