changeset 205:f6d29dc3fe8f

Check that a configuration file that can be read from is really tracked
author Franz Glasner <hg@dom66.de>
date Sun, 14 Oct 2018 22:05:29 +0200
parents 948a26a4a6f3
children 057b33f9c8a5
files extensions/timestamps.py
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/extensions/timestamps.py	Sun Oct 14 22:03:37 2018 +0200
+++ b/extensions/timestamps.py	Sun Oct 14 22:05:29 2018 +0200
@@ -197,7 +197,8 @@
     #
     # NOTE: no need for a local repo here
     #
-    matcher = gen_matcher(repo, ctx, tsconfig=tsconfig)
+    matcher = gen_matcher(repo, ctx, tsconfig=tsconfig) \
+                                               or match.never(repo.root, '')
     ts = Timestamps.from_ctx(ctx, ui, name=TIMESTAMPS_DATABASE)
     if ts is None:
         raise error.Abort(_("timestamps database file does not exist"))
@@ -255,7 +256,15 @@
         except (error.ManifestLookupError, IOError):
             pass
         else:
-            configname = TIMESTAMPS_CONFIGFILE
+            # check whether the existing configuration file is really tracked
+            fstatus = ctx.status(
+                match=match.exact(repo.root, '', [TIMESTAMPS_CONFIGFILE]),
+                listclean=True)
+            if fstatus.modified or fstatus.added or fstatus.clean:
+                configname = TIMESTAMPS_CONFIGFILE
+            else:
+                repo.ui.debug("timestamps configuration file found"
+                              " but not tracked\n")
 
     if configname is None:
         repo.ui.debug("no timestamps configuration file `%s' found\n"