# HG changeset patch # User Franz Glasner # Date 1540280215 -7200 # Node ID 6d3d39aaaed9b33cedeeea54a1162fc4090401ae # Parent 097d08017d784ae41c63ff87919f3cf2fb57382a Implemented the post-revert hook completely diff -r 097d08017d78 -r 6d3d39aaaed9 extensions/timestamps.py --- a/extensions/timestamps.py Mon Oct 22 14:41:39 2018 +0200 +++ b/extensions/timestamps.py Tue Oct 23 09:36:55 2018 +0200 @@ -743,9 +743,35 @@ def post_hook(ui, repo, hooktype, **kwds): + """Generic post-xxx hook: just forward to the `hooktype` related + implementations. + + This generic dispatcher hook simplifies configuration. + + """ ui.debug("POST HOOK: " + hooktype + '\n') ui.debug("POST HOOK: " + repr(kwds) + '\n') + if hooktype == "post-revert": + if not repo.local(): + return + wctx = repo[None] + matcher = gen_matcher(repo, wctx) + if matcher is None: + return + ts = Timestamps.from_filename(ui, name=repo.wjoin(TIMESTAMPS_DATABASE)) + if ts is None: + return + ui.note(_("restoring timestamps\n")) + opts = kwds.get("opts") + if opts.get("all"): + candidates = wctx + else: + # the same as in revert's implementation in `cmdutil.revert` + patterns = scmutil.match(wctx, kwds.get("pats"), opts=opts) + candidates = wctx.walk(patterns) + _restore_timestamps(repo, candidates, matcher, ts) + def update_hook(ui, repo, hooktype, **kwds): if _DEV: @@ -886,6 +912,7 @@ if not self.__hooktype or self.__hooktype != "pre-update": self.ui.warn("timestamps: no recorded update hook data\n") return + self.ui.note(_("restoring timestamps\n")) wctx = self[None] tsmatch = gen_matcher(self, wctx) if tsmatch is not None: