robustcheckout: support Mercurial 4.3; r?glob draft
authorGregory Szorc <gps@mozilla.com>
Mon, 07 Aug 2017 17:28:36 -0700
changeset 11520 daec6f3f5527d252fbbebb080d7962816f98edf1
parent 11515 4a68c88638b003644c6ce6b085b44beb9fe76b07
child 11521 298cede9904a6469f8e33986e4afea5bd0884226
push id1757
push userbmo:gps@mozilla.com
push dateMon, 14 Aug 2017 23:57:42 +0000
reviewersglob
robustcheckout: support Mercurial 4.3; r?glob The old code worked fine. However, a developer warning is being issued due to the deprecation of cmdutil.command() in favor of registrar.command(). Porting is trivial. registrar.py was introduced in Mercurial 3.7. So it should import everywhere where the extension is supported. MozReview-Commit-ID: 25jmdh9l0N8
hgext/robustcheckout/__init__.py
--- a/hgext/robustcheckout/__init__.py
+++ b/hgext/robustcheckout/__init__.py
@@ -26,26 +26,32 @@ from mercurial.i18n import _
 from mercurial.node import hex
 from mercurial import (
     commands,
     error,
     exchange,
     extensions,
     cmdutil,
     hg,
+    registrar,
     scmutil,
     util,
 )
 
-testedwith = '3.7 3.8 3.9 4.0 4.1 4.2'
+testedwith = '3.7 3.8 3.9 4.0 4.1 4.2 4.3'
 minimumhgversion = '3.7'
 
 cmdtable = {}
-command = cmdutil.command(cmdtable)
 
+# 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)
 
 # 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: