changeset 26442:ef8d27f53204

streamclone: move stream_in() from localrepo Another basic content move. The underscore from the function name was removed to comply with naming standards.
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 02 Oct 2015 15:58:24 -0700
parents 56527b886d1d
children d947086d8973
files mercurial/localrepo.py mercurial/streamclone.py
diffstat 2 files changed, 29 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Fri Oct 02 15:51:32 2015 -0700
+++ b/mercurial/localrepo.py	Fri Oct 02 15:58:24 2015 -0700
@@ -1788,30 +1788,6 @@
         """
         return util.hooks()
 
-    def stream_in(self, 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'))
-
-        streamclone.applyremotedata(self, remotereqs, rbranchmap, fp)
-        return len(self.heads()) + 1
-
     def clone(self, remote, heads=[], stream=None):
         '''clone remote repository.
 
@@ -1834,7 +1810,7 @@
         if stream and not heads:
             # 'stream' means remote revlog format is revlogv1 only
             if remote.capable('stream'):
-                self.stream_in(remote, set(('revlogv1',)))
+                streamclone.streamin(self, remote, set(('revlogv1',)))
             else:
                 # otherwise, 'streamreqs' contains the remote revlog format
                 streamreqs = remote.capable('streamreqs')
@@ -1842,7 +1818,7 @@
                     streamreqs = set(streamreqs.split(','))
                     # if we support it, stream in and adjust our requirements
                     if not streamreqs - self.supportedformats:
-                        self.stream_in(remote, streamreqs)
+                        streamclone.streamin(self, remote, streamreqs)
 
         # internal config: ui.quietbookmarkmove
         quiet = self.ui.backupconfig('ui', 'quietbookmarkmove')
--- a/mercurial/streamclone.py	Fri Oct 02 15:51:32 2015 -0700
+++ b/mercurial/streamclone.py	Fri Oct 02 15:58:24 2015 -0700
@@ -7,11 +7,38 @@
 
 from __future__ import absolute_import
 
+from .i18n import _
 from . import (
     branchmap,
+    error,
     exchange,
+    util,
 )
 
+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.