Rev 6075: (vila) More options migrated to the stack-based config. (Vincent Ladeuil) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Aug 17 05:35:04 UTC 2011


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

------------------------------------------------------------
revno: 6075 [merge]
revision-id: pqm at pqm.ubuntu.com-20110817053442-pz1w7iw2w0w78ewy
parent: pqm at pqm.ubuntu.com-20110817020800-z7oepdt2nxwjq5ue
parent: v.ladeuil+lp at free.fr-20110816151239-dtxlk1q0qjhohbt2
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2011-08-17 05:34:42 +0000
message:
  (vila) More options migrated to the stack-based config. (Vincent Ladeuil)
modified:
  bzrlib/config.py               config.py-20051011043216-070c74f4e9e338e8
  bzrlib/debug.py                debug.py-20061102062349-vdhrw9qdpck8cl35-1
  bzrlib/help_topics/en/configuration.txt configuration.txt-20060314161707-868350809502af01
  bzrlib/lockdir.py              lockdir.py-20060220222025-98258adf27fbdda3
  bzrlib/osutils.py              osutils.py-20050309040759-eeaff12fbf77ac86
  bzrlib/tests/per_workingtree/test_workingtree.py test_workingtree.py-20060203003124-817757d3e31444fb
  bzrlib/tests/test_debug.py     test_debug.py-20090303053802-01e8mlv24odmpgix-1
  bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
  doc/en/user-guide/gpg_signatures.txt gpg_signatures.txt-20110613144839-bhiqfi9k0khol2vm-1
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py	2011-08-16 09:33:16 +0000
+++ b/bzrlib/config.py	2011-08-16 15:12:39 +0000
@@ -2386,7 +2386,20 @@
 # Registered options in lexicographical order
 
 option_registry.register(
-    Option('dirstate.fdatasync', default=True, from_unicode=bool_from_store,
+    Option('bzr.workingtree.worth_saving_limit', default=10,
+           from_unicode=int_from_store,  invalid='warning',
+           help='''\
+How many changes before saving the dirstate.
+
+-1 means that we will never rewrite the dirstate file for only
+stat-cache changes. Regardless of this setting, we will always rewrite
+the dirstate file if a file is added/removed/renamed/etc. This flag only
+affects the behavior of updating the dirstate file after we notice that
+a file has been touched.
+'''))
+option_registry.register(
+    Option('dirstate.fdatasync', default=True,
+           from_unicode=bool_from_store,
            help='''\
 Flush dirstate changes onto physical disk?
 
@@ -2395,15 +2408,38 @@
 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(
     Option('editor',
            help='The command called to launch an editor to enter a message.'))
 option_registry.register(
+    Option('ignore_missing_extensions', default=False,
+           from_unicode=bool_from_store,
+           help='''\
+Control the missing extensions warning display.
+
+The warning will not be emitted if set to True.
+'''))
+option_registry.register(
     Option('language',
            help='Language to translate messages into.'))
 option_registry.register(
+    Option('locks.steal_dead', default=False, from_unicode=bool_from_store,
+           help='''\
+Steal locks that appears to be dead.
+
+If set to True, bzr will check if a lock is supposed to be held by an
+active process from the same user on the same machine. If the user and
+machine match, but no process with the given PID is active, then bzr
+will automatically break the stale lock, and create a new lock for
+this process.
+Otherwise, bzr will prompt as normal to break the lock.
+'''))
+option_registry.register(
     Option('output_encoding',
            help= 'Unicode encoding for output'
            ' (terminal encoding if not specified).'))

=== 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-09 16:51:13 +0000
+++ b/bzrlib/help_topics/en/configuration.txt	2011-08-16 15:12:39 +0000
@@ -355,6 +355,10 @@
 
     debug_flags = hpss
 
+or::
+
+    debug_flags = hpss,evil
+
 email
 ~~~~~
 
@@ -423,7 +427,7 @@
 should not be lost if the machine crashes.  See also repository.fdatasync.
 
 gpg_signing_key
-~~~~~~~~~~~
+~~~~~~~~~~~~~~~
 
 The GnuPG user identity to use when signing commits.  Can be an e-mail
 address, key fingerprint or full key ID.  When unset or when set to

=== modified file 'bzrlib/lockdir.py'
--- a/bzrlib/lockdir.py	2011-06-13 01:13:22 +0000
+++ b/bzrlib/lockdir.py	2011-08-12 12:11:44 +0000
@@ -295,9 +295,7 @@
         """
         if (other_holder is not None):
             if other_holder.is_lock_holder_known_dead():
-                if self.get_config().get_user_option_as_bool(
-                    'locks.steal_dead',
-                    default=False):
+                if self.get_config().get('locks.steal_dead'):
                     ui.ui_factory.show_user_warning(
                         'locks_steal_dead',
                         lock_url=urlutils.join(self.transport.base, self.path),
@@ -709,7 +707,8 @@
         """Get the configuration that governs this lockdir."""
         # XXX: This really should also use the locationconfig at least, but
         # that seems a bit hard to hook up at the moment. -- mbp 20110329
-        return config.GlobalConfig()
+        # FIXME: The above is still true ;) -- vila 20110811
+        return config.GlobalStack()
 
 
 class LockHeldInfo(object):

=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py	2011-07-25 07:11:56 +0000
+++ b/bzrlib/osutils.py	2011-08-12 12:18:34 +0000
@@ -42,6 +42,7 @@
 
 from bzrlib import (
     cache_utf8,
+    config,
     errors,
     trace,
     win32utils,
@@ -985,8 +986,7 @@
 def report_extension_load_failures():
     if not _extension_load_failures:
         return
-    from bzrlib.config import GlobalConfig
-    if GlobalConfig().get_user_option_as_bool('ignore_missing_extensions'):
+    if config.GlobalStack().get('ignore_missing_extensions'):
         return
     # the warnings framework should by default show this only once
     from bzrlib.trace import warning

=== modified file 'bzrlib/tests/per_workingtree/test_workingtree.py'
--- a/bzrlib/tests/per_workingtree/test_workingtree.py	2011-07-08 23:01:39 +0000
+++ b/bzrlib/tests/per_workingtree/test_workingtree.py	2011-08-12 14:47:42 +0000
@@ -24,10 +24,12 @@
     branch,
     branchbuilder,
     bzrdir,
+    config,
     errors,
     osutils,
     symbol_versioning,
     tests,
+    trace,
     urlutils,
     )
 from bzrlib.errors import (
@@ -1119,7 +1121,7 @@
 
 class TestControlComponent(TestCaseWithWorkingTree):
     """WorkingTree implementations adequately implement ControlComponent."""
-    
+
     def test_urls(self):
         wt = self.make_branch_and_tree('wt')
         self.assertIsInstance(wt.user_url, str)
@@ -1150,19 +1152,26 @@
 
     def test_set_in_branch(self):
         wt = self.make_wt_with_worth_saving_limit()
-        config = wt.branch.get_config()
-        config.set_user_option('bzr.workingtree.worth_saving_limit', '20')
+        conf = config.BranchStack(wt.branch)
+        conf.set('bzr.workingtree.worth_saving_limit', '20')
         self.assertEqual(20, wt._worth_saving_limit())
         ds = wt.current_dirstate()
         self.assertEqual(10, ds._worth_saving_limit)
 
     def test_invalid(self):
         wt = self.make_wt_with_worth_saving_limit()
-        config = wt.branch.get_config()
-        config.set_user_option('bzr.workingtree.worth_saving_limit', 'a')
+        conf = config.BranchStack(wt.branch)
+        conf.set('bzr.workingtree.worth_saving_limit', 'a')
         # If the config entry is invalid, default to 10
-        # TODO: This writes a warning to the user, trap it somehow
+        warnings = []
+        def warning(*args):
+            warnings.append(args[0] % args[1:])
+        self.overrideAttr(trace, 'warning', warning)
         self.assertEqual(10, wt._worth_saving_limit())
+        self.assertLength(1, warnings)
+        self.assertEquals('Value "a" is not valid for'
+                          ' "bzr.workingtree.worth_saving_limit"',
+                          warnings[0])
 
 
 class TestFormatAttributes(TestCaseWithWorkingTree):

=== 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)

=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py	2011-06-28 11:29:03 +0000
+++ b/bzrlib/workingtree_4.py	2011-08-12 14:47:42 +0000
@@ -34,6 +34,7 @@
 from bzrlib import (
     bzrdir,
     cache_utf8,
+    config,
     conflicts as _mod_conflicts,
     debug,
     dirstate,
@@ -76,8 +77,6 @@
 
 class DirStateWorkingTree(InventoryWorkingTree):
 
-    _DEFAULT_WORTH_SAVING_LIMIT = 10
-
     def __init__(self, basedir,
                  branch,
                  _control_files=None,
@@ -251,20 +250,9 @@
 
         :return: an integer. -1 means never save.
         """
-        config = self.branch.get_config()
-        val = config.get_user_option('bzr.workingtree.worth_saving_limit')
-        if val is None:
-            val = self._DEFAULT_WORTH_SAVING_LIMIT
-        else:
-            try:
-                val = int(val)
-            except ValueError, e:
-                trace.warning('Invalid config value for'
-                              ' "bzr.workingtree.worth_saving_limit"'
-                              ' value %r is not an integer.'
-                              % (val,))
-                val = self._DEFAULT_WORTH_SAVING_LIMIT
-        return val
+        # FIXME: We want a WorkingTreeStack here -- vila 20110812
+        conf = config.BranchStack(self.branch)
+        return conf.get('bzr.workingtree.worth_saving_limit')
 
     def filter_unversioned_files(self, paths):
         """Filter out paths that are versioned.

=== modified file 'doc/en/user-guide/gpg_signatures.txt'
--- a/doc/en/user-guide/gpg_signatures.txt	2011-07-11 10:53:46 +0000
+++ b/doc/en/user-guide/gpg_signatures.txt	2011-08-16 11:19:00 +0000
@@ -16,7 +16,7 @@
 operations.
 
 Setting up GnuPG
---------------
+----------------
 
 There are many guides to creating a digital signature key with GnuPG.  See
 for example the `GnuPG Handbook




More information about the bazaar-commits mailing list