Bug 1231192 - Support clonebundles feature; r=smacleod

bundleclone is the Mozilla-specific precursor to the "clonebundles"
feature in Mercurial 3.6. Change the wizard to recognize when
clonebundles is available and to favor it. Activating clonebundles will
also disable bundleclone, as bundleclone is redundant with clonebundles.
(If both are enabled, bundleclone detects this and gets out of the way.)
This commit is contained in:
Gregory Szorc 2015-12-07 13:03:17 -08:00
parent a83a6676cc
commit dc28dfc19c
2 changed files with 31 additions and 1 deletions

View File

@ -209,3 +209,18 @@ class MercurialConfig(object):
for k in ('password', 'userid', 'cookie'): for k in ('password', 'userid', 'cookie'):
if k in b: if k in b:
del b[k] del b[k]
def have_clonebundles(self):
return 'clonebundles' in self._c.get('experimental', {})
def activate_clonebundles(self):
exp = self._c.setdefault('experimental', {})
exp['clonebundles'] = 'true'
# bundleclone is redundant with clonebundles. Remove it if it
# is installed.
ext = self._c.get('extensions', {})
try:
del ext['bundleclone']
except KeyError:
pass

View File

@ -211,6 +211,15 @@ they can push to try without depending on mq or other workarounds.
Would you like to activate push-to-try Would you like to activate push-to-try
'''.strip() '''.strip()
CLONEBUNDLES_INFO = '''
Mercurial 3.6 and hg.mozilla.org support transparently cloning from a CDN,
making clones faster and more reliable.
(Relevant config option: experimental.clonebundles)
Would you like to activate this feature and have faster clones
'''.strip()
BUNDLECLONE_MINIMUM_VERSION = LooseVersion('3.1') BUNDLECLONE_MINIMUM_VERSION = LooseVersion('3.1')
BUNDLECLONE_INFO = ''' BUNDLECLONE_INFO = '''
@ -359,7 +368,13 @@ class MercurialSetupWizard(object):
if hg_version >= FIREFOXTREE_MINIMUM_VERSION: if hg_version >= FIREFOXTREE_MINIMUM_VERSION:
self.prompt_external_extension(c, 'firefoxtree', FIREFOXTREE_INFO) self.prompt_external_extension(c, 'firefoxtree', FIREFOXTREE_INFO)
if hg_version >= BUNDLECLONE_MINIMUM_VERSION: # Functionality from bundleclone is experimental in Mercurial 3.6.
# There was a bug in 3.6, so look for 3.6.1.
if hg_version >= LooseVersion('3.6.1'):
if not c.have_clonebundles() and self._prompt_yn(CLONEBUNDLES_INFO):
c.activate_clonebundles()
print('Enabled the clonebundles feature.\n')
elif hg_version >= BUNDLECLONE_MINIMUM_VERSION:
self.prompt_external_extension(c, 'bundleclone', BUNDLECLONE_INFO) self.prompt_external_extension(c, 'bundleclone', BUNDLECLONE_INFO)
if hg_version >= PUSHTOTRY_MINIMUM_VERSION: if hg_version >= PUSHTOTRY_MINIMUM_VERSION: