Mercurial > public > mercurial-scm > hg-stable
comparison 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 |
comparison
equal
deleted
inserted
replaced
34709:c212947273a7 | 34710:cdf833d7de98 |
---|---|
1297 args = tr.hookargs.copy() | 1297 args = tr.hookargs.copy() |
1298 args.update(bookmarks.preparehookargs(name, old, new)) | 1298 args.update(bookmarks.preparehookargs(name, old, new)) |
1299 repo.hook('txnclose-bookmark', throw=False, | 1299 repo.hook('txnclose-bookmark', throw=False, |
1300 txnname=desc, **pycompat.strkwargs(args)) | 1300 txnname=desc, **pycompat.strkwargs(args)) |
1301 | 1301 |
1302 if hook.hashook(repo.ui, 'txnclose-phase'): | |
1303 cl = repo.unfiltered().changelog | |
1304 phasemv = sorted(tr.changes['phases'].items()) | |
1305 for rev, (old, new) in phasemv: | |
1306 args = tr.hookargs.copy() | |
1307 node = hex(cl.node(rev)) | |
1308 args.update(phases.preparehookargs(node, old, new)) | |
1309 repo.hook('txnclose-phase', throw=False, txnname=desc, | |
1310 **pycompat.strkwargs(args)) | |
1311 | |
1302 repo.hook('txnclose', throw=False, txnname=desc, | 1312 repo.hook('txnclose', throw=False, txnname=desc, |
1303 **pycompat.strkwargs(hookargs)) | 1313 **pycompat.strkwargs(hookargs)) |
1304 reporef()._afterlock(hookfunc) | 1314 reporef()._afterlock(hookfunc) |
1305 tr.addfinalize('txnclose-hook', txnclosehook) | 1315 tr.addfinalize('txnclose-hook', txnclosehook) |
1306 tr.addpostclose('warms-cache', self._buildcacheupdater(tr)) | 1316 tr.addpostclose('warms-cache', self._buildcacheupdater(tr)) |