Mercurial > hgrepos > DevTools > mercurial-extensions
changeset 228:6d3d39aaaed9
Implemented the post-revert hook completely
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Tue, 23 Oct 2018 09:36:55 +0200 |
| parents | 097d08017d78 |
| children | d499ef3ce349 |
| files | extensions/timestamps.py |
| diffstat | 1 files changed, 27 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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:
