diff extensions/revinfo.py @ 326:26e617693ae8

FIX: kwarchive and revinfo do not run on versions prior to Mercurial 4.3 after testing this with unit-tests
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 04 Mar 2019 23:12:13 +0100
parents e9ded6c1db41
children 56f2020b8b9e
line wrap: on
line diff
--- a/extensions/revinfo.py	Thu Feb 21 00:13:56 2019 +0100
+++ b/extensions/revinfo.py	Mon Mar 04 23:12:13 2019 +0100
@@ -20,22 +20,28 @@
 
 
 from mercurial.i18n import _
-from mercurial import cmdutil, scmutil, util, error, archival, pycompat
-try:
-    from mercurial import registrar
-except ImportError:
-    registrar = None
+from mercurial import (cmdutil, scmutil, util, error, archival, pycompat,
+                       demandimport)
+with demandimport.deactivated():
+    _reenable_demandimport = False
+    if demandimport.isenabled():
+        demandimport.disable()
+        _reenable_demandimport = True
+    try:
+        from mercurial import registrar
+    except ImportError:
+        registrar = None
 
 
 cmdtable = {}
 
-if registrar:
+if registrar and hasattr(registrar, "command"):
     command = registrar.command(cmdtable)
 else:
     command = cmdutil.command(cmdtable)
 
 
-testedwith = "3.5 3.5.1 3.5.2 4.3.1 4.3.2 4.4.1 4.4.2 4.5.2 4.6.1 4.8.1 4.9"
+testedwith = "4.3.1 4.3.2 4.4.1 4.4.2 4.5.2 4.6.1 4.8.1 4.9"
 
 
 def getversion():