Mercurial > hgrepos > DevTools > mercurial-extensions
changeset 372:79192d0078dc
Provide a "pats" (patterns) argument to _do_restore_timestamps() to be used for FILE parameters given on the command line.
"pats" are used for filtering too. It could be implemented by giving an
intersectmater to the given matcher parameter.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Tue, 05 Mar 2019 16:23:40 +0100 |
| parents | 655dd5b0bcd3 |
| children | 1b65516842ca |
| files | extensions/timestamps.py |
| diffstat | 1 files changed, 26 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/extensions/timestamps.py Mon Mar 04 23:29:28 2019 +0100 +++ b/extensions/timestamps.py Tue Mar 05 16:23:40 2019 +0100 @@ -240,7 +240,7 @@ # the same as in revert's implementation in `cmdutil.revert` patterns = scmutil.match(wctx, kwds.get("pats"), opts=opts) candidates = wctx.walk(patterns) - _do_restore_timestamps(repo, candidates, tsconfmatch, ts, ui=ui) + _do_restore_timestamps(repo, candidates, None, tsconfmatch, ts, ui=ui) elif hooktype == "post-resolve": wctx = repo[None] tsconfmatch = _gen_matcher_from_tsconfig(wctx, ui=ui) @@ -448,7 +448,7 @@ if _DEV: self.ui.debug("UPDATE TO_UPDATE w/o resolved: " + repr(to_update) + '\n') - _do_restore_timestamps(self, to_update, tsconfmatch, ts, + _do_restore_timestamps(self, to_update, None, tsconfmatch, ts, allow_other_region=allow_other_region) repo.__class__ = TimestampedRepo @@ -497,7 +497,8 @@ ts = _Timestamps.from_ctx(ctx, ui) if ts is None: raise error.Abort(_("timestamps database file does not exist")) - _do_restore_timestamps(repo, ctx, tsconfmatch, ts, ui=ui, destdir=destdir) + _do_restore_timestamps(repo, ctx, None, tsconfmatch, ts, + ui=ui, destdir=destdir) def _show_timestamps(ui, ctx, pats, formatter, @@ -1162,13 +1163,15 @@ yield i -def _do_restore_timestamps(repo, candidates, tsconfmatch, tsdb, +def _do_restore_timestamps(repo, candidates, pats, tsconfmatch, tsdb, destdir=None, ui=None, alt=None, allow_other_region=False): """Restore file timestamps of files in iterable `candidates` that match `tsconfmatch` to the times in database `tsdb`. + `pats` are FILES from the command line are are (if not `None`) used + to filter the `candidates` too. If `alt` is given and one of "base", "local", "other" try to find a timestamp value from this merge conflict region if there is one. If `allow_other_region` is true then a timestamp value is allowed to be @@ -1180,25 +1183,26 @@ ui = ui or repo.ui with _FloatTimesInStat(): for f in candidates: - if tsconfmatch(f): - if allow_other_region: - mtime = tsdb.getone(f, ui=ui) - else: - mtime = tsdb.getalt(f, alt) - if mtime is not None: - mt = calendar.timegm(_dt_from_isoformat(mtime).timetuple()) - if destdir is None: - real_fname = repo.wjoin(f) - visu_fname = f + if (pats is None) or pats(f): + if tsconfmatch(f): + if allow_other_region: + mtime = tsdb.getone(f, ui=ui) else: - real_fname = visu_fname = os.path.join(destdir, f) - if _DEV: - ui.debug("RESTORING TIMESTAMP: " + visu_fname + ' -> ' - + mtime + '\n') - try: - os.utime(real_fname, (time.time(), mt)) - except IOError: - ui.warn(_("cannot set mtime for file: %s") % real_fname) + mtime = tsdb.getalt(f, alt) + if mtime is not None: + mt = calendar.timegm(_dt_from_isoformat(mtime).timetuple()) + if destdir is None: + real_fname = repo.wjoin(f) + visu_fname = f + else: + real_fname = visu_fname = os.path.join(destdir, f) + if _DEV: + ui.debug("RESTORING TIMESTAMP: " + visu_fname + ' -> ' + + mtime + '\n') + try: + os.utime(real_fname, (time.time(), mt)) + except IOError: + ui.warn(_("cannot set mtime for file: %s") % real_fname) def _debug_mergestate(ui, ms):
