[PATCH 4 of 5 modernize-streamclone] streamclone: move applyremotedata() into maybeperformstreamclone()
Gregory Szorc
gregory.szorc at gmail.com
Sun Oct 4 13:39:41 CDT 2015
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1443983230 25200
# Sun Oct 04 11:27:10 2015 -0700
# Node ID d96e7f31d75fe746aa4046ea114f070198d46005
# Parent d01a373e1434f4e36d4f5f7560e620c9e97fd3dc
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.
diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -96,9 +96,26 @@ def maybeperformstreamclone(pullop):
raise util.Abort(_('locking the remote repository failed'))
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."""
return ui.configbool('server', 'uncompressed', True, untrusted=True)
@@ -229,32 +246,4 @@ def consumev1(repo, fp):
(util.bytecount(total_bytes), elapsed,
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()
More information about the Mercurial-devel
mailing list