Show More
@@ -576,30 +576,30 b' class _containsnode(object):' | |||
|
576 | 576 | def __contains__(self, node): |
|
577 | 577 | return self._revcontains(self._torev(node)) |
|
578 | 578 | |
|
579 |
def cleanupnodes(repo, |
|
|
579 | def cleanupnodes(repo, replacements, operation): | |
|
580 | 580 | """do common cleanups when old nodes are replaced by new nodes |
|
581 | 581 | |
|
582 | 582 | That includes writing obsmarkers or stripping nodes, and moving bookmarks. |
|
583 | 583 | (we might also want to move working directory parent in the future) |
|
584 | 584 | |
|
585 |
|
|
|
586 | replacements. operation is a string, like "rebase". | |
|
585 | replacements is {oldnode: [newnode]} or a iterable of nodes if they do not | |
|
586 | have replacements. operation is a string, like "rebase". | |
|
587 | 587 | """ |
|
588 |
if not util.safehasattr( |
|
|
589 |
|
|
|
588 | if not util.safehasattr(replacements, 'items'): | |
|
589 | replacements = {n: () for n in replacements} | |
|
590 | 590 | |
|
591 | 591 | # Calculate bookmark movements |
|
592 | 592 | moves = {} |
|
593 |
# Unfiltered repo is needed since nodes in |
|
|
593 | # Unfiltered repo is needed since nodes in replacements might be hidden. | |
|
594 | 594 | unfi = repo.unfiltered() |
|
595 |
for oldnode, newnodes in |
|
|
595 | for oldnode, newnodes in replacements.items(): | |
|
596 | 596 | if len(newnodes) > 1: |
|
597 | 597 | # usually a split, take the one with biggest rev number |
|
598 | 598 | newnode = next(unfi.set('max(%ln)', newnodes)).node() |
|
599 | 599 | elif len(newnodes) == 0: |
|
600 | 600 | # move bookmark backwards |
|
601 | 601 | roots = list(unfi.set('max((::%n) - %ln)', oldnode, |
|
602 |
list( |
|
|
602 | list(replacements))) | |
|
603 | 603 | if roots: |
|
604 | 604 | newnode = roots[0].node() |
|
605 | 605 | else: |
@@ -612,7 +612,7 b' def cleanupnodes(repo, mapping, operatio' | |||
|
612 | 612 | # Move bookmarks |
|
613 | 613 | bmarks = repo._bookmarks |
|
614 | 614 | bmarkchanges = [] |
|
615 |
allnewnodes = [n for ns in |
|
|
615 | allnewnodes = [n for ns in replacements.values() for n in ns] | |
|
616 | 616 | for oldnode, newnode in moves.items(): |
|
617 | 617 | oldbmarks = repo.nodebookmarks(oldnode) |
|
618 | 618 | if not oldbmarks: |
@@ -644,12 +644,12 b' def cleanupnodes(repo, mapping, operatio' | |||
|
644 | 644 | torev = unfi.changelog.rev |
|
645 | 645 | sortfunc = lambda ns: torev(ns[0]) |
|
646 | 646 | rels = [(unfi[n], tuple(unfi[m] for m in s)) |
|
647 |
for n, s in sorted( |
|
|
647 | for n, s in sorted(replacements.items(), key=sortfunc) | |
|
648 | 648 | if s or not isobs(n)] |
|
649 | 649 | obsolete.createmarkers(repo, rels, operation=operation) |
|
650 | 650 | else: |
|
651 | 651 | from . import repair # avoid import cycle |
|
652 |
repair.delayedstrip(repo.ui, repo, list( |
|
|
652 | repair.delayedstrip(repo.ui, repo, list(replacements), operation) | |
|
653 | 653 | |
|
654 | 654 | def addremove(repo, matcher, prefix, opts=None, dry_run=None, similarity=None): |
|
655 | 655 | if opts is None: |
General Comments 0
You need to be logged in to leave comments.
Login now