changeset 371:655dd5b0bcd3

Make more robust: deactivate Mercurial's demandimport when trying to import registrar
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 04 Mar 2019 23:29:28 +0100
parents a0cfd90149d0
children 79192d0078dc
files extensions/timestamps.py
diffstat 1 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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,