Do not run commit hooks if there is no node
authorChristian Ebert <blacktrash@gmx.net>
Sat, 01 Dec 2007 09:52:00 +0100
changeset 304 815dc4a04296
parent 302 caa3d683cfcf
child 305 d3cdaa49a644
Do not run commit hooks if there is no node Eg. when commit is interrupted.
hgkw/keyword.py
--- a/hgkw/keyword.py	Mon Nov 26 12:30:50 2007 +0100
+++ b/hgkw/keyword.py	Sat Dec 01 09:52:00 2007 +0100
@@ -445,7 +445,7 @@
                 for name, cmd in ui.configitems('hooks'):
                     if name.split('.', 1)[0] == 'commit':
                         commithooks.append((name, cmd))
-                        ui.setconfig('hooks', name, '')
+                        ui.setconfig('hooks', name, None)
                 if commithooks:
                     # store parents for commit hook environment
                     if p1 is None:
@@ -463,6 +463,10 @@
                                           date=date, match=match, force=force,
                                           force_editor=force_editor,
                                           p1=p1, p2=p2, extra=extra)
+
+                # restore commit hooks
+                for name, cmd in commithooks:
+                    ui.setconfig('hooks', name, cmd)
                 if node is not None:
                     cl = self.changelog.read(node)
                     mn = self.manifest.read(cl[0])
@@ -471,11 +475,7 @@
                     if candidates:
                         # 6th, 7th arguments set expansion, commit to True
                         _overwrite(ui, self, candidates, node, mn, True, True)
-
-                # 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)
+                    repo.hook('commit', node=node, parent1=_p1, parent2=_p2)
                 return node
             finally:
                 del wlock, lock