# HG changeset patch # User Franz Glasner # Date 1551738568 -3600 # Node ID 655dd5b0bcd34b54edeb4ca08f461600a7032821 # Parent a0cfd90149d0121a0a39bb2f0f9e75eb9aa2d85a Make more robust: deactivate Mercurial's demandimport when trying to import registrar diff -r a0cfd90149d0 -r 655dd5b0bcd3 extensions/timestamps.py --- a/extensions/timestamps.py Sat Mar 02 11:51:36 2019 +0100 +++ b/extensions/timestamps.py Mon Mar 04 23:29:28 2019 +0100 @@ -77,13 +77,15 @@ import time from mercurial.i18n import _ -from mercurial import (cmdutil, scmutil, config, util, error, pycompat) +from mercurial import (cmdutil, scmutil, config, util, error, pycompat, + demandimport) from mercurial import match as _matchmod from mercurial import merge as _mergemod -try: - from mercurial import registrar -except ImportError: - registrar = None +with demandimport.deactivated(): + try: + from mercurial import registrar + except ImportError: + registrar = None TIMESTAMPS_CONFIGFILE = ".hgtimestamps" @@ -95,7 +97,6 @@ _DEV = True - _noobj = object() _conflictobj = object() @@ -487,8 +488,8 @@ raise error.Abort(_("repository is not local")) cmdutil.checkunfinished(repo) cmdutil.bailifchanged(repo) - matcher = _gen_matcher_from_tsconfig(ctx, tsconfig=tsconfig, ui=ui) - if matcher is None: + tsconfmatch = _gen_matcher_from_tsconfig(ctx, tsconfig=tsconfig, ui=ui) + if tsconfmatch is None: raise error.Abort(_("timestamps are not activated/configured")) if destdir is None: ts = _Timestamps.from_filename(ui, name=repo.wjoin(TIMESTAMPS_DATABASE)) @@ -496,7 +497,7 @@ ts = _Timestamps.from_ctx(ctx, ui) if ts is None: raise error.Abort(_("timestamps database file does not exist")) - _do_restore_timestamps(repo, ctx, matcher, ts, ui=ui, destdir=destdir) + _do_restore_timestamps(repo, ctx, tsconfmatch, ts, ui=ui, destdir=destdir) def _show_timestamps(ui, ctx, pats, formatter,