Mercurial > hgrepos > DevTools > mercurial-extensions
diff extensions/kwarchive.py @ 307:f8aa592b344e
FIX: Mercurial's "demandimport" defeats the "try: import ...; except ImportError" idiom; temporarily disable demandimport before doing such imports in kwarchive
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Wed, 30 Jan 2019 20:56:59 +0100 |
| parents | 71288cb43ba9 |
| children | 6932e63311c4 |
line wrap: on
line diff
--- a/extensions/kwarchive.py Wed Jan 30 11:13:30 2019 +0100 +++ b/extensions/kwarchive.py Wed Jan 30 20:56:59 2019 +0100 @@ -89,24 +89,32 @@ from mercurial.i18n import _ from mercurial import (archival, config, cmdutil, error, match, subrepo, pycompat, scmutil, templatefilters, templatekw, - util, node) -try: - from mercurial import registrar -except ImportError: - registrar = None -# check for new template function API with `(context, mapping)` + util, node, demandimport) try: - from mercurial import templatefuncs -except ImportError: - context_mapping_api = False -else: - # >= 4.6 - context_mapping_api = True -# some date specific util functions moved to new mercurial.utils.dateutil -try: - from mercurial.utils import dateutil as _dateutil -except ImportError: - _dateutil = util + _reenable_demandimport = False + if demandimport.isenabled(): + demandimport.disable() + _reenable_demandimport = True + try: + from mercurial import registrar + except ImportError: + registrar = None + # check for new template function API with `(context, mapping)` + try: + from mercurial import templatefuncs + except ImportError: + context_mapping_api = False + else: + # >= 4.6 + context_mapping_api = True + # some date specific util functions moved to new mercurial.utils.dateutil + try: + 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"
