[PATCH 1 of 3 V2] clonebundles: remove advertisement of feature

Gregory Szorc gregory.szorc at gmail.com
Fri Jan 8 19:02:19 UTC 2016


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1452279187 28800
#      Fri Jan 08 10:53:07 2016 -0800
# Node ID 215821eeb56f37f0c490e7942b55691e8c335baf
# Parent  76fc5ac23473a25216f9cba2f977d1f56aa9df92
clonebundles: remove advertisement of feature

I screwed up.

When clone bundles is enabled on the server and a compatible client
without the feature enabled clones, the server sends down an
advertisement saying to enable the feature. The server creates the
message which is printed verbatim on the client as an "output" part.
There are 2 problems:

1) The message doesn't respect the client's localization
2) The message contains a reference to the "experimental.clonebundles"
   option.

Since clone bundles is about to be marked as non-experimental and the
goal of the advertisement was to encourage clients to test the
experimental feature, let's just remove the broken advertisement since
it no longer serves a purpose.

diff --git a/hgext/clonebundles.py b/hgext/clonebundles.py
--- a/hgext/clonebundles.py
+++ b/hgext/clonebundles.py
@@ -159,25 +159,16 @@ down, so does the ability for clients to
 message informing them how to bypass the clone bundles facility when a failure
 occurs. So server operators should prepare for some people to follow these
 instructions when a failure occurs, thus driving more load to the original
 Mercurial server when the bundle hosting service fails.
 
 The following config options influence the behavior of the clone bundles
 feature:
 
-ui.clonebundleadvertise
-   Whether the server advertises the existence of the clone bundles feature
-   to compatible clients that aren't using it.
-
-   When this is enabled (the default), a server will send a message to
-   compatible clients performing a traditional clone informing them of the
-   available clone bundles feature. Compatible clients are those that support
-   bundle2 and are advertising support for the clone bundles feature.
-
 ui.clonebundlefallback
    Whether to automatically fall back to a traditional clone in case of
    clone bundles failure. Defaults to false for reasons described above.
 
 experimental.clonebundles
    Whether the clone bundles feature is enabled on clients. Defaults to true.
 
 experimental.clonebundleprefers
@@ -185,20 +176,17 @@ experimental.clonebundleprefers
    bundle manifests will be sorted by the preferences in this list. e.g.
    the value "BUNDLESPEC=gzip-v1, BUNDLESPEC=bzip2-v1" will prefer a gzipped
    version 1 bundle type then bzip2 version 1 bundle type.
 
    If not defined, the order in the manifest will be used and the first
    available bundle will be downloaded.
 """
 
-from mercurial.i18n import _
-from mercurial.node import nullid
 from mercurial import (
-    exchange,
     extensions,
     wireproto,
 )
 
 testedwith = 'internal'
 
 def capabilities(orig, repo, proto):
     caps = orig(repo, proto)
@@ -206,49 +194,10 @@ def capabilities(orig, repo, proto):
     # Only advertise if a manifest exists. This does add some I/O to requests.
     # But this should be cheaper than a wasted network round trip due to
     # missing file.
     if repo.opener.exists('clonebundles.manifest'):
         caps.append('clonebundles')
 
     return caps
 
- at exchange.getbundle2partsgenerator('clonebundlesadvertise', 0)
-def advertiseclonebundlespart(bundler, repo, source, bundlecaps=None,
-                              b2caps=None, heads=None, common=None,
-                              cbattempted=None, **kwargs):
-    """Inserts an output part to advertise clone bundles availability."""
-    # Allow server operators to disable this behavior.
-    # # experimental config: ui.clonebundleadvertise
-    if not repo.ui.configbool('ui', 'clonebundleadvertise', True):
-        return
-
-    # Only advertise if a manifest is present.
-    if not repo.opener.exists('clonebundles.manifest'):
-        return
-
-    # And when changegroup data is requested.
-    if not kwargs.get('cg', True):
-        return
-
-    # And when the client supports clone bundles.
-    if cbattempted is None:
-        return
-
-    # And when the client didn't attempt a clone bundle as part of this pull.
-    if cbattempted:
-        return
-
-    # And when a full clone is requested.
-    # Note: client should not send "cbattempted" for regular pulls. This check
-    # is defense in depth.
-    if common and common != [nullid]:
-        return
-
-    msg = _('this server supports the experimental "clone bundles" feature '
-            'that should enable faster and more reliable cloning\n'
-            'help test it by setting the "experimental.clonebundles" config '
-            'flag to "true"')
-
-    bundler.newpart('output', data=msg)
-
 def extsetup(ui):
     extensions.wrapfunction(wireproto, '_capabilities', capabilities)
diff --git a/tests/test-clonebundles.t b/tests/test-clonebundles.t
--- a/tests/test-clonebundles.t
+++ b/tests/test-clonebundles.t
@@ -63,27 +63,16 @@ Empty manifest file results in retrieval
   $ hg --verbose clone -U http://localhost:$HGPORT empty-manifest
   no clone bundles available on remote; falling back to regular clone
   requesting all changes
   adding changesets
   adding manifests
   adding file changes
   added 2 changesets with 2 changes to 2 files
 
-Server advertises presence of feature to client requesting full clone
-
-  $ hg --config experimental.clonebundles=false clone -U http://localhost:$HGPORT advertise-on-clone
-  requesting all changes
-  remote: this server supports the experimental "clone bundles" feature that should enable faster and more reliable cloning
-  remote: help test it by setting the "experimental.clonebundles" config flag to "true"
-  adding changesets
-  adding manifests
-  adding file changes
-  added 2 changesets with 2 changes to 2 files
-
 Manifest file with invalid URL aborts
 
   $ echo 'http://does.not.exist/bundle.hg' > server/.hg/clonebundles.manifest
   $ hg clone http://localhost:$HGPORT 404-url
   applying clone bundle from http://does.not.exist/bundle.hg
   error fetching bundle: (.* not known|getaddrinfo failed) (re)
   abort: error applying bundle
   (if this error persists, consider contacting the server operator or disable clone bundles via "--config experimental.clonebundles=false")


More information about the Mercurial-devel mailing list