diff extensions/kwarchive.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 950a9bd55d7e
children 56f2020b8b9e
line wrap: on
line diff
--- a/extensions/kwarchive.py	Thu Feb 21 00:13:56 2019 +0100
+++ b/extensions/kwarchive.py	Mon Mar 04 23:12:13 2019 +0100
@@ -95,7 +95,7 @@
 from mercurial import (archival, config, cmdutil, error, match, subrepo,
                        pycompat, scmutil, templatefilters, templatekw,
                        util, node, demandimport)
-try:
+with demandimport.deactivated():
     _reenable_demandimport = False
     if demandimport.isenabled():
         demandimport.disable()
@@ -117,9 +117,6 @@
         from mercurial.utils import dateutil as _dateutil
     except ImportError:
         _dateutil = util
-finally:
-    if _reenable_demandimport:
-        demandimport.enable()
 
 
 testedwith = "4.3.1 4.3.2 4.4.1 4.4.2 4.5.2 4.6.1 4.8.1 4.9"
@@ -138,7 +135,7 @@
 
 cmdtable = {}
 
-if registrar:
+if registrar and hasattr(registrar, "command"):
     command = registrar.command(cmdtable)
 else:
     command = cmdutil.command(cmdtable)