comparison hgext/hooklib/changeset_obsoleted.py @ 45076: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
comparison
equal deleted inserted replaced
45075:797ef6f8295e 45076:04ef381000a8
120 mail.sendmail( 120 mail.sendmail(
121 ui, emailutils.parseaddr(msg['From'])[1], subs, msgtext, mbox=n.mbox 121 ui, emailutils.parseaddr(msg['From'])[1], subs, msgtext, mbox=n.mbox
122 ) 122 )
123 123
124 124
125 def has_successor(repo, rev):
126 return any(
127 r for r in obsutil.allsuccessors(repo.obsstore, [rev]) if r != rev
128 )
129
130
125 def hook(ui, repo, hooktype, node=None, **kwargs): 131 def hook(ui, repo, hooktype, node=None, **kwargs):
126 if hooktype != b"pretxnclose": 132 if hooktype != b"txnclose":
127 raise error.Abort( 133 raise error.Abort(
128 _(b'Unsupported hook type %r') % pycompat.bytestr(hooktype) 134 _(b'Unsupported hook type %r') % pycompat.bytestr(hooktype)
129 ) 135 )
130 for rev in obsutil.getobsoleted(repo, repo.currenttransaction()): 136 for rev in obsutil.getobsoleted(repo, changes=kwargs['changes']):
131 _report_commit(ui, repo, repo.unfiltered()[rev]) 137 ctx = repo.unfiltered()[rev]
138 if not has_successor(repo, ctx.node()):
139 _report_commit(ui, repo, ctx)