[PATCH 2 of 5 modernize-streamclone] streamclone: move streamin() into maybeperformstreamclone()
Gregory Szorc
gregory.szorc at gmail.com
Sun Oct 4 13:39:39 CDT 2015
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1443852495 25200
# Fri Oct 02 23:08:15 2015 -0700
# Node ID 5ac0d9d646e498321c709e9bcd9467cfe037b2c1
# Parent 75d8cd0377ab35712741e1fc0add30126c41b620
streamclone: move streamin() into maybeperformstreamclone()
streamin() only had a single consumer. And it always only ever will
because it is strongly coupled with the current,
soon-to-be-superseded-by-bundle2 functionality.
The return value has been dropped because nobody was using it.
diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -76,9 +76,29 @@ def maybeperformstreamclone(pullop):
if not supported:
return
- streamin(repo, remote, requirements)
+ # Save remote branchmap. We will use it later to speed up branchcache
+ # creation.
+ rbranchmap = None
+ if remote.capable('branchmap'):
+ rbranchmap = remote.branchmap()
+
+ fp = remote.stream_out()
+ l = fp.readline()
+ try:
+ resp = int(l)
+ except ValueError:
+ raise error.ResponseError(
+ _('unexpected response from remote server:'), l)
+ if resp == 1:
+ raise util.Abort(_('operation forbidden by server'))
+ elif resp == 2:
+ 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)
def allowservergeneration(ui):
"""Whether streaming clones are allowed from the server."""
return ui.configbool('server', 'uncompressed', True, untrusted=True)
@@ -210,32 +230,8 @@ def consumev1(repo, fp):
util.bytecount(total_bytes / elapsed)))
finally:
lock.release()
-def streamin(repo, remote, remotereqs):
- # Save remote branchmap. We will use it later
- # to speed up branchcache creation
- rbranchmap = None
- if remote.capable("branchmap"):
- rbranchmap = remote.branchmap()
-
- fp = remote.stream_out()
- l = fp.readline()
- try:
- resp = int(l)
- except ValueError:
- raise error.ResponseError(
- _('unexpected response from remote server:'), l)
- if resp == 1:
- raise util.Abort(_('operation forbidden by server'))
- elif resp == 2:
- raise util.Abort(_('locking the remote repository failed'))
- elif resp != 0:
- raise util.Abort(_('the server sent an unknown error code'))
-
- applyremotedata(repo, remotereqs, rbranchmap, fp)
- return len(repo.heads()) + 1
-
def applyremotedata(repo, remotereqs, remotebranchmap, fp):
"""Apply stream clone data to a repository.
"remotereqs" is a set of requirements to handle the incoming data.
More information about the Mercurial-devel
mailing list