[PATCH 2 of 2] keyword: store commit hooks in dictionary

Christian Ebert blacktrash at gmx.net
Tue Jan 22 09:10:01 CST 2008


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1201004225 -3600
# Node ID b18f65c88327e7a817080d52cec44043a296b39c
# Parent  c52d5993e84510295a9ab671e92bd02d18489c6d
keyword: store commit hooks in dictionary

This safe, as hook.hook() sorts before execution.

diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -464,10 +464,10 @@
                 wlock = self.wlock()
                 lock = self.lock()
                 # store and postpone commit hooks
-                commithooks = []
+                commithooks = {}
                 for name, cmd in ui.configitems('hooks'):
                     if name.split('.', 1)[0] == 'commit':
-                        commithooks.append((name, cmd))
+                        commithooks[name] = cmd
                         ui.setconfig('hooks', name, None)
                 if commithooks:
                     # store parents for commit hook environment
@@ -488,7 +488,7 @@
                                           p1=p1, p2=p2, extra=extra)
 
                 # restore commit hooks
-                for name, cmd in commithooks:
+                for name, cmd in commithooks.iteritems():
                     ui.setconfig('hooks', name, cmd)
                 if node is not None:
                     _overwrite(ui, self, node=node)


More information about the Mercurial-devel mailing list