--- a/hgkw/keyword.py Thu Nov 08 13:03:24 2007 +0100
+++ b/hgkw/keyword.py Sat Nov 10 14:06:59 2007 +0100
@@ -82,6 +82,7 @@
from mercurial import commands, cmdutil, context, fancyopts
from mercurial import filelog, localrepo, revlog, templater, util
+from mercurial.node import *
from mercurial.i18n import _
import re, shutil, sys, tempfile, time
@@ -327,6 +328,10 @@
ui.quiet = not verbose
commands.branch(ui, repo, branchname)
ui.quiet = quiet
+ for name, cmd in ui.configitems('hooks'):
+ if name.split('.', 1)[0].find('commit') > -1:
+ repo.ui.setconfig('hooks', name, '')
+ ui.note(_('unhooked all commit hooks\n'))
ui.note('hg -R "%s" ci -m "%s"\n' % (tmpdir, msg))
repo.commit(text=msg)
pathinfo = ('', ' in %s' % path)[ui.verbose]
@@ -435,6 +440,25 @@
try:
wlock = self.wlock()
lock = self.lock()
+ # store and postpone commit hooks
+ # store parents for commit hook environment
+ commithooks = []
+ xp1, xp2 = p1, p2
+ for name, cmd in ui.configitems('hooks'):
+ if name.split('.', 1)[0] == 'commit':
+ commithooks.append((name, cmd))
+ ui.setconfig('hooks', name, '')
+ if commithooks:
+ if xp1 is None:
+ xp1, xp2 = repo.dirstate.parents()
+ elif not xp2:
+ xp2 = nullid
+ xp1 = hex(xp1)
+ if xp2 == nullid:
+ xp2 = ''
+ else:
+ xp2 = hex(xp2)
+
node = super(kwrepo,
self).commit(files=files, text=text, user=user,
date=date, match=match, force=force,
@@ -448,6 +472,11 @@
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=xp1, parent2=xp2)
return node
finally:
del wlock, lock