changeset 129:95d229cc1165

7902610: Make jcheck tests work with Mercurial 4.3+ Reviewed-by: erikj, tbell
author ehelin
date Thu, 12 Mar 2020 12:47:01 +0100
parents c5506ce082b3
children 20acc53047cc
files jcheck_test.py
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/jcheck_test.py	Thu Jan 02 10:28:30 2020 +0100
+++ b/jcheck_test.py	Thu Mar 12 12:47:01 2020 +0100
@@ -27,6 +27,12 @@
 import sys, os, re, urllib, urllib2
 from mercurial.node import *
 from mercurial import cmdutil, patch, util, context, templater
+try:
+    # Mercurial 4.3 and higher
+    from mercurial import registrar
+except ImportError:
+    registrar = {}
+    pass
 
 # Extend the path so that we can import the jcheck extension itself
 sys.path.insert(0, os.path.dirname(__file__))
@@ -36,7 +42,9 @@
 # decorator. If this isn't available, fallback on a simple local implementation
 # that just adds the data to the cmdtable.
 cmdtable = {}
-if hasattr(cmdutil, 'command'):
+if hasattr(registrar, 'command'):
+    command = registrar.command(cmdtable)
+elif hasattr(cmdutil, 'command'):
     command = cmdutil.command(cmdtable)
 else:
     def command(name, options, synopsis):