RFC: Fix for issue 1827 (v2)

Sune Foldager cryo at cyanite.org
Mon Feb 15 16:30:23 CST 2010


Here is another version which doesn't have the race condition. The
problem with this one, IMO, is style.. it's a bit annoying to refer to
variables that aren't set on the same level, but that you semantically
know are set at this point :-p

# HG changeset patch
# User Sune Foldager <cryo at cyanite.org>
# Date 1266272885 -3600
# Branch stable
# Node ID 09b5f6ecea662e89520ca1ce0317367293386942
# 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,11 +862,13 @@
             self.dirstate.setparents(ret)
             ms.reset()

-            return ret
-
         finally:
             wlock.release()

+        self.hook("commit", node=hex(ret), parent1=hex(p1),
+                  parent2=(p2 != nullid and hex(p2) or ''))
+        return ret
+
     def commitctx(self, ctx, error=False):
         """Add a new revision to current repository.

@@ -933,7 +935,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,10 @@
             repo.dirstate.setparents(fp1, fp2)
             if not branchmerge and not fastforward:
                 repo.dirstate.setbranch(p2.branch())
-            repo.hook('update', parent1=xp1, parent2=xp2, error=stats[3])

-        return stats
     finally:
         wlock.release()
+
+    if not partial:
+        repo.hook('update', parent1=xp1, parent2=xp2, error=stats[3])
+    return stats


More information about the Mercurial-devel mailing list