Rev 5774: Both the length and the section id should be used to sort. in file:///home/vila/src/bzr/experimental/config/

Vincent Ladeuil v.ladeuil+lp at free.fr
Sat Apr 9 20:17:38 UTC 2011


At file:///home/vila/src/bzr/experimental/config/

------------------------------------------------------------
revno: 5774
revision-id: v.ladeuil+lp at free.fr-20110409201738-mw0cn3nri8769s9i
parent: v.ladeuil+lp at free.fr-20110409201359-90ie1sgwzmdk2kny
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: config-section-matchers
timestamp: Sat 2011-04-09 22:17:38 +0200
message:
  Both the length and the section id should be used to sort.
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py	2011-04-09 20:13:59 +0000
+++ b/bzrlib/config.py	2011-04-09 20:17:38 +0000
@@ -2380,11 +2380,11 @@
         # The following is a bit hackish but ensures compatibility with
         # LocationConfig by reusing the same code
         sections = list(self.store.get_sections())
-        filtered_sections = _filter_for_location_by_parts(
+        filtered_sections = _iter_for_location_by_parts(
             [s.id for s in sections], self.location)
         iter_sections = iter(sections)
         matching_sections = []
-        for length, section_id, extra_path in filtered_sections:
+        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()
@@ -2392,7 +2392,8 @@
                 matching_sections.append(
                     LocationSection(section, length, extra_path))
         # We want the longest (aka more specific) locations first
-        sections = sorted(matching_sections, key=lambda section: section.length,
+        sections = sorted(matching_sections,
+                          key=lambda section: (section.length, section.id),
                           reverse=True)
         # Sections mentioning 'ignore_parents' restrict the selection
         for section in sections:



More information about the bazaar-commits mailing list