Mercurial > hgrepos > DevTools > mercurial-extensions
changeset 209:b078d3a02205
Write the timestamps database add add it as tracked file if needed when committing
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Tue, 16 Oct 2018 09:32:39 +0200 |
| parents | 99a1f7a1aec8 |
| children | aea0875c48e7 |
| files | extensions/timestamps.py |
| diffstat | 1 files changed, 26 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/extensions/timestamps.py Mon Oct 15 09:40:37 2018 +0200 +++ b/extensions/timestamps.py Tue Oct 16 09:32:39 2018 +0200 @@ -68,8 +68,8 @@ import re from mercurial.i18n import _ -from mercurial import (cmdutil, scmutil, config, util, error, match, - pycompat) +from mercurial import (cmdutil, scmutil, config, util, error, pycompat) +from mercurial import match as _matchmod cmdtable = {} @@ -198,7 +198,7 @@ # NOTE: no need for a local repo here # matcher = gen_matcher(repo, ctx, tsconfig=tsconfig) \ - or match.never(repo.root, '') + or _matchmod.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")) @@ -258,7 +258,7 @@ else: # check whether the existing configuration file is really tracked fstatus = ctx.status( - match=match.exact(repo.root, '', [TIMESTAMPS_CONFIGFILE]), + match=_matchmod.exact(repo.root, '', [TIMESTAMPS_CONFIGFILE]), listclean=True) if fstatus.modified or fstatus.added or fstatus.clean: configname = TIMESTAMPS_CONFIGFILE @@ -291,17 +291,17 @@ # # NOTE: an empty patterns list means: match always # - matcher = match.match(repo.root, - "", - patterns=patterns, - include=include, - exclude=include) + matcher = _matchmod.match(repo.root, + "", + patterns=patterns, + include=include, + exclude=include) else: # per default: match all files but not file starting with ".hg" - matcher = match.match(repo.root, - "", - patterns=["**"], - exclude=[".hg*"]) + matcher = _matchmod.match(repo.root, + "", + patterns=["**"], + exclude=[".hg*"]) return matcher @@ -694,6 +694,19 @@ # match: "hg ci" -> alwaysmatcher # "hg ci file1 ... -> patternmatcher with the files # + + with io.open(self.wjoin(TIMESTAMPS_DATABASE), "wb") as fp: + ts.write(fp) + # check whether the database file is really tracked + dbstatus = wctx.status( + match=_matchmod.exact(self.root, '', [TIMESTAMPS_DATABASE]), + listclean=True) + if dbstatus.modified or dbstatus.added or dbstatus.clean: + # already tracked + pass + else: + wctx.add([TIMESTAMPS_DATABASE]) + # XXX TBD: add the database to `match` else: self.ui.debug("TimestampedRepo.commit():" " timestamps not activated/configured\n")
