Rev 5755: Clarify ConfigStack.get() about lazy evaluation of sections. in file:///home/vila/src/bzr/experimental/config/

Vincent Ladeuil v.ladeuil+lp at free.fr
Wed Apr 6 08:24:36 UTC 2011


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

------------------------------------------------------------
revno: 5755
revision-id: v.ladeuil+lp at free.fr-20110406082436-1d0css49ccsb6vc2
parent: v.ladeuil+lp at free.fr-20110406075942-zbw862cv0ioufx7h
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: config-stack
timestamp: Wed 2011-04-06 10:24:36 +0200
message:
  Clarify ConfigStack.get() about lazy evaluation of sections.
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py	2011-04-06 07:59:42 +0000
+++ b/bzrlib/config.py	2011-04-06 08:24:36 +0000
@@ -2196,18 +2196,18 @@
 
     def get(self, name):
         """Return the value from the first definition found in the sections"""
-        value = None
-        for s in self.sections:
-            if callable(s):
-                for s in s():
-                    value = s.get(name)
-                    if value is not None:
-                        break
+        for section_or_callable in self.sections:
+            # Each section can expand to multiple ones when a callable is used
+            if callable(section_or_callable):
+                sections = section_or_callable()
             else:
-                value = s.get(name)
-            if value is not None:
-                break
-        return value
+                sections = [section_or_callable]
+            for section in sections:
+                value = section.get(name)
+                if value is not None:
+                    return value
+        # No definition was found
+        return None
 
     def set(self, name, value):
         self.mutable_section.set(name, value)



More information about the bazaar-commits mailing list