Patchwork [04,of,14,V3] streamclone: rework canperformstreamclone

login
register
mail settings
Submitter Boris Feld
Date Jan. 19, 2018, 11:47 p.m.
Message ID <615f8f725f24c2c541b8.1516405629@FB>
Download mbox | patch
Permalink /patch/26988/
State Accepted
Headers show

Comments

Boris Feld - Jan. 19, 2018, 11:47 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1516232727 -3600
#      Thu Jan 18 00:45:27 2018 +0100
# Node ID 615f8f725f24c2c541b85a006bfa4be0915bfcf3
# Parent  542df1a9814ff6e7e688c59528e3d8bad82f8c11
# EXP-Topic b2-stream
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 615f8f725f24
streamclone: rework canperformstreamclone

There is code about bundle2 laying around in `canperformstreamclone` but not
put to any uses. As we discovered with the previous patch, streambundle 'v1'
won't work on bundle2 because they are readline based. So we jump to 'v2' as
the first expected supported version.

Patch

diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -18,12 +18,11 @@  from . import (
     util,
 )
 
-def canperformstreamclone(pullop, bailifbundle2supported=False):
+def canperformstreamclone(pullop, bundle2=False):
     """Whether it is possible to perform a streaming clone as part of pull.
 
-    ``bailifbundle2supported`` will cause the function to return False if
-    bundle2 stream clones are supported. It should only be called by the
-    legacy stream clone code path.
+    ``bundle2`` will cause the function to consider stream clone through
+    bundle2 and only through bundle2.
 
     Returns a tuple of (supported, requirements). ``supported`` is True if
     streaming clone is supported and False otherwise. ``requirements`` is
@@ -35,18 +34,18 @@  def canperformstreamclone(pullop, bailif
 
     bundle2supported = False
     if pullop.canusebundle2:
-        if 'v1' in pullop.remotebundle2caps.get('stream', []):
+        if 'v2' in pullop.remotebundle2caps.get('stream', []):
             bundle2supported = True
         # else
             # Server doesn't support bundle2 stream clone or doesn't support
             # the versions we support. Fall back and possibly allow legacy.
 
     # Ensures legacy code path uses available bundle2.
-    if bailifbundle2supported and bundle2supported:
+    if bundle2supported and not bundle2:
         return False, None
     # Ensures bundle2 doesn't try to do a stream clone if it isn't supported.
-    #elif not bailifbundle2supported and not bundle2supported:
-    #    return False, None
+    elif bundle2 and not bundle2supported:
+        return False, None
 
     # Streaming clone only works on empty repositories.
     if len(repo):