diff mercurial/localrepo.py @ 34710:cdf833d7de98

phase: add a dedicated txnclose-phase hook The new 'txnclose-phase' hook expose the phase movement information stored in 'tr.changes['phases]'. To provide a simple and straightforward hook API to the users, we introduce a new hook called for each revision affected. Since a transaction can affect the phase of multiple changesets, updating the existing 'txnclose' hook to expose that information would be more complex. The data for all moves will not fit in environment variables and iterations over each move would be cumbersome. So the introduction of a new dedicated hook is preferred in this changesets. This does not exclude the addition of the full phase movement information to the existing 'txnclose' in the future to help write more complex hooks.
author Boris Feld <boris.feld@octobus.net>
date Sun, 08 Oct 2017 17:50:46 +0200
parents c212947273a7
children f6d17075608f
line wrap: on
line diff
--- a/mercurial/localrepo.py	Sun Oct 08 18:50:14 2017 +0200
+++ b/mercurial/localrepo.py	Sun Oct 08 17:50:46 2017 +0200
@@ -1299,6 +1299,16 @@
                         repo.hook('txnclose-bookmark', throw=False,
                                   txnname=desc, **pycompat.strkwargs(args))
 
+                if hook.hashook(repo.ui, 'txnclose-phase'):
+                    cl = repo.unfiltered().changelog
+                    phasemv = sorted(tr.changes['phases'].items())
+                    for rev, (old, new) in phasemv:
+                        args = tr.hookargs.copy()
+                        node = hex(cl.node(rev))
+                        args.update(phases.preparehookargs(node, old, new))
+                        repo.hook('txnclose-phase', throw=False, txnname=desc,
+                                  **pycompat.strkwargs(args))
+
                 repo.hook('txnclose', throw=False, txnname=desc,
                           **pycompat.strkwargs(hookargs))
             reporef()._afterlock(hookfunc)