Patchwork D1929: bundle2: don't advertise stream bundle2 capability when feature disabled

login
register
mail settings
Submitter phabricator
Date Jan. 22, 2018, 9:23 p.m.
Message ID <c64646d8cf83f95c7d19379ffbf93431@localhost.localdomain>
Download mbox | patch
Permalink /patch/27047/
State Not Applicable
Headers show

Comments

phabricator - Jan. 22, 2018, 9:23 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGc1b9eb15a51c: bundle2: don&#039;t advertise stream bundle2 capability when feature disabled (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1929?vs=4987&id=4996

REVISION DETAIL
  https://phab.mercurial-scm.org/D1929

AFFECTED FILES
  mercurial/bundle2.py
  tests/test-clone-uncompressed.t

CHANGE DETAILS




To: indygreg, #hg-reviewers, lothiraldan, durin42
Cc: mercurial-devel

Patch

diff --git a/tests/test-clone-uncompressed.t b/tests/test-clone-uncompressed.t
--- a/tests/test-clone-uncompressed.t
+++ b/tests/test-clone-uncompressed.t
@@ -102,7 +102,7 @@ 
   Main capabilities:
     batch
     branchmap
-    $USUAL_BUNDLE2_CAPS$%0Astream%3Dv2
+    $USUAL_BUNDLE2_CAPS$
     changegroupsubset
     compression=zstd,zlib
     getbundle
@@ -136,8 +136,6 @@ 
     remote-changegroup
       http
       https
-    stream
-      v2
 
   $ hg clone --stream -U http://localhost:$HGPORT server-disabled
   warning: stream clone requested but server has them disabled
diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1519,8 +1519,20 @@ 
         caps['checkheads'] = ('related',)
     if 'phases' in repo.ui.configlist('devel', 'legacy.exchange'):
         caps.pop('phases')
-    if not repo.ui.configbool('experimental', 'bundle2.stream'):
-        caps.pop('stream')
+
+    # Don't advertise stream clone support in server mode if not configured.
+    if role == 'server':
+        streamsupported = repo.ui.configbool('server', 'uncompressed',
+                                             untrusted=True)
+        featuresupported = repo.ui.configbool('experimental', 'bundle2.stream')
+
+        if not streamsupported or not featuresupported:
+            caps.pop('stream')
+    # role == 'client'
+    else:
+        if not repo.ui.configbool('experimental', 'bundle2.stream'):
+            caps.pop('stream')
+
     return caps
 
 def bundle2caps(remote):