changeset 26461:09cc3c2e9ece

streamclone: move applyremotedata() into maybeperformstreamclone() Future work around stream cloning will be implemented in a bundle2 world. This code will only be used in the legacy code path and doesn't need to be abstracted or extensible.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 04 Oct 2015 11:27:10 -0700
parents 79ef867538ea
children 3b0ec09192ae
files mercurial/streamclone.py
diffstat 1 files changed, 18 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/streamclone.py	Sat Oct 03 09:53:56 2015 -0700
+++ b/mercurial/streamclone.py	Sun Oct 04 11:27:10 2015 -0700
@@ -97,7 +97,24 @@
     elif resp != 0:
         raise util.Abort(_('the server sent an unknown error code'))
 
-    applyremotedata(repo, requirements, rbranchmap, fp)
+    lock = repo.lock()
+    try:
+        consumev1(repo, fp)
+
+        # new requirements = old non-format requirements +
+        #                    new format-related remote requirements
+        # requirements from the streamed-in repository
+        repo.requirements = requirements | (
+                repo.requirements - repo.supportedformats)
+        repo._applyopenerreqs()
+        repo._writerequirements()
+
+        if rbranchmap:
+            branchmap.replacecache(repo, rbranchmap)
+
+        repo.invalidate()
+    finally:
+        lock.release()
 
 def allowservergeneration(ui):
     """Whether streaming clones are allowed from the server."""
@@ -230,31 +247,3 @@
                         util.bytecount(total_bytes / elapsed)))
     finally:
         lock.release()
-
-def applyremotedata(repo, remotereqs, remotebranchmap, fp):
-    """Apply stream clone data to a repository.
-
-    "remotereqs" is a set of requirements to handle the incoming data.
-    "remotebranchmap" is the result of a branchmap lookup on the remote. It
-    can be None.
-    "fp" is a file object containing the raw stream data, suitable for
-    feeding into consumev1().
-    """
-    lock = repo.lock()
-    try:
-        consumev1(repo, fp)
-
-        # new requirements = old non-format requirements +
-        #                    new format-related remote requirements
-        # requirements from the streamed-in repository
-        repo.requirements = remotereqs | (
-                repo.requirements - repo.supportedformats)
-        repo._applyopenerreqs()
-        repo._writerequirements()
-
-        if remotebranchmap:
-            branchmap.replacecache(repo, remotebranchmap)
-
-        repo.invalidate()
-    finally:
-        lock.release()