Mercurial > hg
diff hgext/hooklib/changeset_obsoleted.py @ 45075:04ef381000a8
hooklib: fix detection of successors for changeset_obsoleted
Provide a hook for obsutil.getobsolete to be used with either a
transaction or the changes item of the transaction, since hooks only
have access to the latter. Use that to find the correct list of
revisions with obsmarkers, even new ones, and then filter out revisions
with known successors.
Move the processing from pretxnclose to txnclose as the transaction
access itself is no longer necessary. This is more in line with notify
and ensures that sanity checks can abort the transaction first.
Differential Revision: https://phab.mercurial-scm.org/D8575
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Thu, 21 May 2020 18:18:50 +0200 |
parents | 4cabeea6d214 |
children | 3c2fae87bd5a |
line wrap: on
line diff
--- a/hgext/hooklib/changeset_obsoleted.py Thu Jul 09 20:46:52 2020 -0700 +++ b/hgext/hooklib/changeset_obsoleted.py Thu May 21 18:18:50 2020 +0200 @@ -122,10 +122,18 @@ ) +def has_successor(repo, rev): + return any( + r for r in obsutil.allsuccessors(repo.obsstore, [rev]) if r != rev + ) + + def hook(ui, repo, hooktype, node=None, **kwargs): - if hooktype != b"pretxnclose": + if hooktype != b"txnclose": raise error.Abort( _(b'Unsupported hook type %r') % pycompat.bytestr(hooktype) ) - for rev in obsutil.getobsoleted(repo, repo.currenttransaction()): - _report_commit(ui, repo, repo.unfiltered()[rev]) + for rev in obsutil.getobsoleted(repo, changes=kwargs['changes']): + ctx = repo.unfiltered()[rev] + if not has_successor(repo, ctx.node()): + _report_commit(ui, repo, ctx)