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
--- 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: