hgext/keyword.py
branchstable
changeset 10492 0e64d814d7d0
parent 10332 f64160f28b3f
child 10495 2c2d2f1354b4
--- a/hgext/keyword.py	Wed Feb 17 11:00:48 2010 +0100
+++ b/hgext/keyword.py	Wed Feb 17 15:43:21 2010 +0100
@@ -480,7 +480,14 @@
             # other extensions can still wrap repo.commitctx directly
             self.commitctx = self.kwcommitctx
             try:
-                return super(kwrepo, self).commit(*args, **opts)
+                self._kwcommithooks = {}
+                n = super(kwrepo, self).commit(*args, **opts)
+                if self._kwcommithooks:
+                    xp1, xp2 = self._kwxp1, self._kwxp2
+                    for name, cmd in self._kwcommithooks.iteritems():
+                        ui.setconfig('hooks', name, cmd)
+                    self.hook('commit', node=n, parent1=xp1, parent2=xp2)
+                return n
             finally:
                 del self.commitctx
 
@@ -490,23 +497,18 @@
                 wlock = self.wlock()
                 lock = self.lock()
                 # store and postpone commit hooks
-                commithooks = {}
                 for name, cmd in ui.configitems('hooks'):
                     if name.split('.', 1)[0] == 'commit':
-                        commithooks[name] = cmd
+                        self._kwcommithooks[name] = cmd
                         ui.setconfig('hooks', name, None)
-                if commithooks:
+                if self._kwcommithooks:
                     # store parents for commit hooks
                     p1, p2 = ctx.p1(), ctx.p2()
-                    xp1, xp2 = p1.hex(), p2 and p2.hex() or ''
+                    self._kwxp1, self._kwxp2 = p1.hex(), p2 and p2.hex() or ''
 
                 n = super(kwrepo, self).commitctx(ctx, error)
 
                 kwt.overwrite(n, True, None)
-                if commithooks:
-                    for name, cmd in commithooks.iteritems():
-                        ui.setconfig('hooks', name, cmd)
-                    self.hook('commit', node=n, parent1=xp1, parent2=xp2)
                 return n
             finally:
                 release(lock, wlock)