Bug 1424386: Update robustcheckout in m-c with latest version from v-c-t r?gps draft
authorConnor Sheehan <sheehan@mozilla.com>
Wed, 20 Dec 2017 10:48:04 -0500
changeset 713560 1573ee2dcf29ab7e22d8d40b4a88d504fe9efe24
parent 713559 bed7f3dda321df4650c4a498220533c62988f2c7
child 744362 9b16c807671b2005329445a3cec61fe9d5086536
push id93674
push userbmo:sheehan@mozilla.com
push dateWed, 20 Dec 2017 15:54:31 +0000
reviewersgps
bugs1424386
milestone59.0a1
Bug 1424386: Update robustcheckout in m-c with latest version from v-c-t r?gps MozReview-Commit-ID: Lryc4SGlg1y
testing/mozharness/external_tools/robustcheckout.py
--- a/testing/mozharness/external_tools/robustcheckout.py
+++ b/testing/mozharness/external_tools/robustcheckout.py
@@ -32,28 +32,44 @@ from mercurial import (
     cmdutil,
     hg,
     match as matchmod,
     registrar,
     scmutil,
     util,
 )
 
-testedwith = '3.7 3.8 3.9 4.0 4.1 4.2 4.3'
+# TRACKING hg43
+try:
+    from mercurial import configitems
+except ImportError:
+    configitems = None
+
+testedwith = '3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4'
 minimumhgversion = '3.7'
 
 cmdtable = {}
 
-# Mercurial 4.3 introduced registrar.command as a replacement for
+# TRACKING hg43 Mercurial 4.3 introduced registrar.command as a replacement for
 # cmdutil.command.
 if util.safehasattr(registrar, 'command'):
     command = registrar.command(cmdtable)
 else:
     command = cmdutil.command(cmdtable)
 
+# TRACKING hg43 Mercurial 4.3 introduced the config registrar. 4.4 requires
+# config items to be registered to avoid a devel warning
+if util.safehasattr(registrar, 'configitem'):
+    configtable = {}
+    configitem = registrar.configitem(configtable)
+
+    configitem('robustcheckout', 'retryjittermin', default=configitems.dynamicdefault)
+    configitem('robustcheckout', 'retryjittermax', default=configitems.dynamicdefault)
+
+
 # Mercurial 4.2 introduced the vfs module and deprecated the symbol in
 # scmutil.
 def getvfs():
     try:
         from mercurial.vfs import vfs
         return vfs
     except ImportError:
         return scmutil.vfs
@@ -201,19 +217,19 @@ def robustcheckout(ui, url, dest, upstre
 
     # Sparse profile support was added in Mercurial 4.3, where it was highly
     # experimental. Because of the fragility of it, we only support sparse
     # profiles on 4.3. When 4.4 is released, we'll need to opt in to sparse
     # support. We /could/ silently fall back to non-sparse when not supported.
     # However, given that sparse has performance implications, we want to fail
     # fast if we can't satisfy the desired checkout request.
     if sparseprofile:
-        if util.versiontuple(n=2) != (4, 3):
+        if util.versiontuple(n=2) not in ((4, 3), (4, 4)):
             raise error.Abort('sparse profile support only available for '
-                              'Mercurial 4.3 (using %s)' % util.version())
+                              'Mercurial versions greater than 4.3 (using %s)' % util.version())
 
         try:
             extensions.find('sparse')
         except KeyError:
             raise error.Abort('sparse extension must be enabled to use '
                               '--sparseprofile')
 
     ui.warn('(using Mercurial %s)\n' % util.version())
@@ -540,17 +556,17 @@ def _docheckout(ui, url, dest, upstream,
         purgeext = extensions.find('purge')
 
         # Mercurial 4.3 doesn't purge files outside the sparse checkout.
         # See https://bz.mercurial-scm.org/show_bug.cgi?id=5626. Force
         # purging by monkeypatching the sparse matcher.
         try:
             old_sparse_fn = getattr(repo.dirstate, '_sparsematchfn', None)
             if old_sparse_fn is not None:
-                assert util.versiontuple(n=2) == (4, 3)
+                assert util.versiontuple(n=2) in ((4, 3), (4, 4))
                 repo.dirstate._sparsematchfn = lambda: matchmod.always(repo.root, '')
 
             if purgeext.purge(ui, repo, all=True, abort_on_err=True,
                               # The function expects all arguments to be
                               # defined.
                               **{'print': None, 'print0': None, 'dirs': None,
                                  'files': None}):
                 raise error.Abort('error purging')