Rearrange commit hook hack
authorChristian Ebert <blacktrash@gmx.net>
Tue, 13 Nov 2007 02:06:38 +0100
changeset 297 9e29992343a1
parent 296 869b16d09eec
child 298 c8afb99bb70f
Rearrange commit hook hack
hgkw/keyword.py
--- a/hgkw/keyword.py	Sun Nov 11 11:29:50 2007 +0100
+++ b/hgkw/keyword.py	Tue Nov 13 02:06:38 2007 +0100
@@ -437,6 +437,7 @@
                    match=util.always, force=False, force_editor=False,
                    p1=None, p2=None, extra={}):
             wlock = lock = None
+            _p1 = _p2 = None
             try:
                 wlock = self.wlock()
                 lock = self.lock()
@@ -452,6 +453,11 @@
                         _p1, _p2 = repo.dirstate.parents()
                     else:
                         _p1, _p2 = p1, p2 or nullid
+                    _p1 = hex(_p1)
+                    if _p2 == nullid:
+                        _p2 = ''
+                    else:
+                        _p2 = hex(_p2)
 
                 node = super(kwrepo,
                              self).commit(files=files, text=text, user=user,
@@ -467,16 +473,10 @@
                         # 6th, 7th arguments set expansion, commit to True
                         _overwrite(ui, self, candidates, node, mn, True, True)
 
-                if commithooks:
-                    # restore commit hooks and run them
-                    for name, cmd in commithooks:
-                        ui.setconfig('hooks', name, cmd)
-                    xp1 = hex(_p1)
-                    if _p2 == nullid:
-                        xp2 = ''
-                    else:
-                        xp2 = hex(_p2)
-                    repo.hook('commit', node=node, parent1=xp1, parent2=xp2)
+                # restore commit hooks and run them
+                for name, cmd in commithooks:
+                    ui.setconfig('hooks', name, cmd)
+                repo.hook('commit', node=node, parent1=_p1, parent2=_p2)
                 return node
             finally:
                 del wlock, lock