changegroup: don't run changegroup hooks if nodes are gone
authorDurham Goode <durham@fb.com>
Mon, 07 Oct 2013 11:45:01 -0700
changeset 19884 fc3fbca35085
parent 19881 821a89018f17
child 19885 6cc696179869
changegroup: don't run changegroup hooks if nodes are gone The changegroup hook runs when the repo lock is released, but it's possible that multiple transactions have happened during that single lock and therefore the commits the hook was for may be gone. This is the case in the shelve extension where it adds a commit and strips it in the same lock but different transactions (which results in warning messages during unshelve on hgsubversion repos). A real fix would be to attach the hook to the transaction instead, but that might have unknown consequences. Since we're this close to code-freeze, this fix just prevents the hook from running if the commit disappeared.
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Wed Oct 02 09:50:21 2013 +0200
+++ b/mercurial/localrepo.py	Mon Oct 07 11:45:01 2013 -0700
@@ -2229,6 +2229,12 @@
                     # In other case we can safely update cache on disk.
                     branchmap.updatecache(self.filtered('served'))
                 def runhooks():
+                    # These hooks run when the lock releases, not when the
+                    # transaction closes. So it's possible for the changelog
+                    # to have changed since we last saw it.
+                    if clstart >= len(self):
+                        return
+
                     # forcefully update the on-disk branch cache
                     self.ui.debug("updating the branch cache\n")
                     self.hook("changegroup", node=hex(cl.node(clstart)),