# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 2011-11-28 00:32:13
# Node ID a348739da8f07914f59e9ddbb6e51df2f94b4d45
# Parent  9df9444e96ec6df9f870cdcfb338e33c025841cd

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/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5575,8 +5575,7 @@ def unbundle(ui, repo, fname1, *fnames, 
         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()
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1527,8 +1527,7 @@ class localrepository(repo.repository):
                                            "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 @@ class localrepository(repo.repository):
                         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 @@ class localrepository(repo.repository):
 
         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 @@ class localrepository(repo.repository):
 
         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 @@ class sshserver(object):
 
         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 @@ def unbundle(repo, proto, heads):
             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: