# HG changeset patch # User Franz Glasner # Date 1535615228 -7200 # Node ID ffe20b7d21c48b791b5830df2afa46b871b5a717 # Parent a6a739ed3d052981a895ed6477444aa0c51bd37f Some tests with matching and ISO formatting diff -r a6a739ed3d05 -r ffe20b7d21c4 extensions/timestamps.py --- a/extensions/timestamps.py Thu Aug 30 00:58:29 2018 +0200 +++ b/extensions/timestamps.py Thu Aug 30 09:47:08 2018 +0200 @@ -38,6 +38,8 @@ * optional second non-comment line: :encoding: ENCODING + * timestamp in ISOFORMAT (``YYYY-MM-DDTHH:MM:SS.mmmmmm+HH:MM``) + (This is roughly simalar to a Perforce checkpoint.) - Otherwise mostly modelled after TimestampMod @@ -54,7 +56,9 @@ __author__ = "Franz Glasner" +import os import io +import datetime from mercurial.i18n import _ from mercurial import (cmdutil, scmutil, config, util, error, match, @@ -129,7 +133,9 @@ raise error.Abort(_("repository is not local")) matcher = gen_matcher(repo, ctx, tsconfig=tsconfig) for fn in ctx: - print fn, matcher(fn) + if matcher(fn): + st = os.lstat(fn) + print (fn, st, st.st_mtime, to_isoformat(st.st_mtime)) def restore_timestamps(ui, repo, ctx, @@ -182,3 +188,11 @@ patterns=["**"], exclude=[".hg*"]) return matcher + + +def to_isoformat(t): + dt = datetime.datetime.utcfromtimestamp(t) + if dt.utcoffset() is None: + return dt.isoformat() + "Z" + else: + return dt.isoformat()