[PATCH 3 of 3] addchangegroup: remove the lock argument on the addchangegroup methods

Pierre-Yves David pierre-yves.david at ens-lyon.org
Mon Nov 28 08:13:34 CST 2011


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1322440333 -3600
# Node ID 4c99bcea941dab2827dd769d57814be8d58867f2
# Parent  b9401c8120aec346e6cae02dee958707df28959b
addchangegroup: remove the lock argument on the addchangegroup methods

This argument is no longer require. post lock release code is now handled with
dedicated post release callback code in lock itself.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1527,8 +1527,7 @@
                                            "changegroupsubset."))
                 else:
                     cg = remote.changegroupsubset(fetch, heads, 'pull')
-                result = self.addchangegroup(cg, 'pull', remote.url(),
-                                             lock=lock)
+                result = self.addchangegroup(cg, 'pull', remote.url())
             phases.advanceboundary(self, 0, common)
         finally:
             lock.release()
@@ -1583,8 +1582,7 @@
                         ret = remote.unbundle(cg, remote_heads, 'push')
                     else:
                         # we return an integer indicating remote head count change
-                        ret = remote.addchangegroup(cg, 'push', self.url(),
-                                                    lock=lock)
+                        ret = remote.addchangegroup(cg, 'push', self.url())
                 # if we don't push, the common data is already useful
                 # everything exchange is public for now
                 phases.advanceboundary(self, 0, fut)
@@ -1849,12 +1847,10 @@
 
         return changegroup.unbundle10(util.chunkbuffer(gengroup()), 'UN')
 
-    def addchangegroup(self, source, srctype, url, emptyok=False, lock=None):
+    def addchangegroup(self, source, srctype, url, emptyok=False):
         """Add the changegroup returned by source.read() to this repo.
         srctype is a string like 'push', 'pull', or 'unbundle'.  url is
         the URL of the repo where this changegroup is coming from.
-        If lock is not None, the function takes ownership of the lock
-        and releases it after the changegroup is added.
 
         Return an integer summarizing the change to this repo:
         - nothing changed or no source: 0
@@ -2019,8 +2015,6 @@
 
         finally:
             tr.release()
-            if lock:
-                lock.release()
         # never return 0 here:
         if dh < 0:
             return dh - 1
diff --git a/mercurial/sshserver.py b/mercurial/sshserver.py
--- a/mercurial/sshserver.py
+++ b/mercurial/sshserver.py
@@ -142,8 +142,8 @@
 
         self.sendresponse("")
         cg = changegroup.unbundle10(self.fin, "UN")
-        r = self.repo.addchangegroup(cg, 'serve', self._client(),
-                                     lock=self.lock)
+        r = self.repo.addchangegroup(cg, 'serve', self._client())
+        self.lock.release()
         return str(r)
 
     def _client(self):
diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -574,8 +574,7 @@
             gen = changegroupmod.readbundle(fp, None)
 
             try:
-                r = repo.addchangegroup(gen, 'serve', proto._client(),
-                                        lock=lock)
+                r = repo.addchangegroup(gen, 'serve', proto._client())
             except util.Abort, inst:
                 sys.stderr.write("abort: %s\n" % inst)
         finally:


More information about the Mercurial-devel mailing list