Rev 6058: (vila) Migrate some config options to the stack-based API. (Vincent Ladeuil) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Aug 9 09:04:09 UTC 2011


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 6058 [merge]
revision-id: pqm at pqm.ubuntu.com-20110809090406-sjx052uyb3t9c6o0
parent: pqm at pqm.ubuntu.com-20110808173945-vx1z3qi3c3qj50zv
parent: v.ladeuil+lp at free.fr-20110808170351-hmrf9layb5e1ve6n
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2011-08-09 09:04:06 +0000
message:
  (vila) Migrate some config options to the stack-based API. (Vincent Ladeuil)
modified:
  bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
  bzrlib/config.py               config.py-20051011043216-070c74f4e9e338e8
  bzrlib/i18n.py                 i18n.py-20110429130428-eblvodng604h3dzi-1
  bzrlib/ui/__init__.py          ui.py-20050824083933-8cf663c763ba53a9
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py	2011-07-25 12:32:26 +0000
+++ b/bzrlib/bzrdir.py	2011-08-08 16:28:55 +0000
@@ -2287,11 +2287,8 @@
     help='Same as 2a.')
 
 # The current format that is made on 'bzr init'.
-format_name = config.GlobalConfig().get_user_option('default_format')
-if format_name is None:
-    controldir.format_registry.set_default('2a')
-else:
-    controldir.format_registry.set_default(format_name)
+format_name = config.GlobalStack().get('default_format')
+controldir.format_registry.set_default(format_name)
 
 # XXX 2010-08-20 JRV: There is still a lot of code relying on
 # bzrlib.bzrdir.format_registry existing. When BzrDir.create/BzrDir.open/etc

=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py	2011-08-02 01:10:27 +0000
+++ b/bzrlib/config.py	2011-08-08 17:03:51 +0000
@@ -2287,14 +2287,23 @@
 option_registry = registry.Registry()
 
 
+# Registered options in lexicographical order
+
+option_registry.register(
+    'dirstate.fdatasync', Option('dirstate.fdatasync', default=True),
+    help='Flush dirstate changes onto physical disk?')
+option_registry.register(
+    'default_format', Option('default_format', default='2a'),
+    help='Format used when creating branches.')
 option_registry.register(
     'editor', Option('editor'),
     help='The command called to launch an editor to enter a message.')
-
-option_registry.register(
-    'dirstate.fdatasync', Option('dirstate.fdatasync', default=True),
-    help='Flush dirstate changes onto physical disk?')
-
+option_registry.register(
+    'language', Option('language'),
+    help='Language to translate messages into.')
+option_registry.register(
+    'output_encoding', Option('output_encoding'),
+    help='Unicode encoding for output (terminal encoding if not specified).')
 option_registry.register(
     'repository.fdatasync',
     Option('repository.fdatasync', default=True),

=== modified file 'bzrlib/i18n.py'
--- a/bzrlib/i18n.py	2011-07-14 22:14:52 +0000
+++ b/bzrlib/i18n.py	2011-08-08 17:03:51 +0000
@@ -134,7 +134,7 @@
 def _get_current_locale():
     if not os.environ.get('LANGUAGE'):
         from bzrlib import config
-        lang = config.GlobalConfig().get_user_option('language')
+        lang = config.GlobalStack().get('language')
         if lang:
             os.environ['LANGUAGE'] = lang
             return lang

=== modified file 'bzrlib/ui/__init__.py'
--- a/bzrlib/ui/__init__.py	2011-08-02 11:18:43 +0000
+++ b/bzrlib/ui/__init__.py	2011-08-08 15:57:57 +0000
@@ -47,6 +47,7 @@
 from bzrlib.lazy_import import lazy_import
 lazy_import(globals(), """
 from bzrlib import (
+    config,
     osutils,
     progress,
     trace,
@@ -247,9 +248,7 @@
         """
         # XXX: is the caller supposed to close the resulting object?
         if encoding is None:
-            from bzrlib import config
-            encoding = config.GlobalConfig().get_user_option(
-                'output_encoding')
+            encoding = config.GlobalStack().get('output_encoding')
         if encoding is None:
             encoding = osutils.get_terminal_encoding(trace=True)
         if encoding_type is None:




More information about the bazaar-commits mailing list