Mercurial > public > mercurial-scm > hg
comparison mercurial/obsutil.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 | 9d2b2df2c2ba |
children | 89a2afe31e82 |
comparison
equal
deleted
inserted
replaced
45074:797ef6f8295e | 45075:04ef381000a8 |
---|---|
11 | 11 |
12 from .i18n import _ | 12 from .i18n import _ |
13 from . import ( | 13 from . import ( |
14 diffutil, | 14 diffutil, |
15 encoding, | 15 encoding, |
16 error, | |
16 node as nodemod, | 17 node as nodemod, |
17 phases, | 18 phases, |
18 pycompat, | 19 pycompat, |
19 util, | 20 util, |
20 ) | 21 ) |
479 effects |= DIFFCHANGED | 480 effects |= DIFFCHANGED |
480 | 481 |
481 return effects | 482 return effects |
482 | 483 |
483 | 484 |
484 def getobsoleted(repo, tr): | 485 def getobsoleted(repo, tr=None, changes=None): |
485 """return the set of pre-existing revisions obsoleted by a transaction""" | 486 """return the set of pre-existing revisions obsoleted by a transaction |
487 | |
488 Either the transaction or changes item of the transaction (for hooks) | |
489 must be provided, but not both. | |
490 """ | |
491 if (tr is None) == (changes is None): | |
492 e = b"exactly one of tr and changes must be provided" | |
493 raise error.ProgrammingError(e) | |
486 torev = repo.unfiltered().changelog.index.get_rev | 494 torev = repo.unfiltered().changelog.index.get_rev |
487 phase = repo._phasecache.phase | 495 phase = repo._phasecache.phase |
488 succsmarkers = repo.obsstore.successors.get | 496 succsmarkers = repo.obsstore.successors.get |
489 public = phases.public | 497 public = phases.public |
490 addedmarkers = tr.changes[b'obsmarkers'] | 498 if changes is None: |
491 origrepolen = tr.changes[b'origrepolen'] | 499 changes = tr.changes |
500 addedmarkers = changes[b'obsmarkers'] | |
501 origrepolen = changes[b'origrepolen'] | |
492 seenrevs = set() | 502 seenrevs = set() |
493 obsoleted = set() | 503 obsoleted = set() |
494 for mark in addedmarkers: | 504 for mark in addedmarkers: |
495 node = mark[0] | 505 node = mark[0] |
496 rev = torev(node) | 506 rev = torev(node) |