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