streamclone: move _allowstream() from wireproto
authorGregory Szorc <gregory.szorc@gmail.com>
Fri, 02 Oct 2015 16:24:56 -0700
changeset 26444 623743010133
parent 26443 d947086d8973
child 26445 f134fb33c906
streamclone: move _allowstream() from wireproto While we're moving things into streamclone.py...
mercurial/streamclone.py
mercurial/wireproto.py
--- a/mercurial/streamclone.py	Fri Oct 02 16:05:52 2015 -0700
+++ b/mercurial/streamclone.py	Fri Oct 02 16:24:56 2015 -0700
@@ -17,6 +17,10 @@
     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()
--- a/mercurial/wireproto.py	Fri Oct 02 16:05:52 2015 -0700
+++ b/mercurial/wireproto.py	Fri Oct 02 16:24:56 2015 -0700
@@ -564,7 +564,7 @@
     """
     # 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
@@ -701,16 +701,13 @@
                      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):