Rev 5806: Don't publicize the hooks yet and add proper cleanups to avoid hook leaks (or hooks triggering during tests cleanup). in file:///home/vila/src/bzr/experimental/config/

Vincent Ladeuil v.ladeuil+lp at free.fr
Tue Jun 14 09:58:02 UTC 2011


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

------------------------------------------------------------
revno: 5806
revision-id: v.ladeuil+lp at free.fr-20110614095801-ip5491k8qmv7ku9w
parent: v.ladeuil+lp at free.fr-20110614090336-mqx0p4bbhpmtwohl
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: config-hooks
timestamp: Tue 2011-06-14 11:58:01 +0200
message:
  Don't publicize the hooks yet and add proper cleanups to avoid hook leaks (or hooks triggering during tests cleanup).
-------------- next part --------------
=== modified file 'bzrlib/hooks.py'
--- a/bzrlib/hooks.py	2011-06-14 08:59:12 +0000
+++ b/bzrlib/hooks.py	2011-06-14 09:58:01 +0000
@@ -72,7 +72,10 @@
     ('bzrlib.branch', 'Branch.hooks', 'BranchHooks'),
     ('bzrlib.bzrdir', 'BzrDir.hooks', 'BzrDirHooks'),
     ('bzrlib.commands', 'Command.hooks', 'CommandHooks'),
-    ('bzrlib.config', 'ConfigHooks', '_ConfigHooks'),
+# Keep the config hooks private (i.e. not shown by 'bzr help hooks') until the
+# old_* ones are removed (which will occur when the stack/store implementation
+# if fully deployed). -- vila 20110614
+#    ('bzrlib.config', 'ConfigHooks', '_ConfigHooks'),
     ('bzrlib.info', 'hooks', 'InfoHooks'),
     ('bzrlib.lock', 'Lock.hooks', 'LockHooks'),
     ('bzrlib.merge', 'Merger.hooks', 'MergeHooks'),

=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py	2011-06-14 09:03:36 +0000
+++ b/bzrlib/tests/test_config.py	2011-06-14 09:58:01 +0000
@@ -1920,6 +1920,8 @@
         def hook(*args):
             calls.append(args)
         config.ConfigHooks.install_named_hook('old_get', hook, None)
+        self.addCleanup(
+            config.ConfigHooks.uninstall_named_hook, 'old_get', None)
         self.assertLength(0, calls)
         actual_value = conf.get_user_option(name)
         self.assertEquals(value, actual_value)
@@ -1942,6 +1944,8 @@
         def hook(*args):
             calls.append(args)
         config.ConfigHooks.install_named_hook('old_set', hook, None)
+        self.addCleanup(
+            config.ConfigHooks.uninstall_named_hook, 'old_set', None)
         self.assertLength(0, calls)
         conf.set_user_option(name, value)
         self.assertLength(1, calls)
@@ -1964,6 +1968,8 @@
         def hook(*args):
             calls.append(args)
         config.ConfigHooks.install_named_hook('old_remove', hook, None)
+        self.addCleanup(
+            config.ConfigHooks.uninstall_named_hook, 'old_remove', None)
         self.assertLength(0, calls)
         conf.remove_user_option(name, section_name)
         self.assertLength(1, calls)
@@ -1987,6 +1993,8 @@
         def hook(*args):
             calls.append(args)
         config.ConfigHooks.install_named_hook('old_load', hook, None)
+        self.addCleanup(
+            config.ConfigHooks.uninstall_named_hook, 'old_load', None)
         self.assertLength(0, calls)
         # Build a config
         conf = conf_class(*conf_args)
@@ -2009,6 +2017,8 @@
         def hook(*args):
             calls.append(args)
         config.ConfigHooks.install_named_hook('old_save', hook, None)
+        self.addCleanup(
+            config.ConfigHooks.uninstall_named_hook, 'old_save', None)
         self.assertLength(0, calls)
         # Setting an option triggers a save
         conf.set_user_option('foo', 'bar')

=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt	2011-06-08 19:49:23 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt	2011-06-14 09:58:01 +0000
@@ -20,10 +20,10 @@
 
 .. New commands, options, etc that users may wish to try out.
 
-* Hooks added for config stacks: ``get``, ``set`` and ``remove`` are called
-  when an option is repsectively read, modified or deleted. Also added
-  ``load`` and ``save`` hooks for config stores, called when the stores are
-  loaded or saved.  (Vincent Ladeuil)
+* Hooks have been added for config stacks: ``get``, ``set`` and ``remove``
+  are called when an option is repsectively read, modified or deleted. Also
+  added ``load`` and ``save`` hooks for config stores, called when the
+  stores are loaded or saved.  (Vincent Ladeuil)
 
 * New hook server_exception in bzrlib.smart.server to catch any
   exception caused while running bzr serve.



More information about the bazaar-commits mailing list