addchangegroup: remove the lock argument on the addchangegroup methods
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Mon, 28 Nov 2011 01:32:13 +0100
changeset 15585 a348739da8f0
parent 15584 9df9444e96ec
child 15586 98ec09582f72
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.
mercurial/commands.py
mercurial/localrepo.py
mercurial/sshserver.py
mercurial/wireproto.py
--- a/mercurial/commands.py	Mon Nov 28 01:18:15 2011 +0100
+++ b/mercurial/commands.py	Mon Nov 28 01:32:13 2011 +0100
@@ -5575,8 +5575,7 @@
         for fname in fnames:
             f = url.open(ui, fname)
             gen = changegroup.readbundle(f, fname)
-            modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname,
-                                           lock=lock)
+            modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
         bookmarks.updatecurrentbookmark(repo, wc.node(), wc.branch())
     finally:
         lock.release()
--- a/mercurial/localrepo.py	Mon Nov 28 01:18:15 2011 +0100
+++ b/mercurial/localrepo.py	Mon Nov 28 01:32:13 2011 +0100
@@ -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
--- a/mercurial/sshserver.py	Mon Nov 28 01:18:15 2011 +0100
+++ b/mercurial/sshserver.py	Mon Nov 28 01:32:13 2011 +0100
@@ -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):
--- a/mercurial/wireproto.py	Mon Nov 28 01:18:15 2011 +0100
+++ b/mercurial/wireproto.py	Mon Nov 28 01:32:13 2011 +0100
@@ -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: