diff mercurial/wireproto.py @ 20968:33d5fdd9bd99

unbundle: extract the core logic in another function The `exchange` module now contains an `unbundle` function that holds the core unbundle logic. The wire protocol keeps its own unbundle function. It enforces wireprotocol-specific logic and then calls the extracted function. This aims at implementing unbundle for localrepo.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Fri, 04 Apr 2014 17:28:59 -0700
parents 984850270acb
children 7a679918ee2b
line wrap: on
line diff
--- a/mercurial/wireproto.py	Fri Apr 04 17:15:25 2014 -0700
+++ b/mercurial/wireproto.py	Fri Apr 04 17:28:59 2014 -0700
@@ -765,21 +765,10 @@
         r = 0
         try:
             proto.getfile(fp)
-            lock = repo.lock()
-            try:
-                exchange.check_heads(repo, their_heads, 'uploading changes')
-
-                # push can proceed
-                fp.seek(0)
-                gen = changegroupmod.readbundle(fp, None)
-
-                try:
-                    r = changegroupmod.addchangegroup(repo, gen, 'serve',
-                                                      proto._client())
-                except util.Abort, inst:
-                    sys.stderr.write("abort: %s\n" % inst)
-            finally:
-                lock.release()
+            fp.seek(0)
+            gen = changegroupmod.readbundle(fp, None)
+            r = exchange.unbundle(repo, gen, their_heads, 'serve',
+                                  proto._client())
             return pushres(r)
 
         finally: