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.
--- 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()