Rev 6407: Always return the no-name section if present. in file:///home/vila/src/bzr/bugs/832046-globs-store-ordered/

Vincent Ladeuil v.ladeuil+lp at free.fr
Thu Dec 22 16:53:40 UTC 2011


At file:///home/vila/src/bzr/bugs/832046-globs-store-ordered/

------------------------------------------------------------
revno: 6407
revision-id: v.ladeuil+lp at free.fr-20111222165339-i1da5m6pa96nmjjj
parent: v.ladeuil+lp at free.fr-20111222163936-n6eqfzrz8zj0qpxs
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 832046-globs-store-ordered
timestamp: Thu 2011-12-22 17:53:39 +0100
message:
  Always return the no-name section if present.
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py	2011-12-22 16:29:55 +0000
+++ b/bzrlib/config.py	2011-12-22 16:53:39 +0000
@@ -3359,11 +3359,22 @@
         self.location = location
 
     def get_sections(self):
-        """Get all sections matching ``location``."""
+        """Get all sections matching ``location`` in the store.
+
+        The most generic sections are described first in the store, then more
+        specific ones can be provided for reduced scopes.
+
+        The returned section are therefore returned in the reversed order so
+        the most specific ones can be found first.
+        """
         store = self.store
         sections = []
         # Later sections are more specific, they should be returned first
         for _, section in reversed(list(store.get_sections())):
+            if section.id is None:
+                # The no-name section is always included if present
+                yield store, LocationSection(section, self.location)
+                continue
             section_path = section.id
             if section_path.startswith('file://'):
                 section_path = urlutils.local_path_from_url(section)

=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py	2011-12-22 16:29:55 +0000
+++ b/bzrlib/tests/test_config.py	2011-12-22 16:53:39 +0000
@@ -3322,6 +3322,15 @@
     def test_empty(self):
         self.assertSectionIDs([], self.test_dir, '')
 
+    def test_no_name_included_when_present(self):
+        # Note that other tests will cover the case where the no-name section
+        # is empty and as such, not included.
+        self.assertSectionIDs(['/foo/bar', '/foo', None], '/foo/bar/baz', '''\
+option = defined so the no-name section exists
+[/foo]
+[/foo/bar]
+''')
+
     def test_order_reversed(self):
         self.assertSectionIDs(['/foo/bar', '/foo'], '/foo/bar/baz', '''\
 [/foo]

=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt	2011-12-22 16:39:36 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt	2011-12-22 16:53:39 +0000
@@ -130,7 +130,8 @@
 
 * Configuration stacks can now use ``GlobOrderedMatcher`` to select the
   sections matching a location while respecting the order chosen by the user
-  in the configuration file. (Vincent Ladeuil, #832046).
+  in the configuration file: from generic sections to specific
+  sections. (Vincent Ladeuil, #832046).
 
 * Configuration options can be SI units by using ``int_SI_from_unicode`` as
   their ``convert_from_unicode`` helper. (Vincent Ladeuil)



More information about the bazaar-commits mailing list