[PATCH 1 of 5 modernize-streamclone] streamclone: move streaming clone logic from localrepo
Gregory Szorc
gregory.szorc at gmail.com
Sat Oct 3 05:55:53 UTC 2015
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1443847144 25200
# Fri Oct 02 21:39:04 2015 -0700
# Node ID 78a614c3c6def09605aa17d23da8a94a931fe6cc
# Parent 667f7b208f400279f93a525e7aa062700ef4ee8d
streamclone: move streaming clone logic from localrepo
This is the last remnants of streaming clone code in localrepo.py.
This is a mostly mechanical transplant of code to a new file. Only a
rewrite of "self" to "repo" was performed. The code will be
significantly refactored in upcoming patches. So don't scrutinize it too
closely.
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1788,33 +1788,9 @@ class localrepository(object):
keyword arguments:
heads: list of revs to clone (forces use of pull)
stream: use streaming clone if possible'''
-
- # now, all clients that can request uncompressed clones can
- # read repo formats supported by all servers that can serve
- # them.
-
- # if revlog format changes, client will have to check version
- # and format flags on "stream" capability, and use
- # uncompressed only if compatible.
-
- if stream is None:
- # if the server explicitly prefers to stream (for fast LANs)
- stream = remote.capable('stream-preferred')
-
- if stream and not heads:
- # 'stream' means remote revlog format is revlogv1 only
- if remote.capable('stream'):
- streamclone.streamin(self, remote, set(('revlogv1',)))
- else:
- # otherwise, 'streamreqs' contains the remote revlog format
- streamreqs = remote.capable('streamreqs')
- if streamreqs:
- streamreqs = set(streamreqs.split(','))
- # if we support it, stream in and adjust our requirements
- if not streamreqs - self.supportedformats:
- streamclone.streamin(self, remote, streamreqs)
+ streamclone.maybeperformstreamclone(self, remote, heads, stream)
# internal config: ui.quietbookmarkmove
quiet = self.ui.backupconfig('ui', 'quietbookmarkmove')
try:
diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -16,8 +16,34 @@ from . import (
store,
util,
)
+def maybeperformstreamclone(repo, remote, heads, stream):
+ # now, all clients that can request uncompressed clones can
+ # read repo formats supported by all servers that can serve
+ # them.
+
+ # if revlog format changes, client will have to check version
+ # and format flags on "stream" capability, and use
+ # uncompressed only if compatible.
+
+ if stream is None:
+ # if the server explicitly prefers to stream (for fast LANs)
+ stream = remote.capable('stream-preferred')
+
+ if stream and not heads:
+ # 'stream' means remote revlog format is revlogv1 only
+ if remote.capable('stream'):
+ streamin(repo, remote, set(('revlogv1',)))
+ else:
+ # otherwise, 'streamreqs' contains the remote revlog format
+ streamreqs = remote.capable('streamreqs')
+ if streamreqs:
+ streamreqs = set(streamreqs.split(','))
+ # if we support it, stream in and adjust our requirements
+ if not streamreqs - repo.supportedformats:
+ streamin(repo, remote, streamreqs)
+
def allowservergeneration(ui):
"""Whether streaming clones are allowed from the server."""
return ui.configbool('server', 'uncompressed', True, untrusted=True)
More information about the Mercurial-devel
mailing list