changeset 15584:9df9444e96ec

addchangegroup: use a postrelease callback to call changegroup hook This is will allow addchangegroup to drop lock related code.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Mon, 28 Nov 2011 01:18:15 +0100
parents 926a06f7a353
children a348739da8f0
files mercurial/localrepo.py
diffstat 1 files changed, 14 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Mon Nov 28 15:05:26 2011 +0100
+++ b/mercurial/localrepo.py	Mon Nov 28 01:18:15 2011 +0100
@@ -2003,21 +2003,24 @@
             cl.finalize(trp)
 
             tr.close()
+
+            def postaddchangegroup():
+                if changesets > 0:
+                    # forcefully update the on-disk branch cache
+                    self.ui.debug("updating the branch cache\n")
+                    self.updatebranchcache()
+                    self.hook("changegroup", node=hex(cl.node(clstart)),
+                              source=srctype, url=url)
+
+                    for n in added:
+                        self.hook("incoming", node=hex(n), source=srctype,
+                                  url=url)
+            self._postrelease(postaddchangegroup)
+
         finally:
             tr.release()
             if lock:
                 lock.release()
-
-        if changesets > 0:
-            # forcefully update the on-disk branch cache
-            self.ui.debug("updating the branch cache\n")
-            self.updatebranchcache()
-            self.hook("changegroup", node=hex(cl.node(clstart)),
-                      source=srctype, url=url)
-
-            for n in added:
-                self.hook("incoming", node=hex(n), source=srctype, url=url)
-
         # never return 0 here:
         if dh < 0:
             return dh - 1