Patchwork [5,of,6,clone,bundles] exchange: advertise if a clone bundle was attempted

login
register
mail settings
Submitter Gregory Szorc
Date Oct. 14, 2015, 6:07 p.m.
Message ID <69474173bfb98339226a.1444846077@gps-mbp.local>
Download mbox | patch
Permalink /patch/11072/
State Accepted
Headers show

Comments

Gregory Szorc - Oct. 14, 2015, 6:07 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1444844180 25200
#      Wed Oct 14 10:36:20 2015 -0700
# Node ID 69474173bfb98339226a29c0ba132adb7619626a
# Parent  2a2363bc09f454c432327add39d8dac8acfcb37a
exchange: advertise if a clone bundle was attempted

The client now sends a "cbattempted" boolean flag to the "getbundle"
wire protocol command to tell the server whether a clone bundle was
attempted.

The presence of this flag will enable the server to conditionally emit a
bundle2 "output" part advertising the availability of clone bundles to
compatible clients that don't have it enabled.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1178,8 +1178,18 @@  def _pullbundle2(pullop):
         if pullop.remotebookmarks is None:
             # make sure to always includes bookmark data when migrating
             # `hg incoming --bundle` to using this function.
             kwargs['listkeys'].append('bookmarks')
+
+    # If this is a full pull / clone and the server supports the clone bundles
+    # feature, tell the server whether we attempted a clone bundle. The
+    # presence of this flag indicates the client supports clone bundles. This
+    # will enable the server to treat clients that support clone bundles
+    # differently from those that don't.
+    if (pullop.remote.capable('clonebundles')
+        and pullop.heads is None and list(pullop.common) == [nullid]):
+        kwargs['cbattempted'] = pullop.clonebundleattempted
+
     if streaming:
         pullop.repo.ui.status(_('streaming all changes\n'))
     elif not pullop.fetch:
         pullop.repo.ui.status(_("no changes found\n"))
diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -159,9 +159,10 @@  gboptsmap = {'heads':  'nodes',
              'common': 'nodes',
              'obsmarkers': 'boolean',
              'bundlecaps': 'scsv',
              'listkeys': 'csv',
-             'cg': 'boolean'}
+             'cg': 'boolean',
+             'cbattempted': 'boolean'}
 
 # client side
 
 class wirepeer(peer.peerrepository):