RFC: Fix for issue 1827
Sune Foldager
cryo at cyanite.org
Mon Feb 15 16:07:13 CST 2010
What do you guys think of the following patch? I am not sure how people
will like
a) invoking the commit hook in a different method than before. could
affect some dodgy external code, perhaps, although I shouldn't think so.
b) the trick to release the lock "early" (outside the finally). The code
I wrote ensures that the locks are only released once.
/Sune
# HG changeset patch
# User Sune Foldager <cryo at cyanite.org>
# Date 1266270994 -3600
# Branch stable
# Node ID 702c317a52091d7ecc01bd4e74c8e42c6f001eda
# Parent 44b4a2a3162319ef6d21c9e9f191ecf2c42ea609
run commit and update hooks after command completion (issue1827)
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -862,10 +862,15 @@
self.dirstate.setparents(ret)
ms.reset()
+ wl, wlock = wlock, None
+ wl.release()
+ self.hook("commit", node=hex(ret), parent1=hex(p1),
+ parent2=(p2 != nullid and hex(p2) or ''))
return ret
finally:
- wlock.release()
+ if wlock:
+ wlock.release()
def commitctx(self, ctx, error=False):
"""Add a new revision to current repository.
@@ -933,7 +938,6 @@
if self._branchcache:
self.branchtags()
- self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2)
return n
finally:
del tr
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -511,8 +511,11 @@
repo.dirstate.setparents(fp1, fp2)
if not branchmerge and not fastforward:
repo.dirstate.setbranch(p2.branch())
+ wl, wlock = wlock, None
+ wl.release()
repo.hook('update', parent1=xp1, parent2=xp2, error=stats[3])
return stats
finally:
- wlock.release()
+ if wlock:
+ wlock.release()
More information about the Mercurial-devel
mailing list