# HG changeset patch # User Christian Ebert # Date 1194776990 -3600 # Node ID 869b16d09eecd6efe33e45f94c26cd357cf143f6 # Parent 343c5dd8dcda2a9de958c4004b6967b8abc7af22 Commit hook handling entirely into if-condition diff -r 343c5dd8dcda -r 869b16d09eec hgkw/keyword.py --- a/hgkw/keyword.py Sat Nov 10 14:08:12 2007 +0100 +++ b/hgkw/keyword.py Sun Nov 11 11:29:50 2007 +0100 @@ -441,23 +441,17 @@ 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 = '' + # store parents for commit hook environment + if p1 is None: + _p1, _p2 = repo.dirstate.parents() else: - xp2 = hex(xp2) + _p1, _p2 = p1, p2 or nullid node = super(kwrepo, self).commit(files=files, text=text, user=user, @@ -473,10 +467,16 @@ # 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) + 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) return node finally: del wlock, lock