Rev 6072: Migrate debug_flags to stack-based config. in file:///home/vila/src/bzr/experimental/migrate-config-options/

Vincent Ladeuil v.ladeuil+lp at free.fr
Fri Aug 12 16:25:56 UTC 2011


At file:///home/vila/src/bzr/experimental/migrate-config-options/

------------------------------------------------------------
revno: 6072
revision-id: v.ladeuil+lp at free.fr-20110812162556-t57zqffa55hn2jpx
parent: v.ladeuil+lp at free.fr-20110812144742-g12l2cgakyulg935
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: migrate-config-options
timestamp: Fri 2011-08-12 18:25:56 +0200
message:
  Migrate debug_flags to stack-based config.
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py	2011-08-12 14:47:42 +0000
+++ b/bzrlib/config.py	2011-08-12 16:25:56 +0000
@@ -2398,6 +2398,9 @@
 should not be lost if the machine crashes.  See also repository.fdatasync.
 '''))
 option_registry.register(
+    Option('debug_flags', default=[], from_unicode=list_from_store,
+           help='Debug flags to activate.'))
+option_registry.register(
     Option('default_format', default='2a',
            help='Format used when creating branches.'))
 option_registry.register(

=== modified file 'bzrlib/debug.py'
--- a/bzrlib/debug.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/debug.py	2011-08-12 16:25:56 +0000
@@ -31,15 +31,8 @@
 def set_debug_flags_from_config():
     """Turn on debug flags based on the global configuration"""
 
-    from bzrlib.config import GlobalConfig
+    from bzrlib import config
 
-    c = GlobalConfig()
-    value = c.get_user_option("debug_flags")
-    if value is not None:
-        # configobject gives us either a string if there's just one or a list
-        # if there's multiple
-        if isinstance(value, basestring):
-            value = [value]
-        for w in value:
-            w = w.strip()
-            debug_flags.add(w)
+    c = config.GlobalStack()
+    for f in c.get('debug_flags'):
+        debug_flags.add(f)

=== modified file 'bzrlib/help_topics/en/configuration.txt'
--- a/bzrlib/help_topics/en/configuration.txt	2011-08-02 01:10:27 +0000
+++ b/bzrlib/help_topics/en/configuration.txt	2011-08-12 16:25:56 +0000
@@ -353,7 +353,7 @@
 can be used as with the -D command-line option (see `help global-options`).
 For example::
 
-    debug_flags = hpss
+    debug_flags = hpss,
 
 email
 ~~~~~

=== modified file 'bzrlib/tests/test_debug.py'
--- a/bzrlib/tests/test_debug.py	2010-08-29 14:32:45 +0000
+++ b/bzrlib/tests/test_debug.py	2011-08-12 16:25:56 +0000
@@ -29,11 +29,13 @@
     def test_set_debug_flags_from_config(self):
         # test both combinations because configobject automatically splits up
         # comma-separated lists
-        self.try_debug_flags(['hpss', 'error'], 'debug_flags = hpss, error\n')
-        self.try_debug_flags(['hpss'], 'debug_flags = hpss\n')
+        self.assertDebugFlags(['hpss', 'error'], 'debug_flags = hpss, error\n')
+        self.assertDebugFlags(['hpss'], 'debug_flags = hpss\n')
 
-    def try_debug_flags(self, expected_flags, conf_bytes):
-        conf = config.GlobalConfig.from_string(conf_bytes, save=True)
+    def assertDebugFlags(self, expected_flags, conf_bytes):
+        conf = config.GlobalStack()
+        conf.store._load_from_string(conf_bytes)
+        conf.store.save()
         self.overrideAttr(debug, 'debug_flags', set())
         debug.set_debug_flags_from_config()
         self.assertEqual(set(expected_flags), debug.debug_flags)



More information about the bazaar-commits mailing list