[PATCH 5 of 5 modernize-streamclone] streamclone: move _allowstream() from wireproto

Gregory Szorc gregory.szorc at gmail.com
Fri Oct 2 18:34:05 CDT 2015


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1443828296 25200
#      Fri Oct 02 16:24:56 2015 -0700
# Node ID 667f7b208f400279f93a525e7aa062700ef4ee8d
# Parent  3b427581580d347b861b99a6cfef37d56d5a3808
streamclone: move _allowstream() from wireproto

While we're moving things into streamclone.py...

diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -16,8 +16,12 @@ from . import (
     store,
     util,
 )
 
+def allowservergeneration(ui):
+    """Whether streaming clones are allowed from the server."""
+    return ui.configbool('server', 'uncompressed', True, untrusted=True)
+
 # This is it's own function so extensions can override it.
 def _walkstreamfiles(repo):
     return repo.store.walk()
 
diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -563,9 +563,9 @@ def _capabilities(repo, proto):
       command without any other action needed.
     """
     # copy to prevent modification of the global list
     caps = list(wireprotocaps)
-    if _allowstream(repo.ui):
+    if streamclone.allowservergeneration(repo.ui):
         if repo.ui.configbool('server', 'preferuncompressed', False):
             caps.append('stream-preferred')
         requiredformats = repo.requirements & repo.supportedformats
         # if our local revlogs are just revlogv1, add 'stream' cap
@@ -700,18 +700,15 @@ def pushkey(repo, proto, namespace, key,
     r = repo.pushkey(encoding.tolocal(namespace), encoding.tolocal(key),
                      encoding.tolocal(old), new)
     return '%s\n' % int(r)
 
-def _allowstream(ui):
-    return ui.configbool('server', 'uncompressed', True, untrusted=True)
-
 @wireprotocommand('stream_out')
 def stream(repo, proto):
     '''If the server supports streaming clone, it advertises the "stream"
     capability with a value representing the version and flags of the repo
     it is serving. Client checks to see if it understands the format.
     '''
-    if not _allowstream(repo.ui):
+    if not streamclone.allowservergeneration(repo.ui):
         return '1\n'
 
     def getstream(it):
         yield '0\n'


More information about the Mercurial-devel mailing list