Skip to content
Snippets Groups Projects
Commit 2dbd6d259cd2 authored by Martin von Zweigbergk's avatar Martin von Zweigbergk
Browse files

cleanupnodes: rename "mapping" to "replacements"

The next patch will pass in overrides for bookmark moves, which is a
mapping itself, so let's rename "mapping" to "replacements" to
distinguish them better.

Differential Revision: https://phab.mercurial-scm.org/D749
parent 033a5befbaf7
No related branches found
No related tags found
No related merge requests found
......@@ -576,9 +576,9 @@
def __contains__(self, node):
return self._revcontains(self._torev(node))
def cleanupnodes(repo, mapping, operation):
def cleanupnodes(repo, replacements, operation):
"""do common cleanups when old nodes are replaced by new nodes
That includes writing obsmarkers or stripping nodes, and moving bookmarks.
(we might also want to move working directory parent in the future)
......@@ -580,8 +580,8 @@
"""do common cleanups when old nodes are replaced by new nodes
That includes writing obsmarkers or stripping nodes, and moving bookmarks.
(we might also want to move working directory parent in the future)
mapping is {oldnode: [newnode]} or a iterable of nodes if they do not have
replacements. operation is a string, like "rebase".
replacements is {oldnode: [newnode]} or a iterable of nodes if they do not
have replacements. operation is a string, like "rebase".
"""
......@@ -587,6 +587,6 @@
"""
if not util.safehasattr(mapping, 'items'):
mapping = {n: () for n in mapping}
if not util.safehasattr(replacements, 'items'):
replacements = {n: () for n in replacements}
# Calculate bookmark movements
moves = {}
......@@ -590,5 +590,5 @@
# Calculate bookmark movements
moves = {}
# Unfiltered repo is needed since nodes in mapping might be hidden.
# Unfiltered repo is needed since nodes in replacements might be hidden.
unfi = repo.unfiltered()
......@@ -594,8 +594,8 @@
unfi = repo.unfiltered()
for oldnode, newnodes in mapping.items():
for oldnode, newnodes in replacements.items():
if len(newnodes) > 1:
# usually a split, take the one with biggest rev number
newnode = next(unfi.set('max(%ln)', newnodes)).node()
elif len(newnodes) == 0:
# move bookmark backwards
roots = list(unfi.set('max((::%n) - %ln)', oldnode,
......@@ -596,10 +596,10 @@
if len(newnodes) > 1:
# usually a split, take the one with biggest rev number
newnode = next(unfi.set('max(%ln)', newnodes)).node()
elif len(newnodes) == 0:
# move bookmark backwards
roots = list(unfi.set('max((::%n) - %ln)', oldnode,
list(mapping)))
list(replacements)))
if roots:
newnode = roots[0].node()
else:
......@@ -612,7 +612,7 @@
# Move bookmarks
bmarks = repo._bookmarks
bmarkchanges = []
allnewnodes = [n for ns in mapping.values() for n in ns]
allnewnodes = [n for ns in replacements.values() for n in ns]
for oldnode, newnode in moves.items():
oldbmarks = repo.nodebookmarks(oldnode)
if not oldbmarks:
......@@ -644,8 +644,8 @@
torev = unfi.changelog.rev
sortfunc = lambda ns: torev(ns[0])
rels = [(unfi[n], tuple(unfi[m] for m in s))
for n, s in sorted(mapping.items(), key=sortfunc)
for n, s in sorted(replacements.items(), key=sortfunc)
if s or not isobs(n)]
obsolete.createmarkers(repo, rels, operation=operation)
else:
from . import repair # avoid import cycle
......@@ -648,8 +648,8 @@
if s or not isobs(n)]
obsolete.createmarkers(repo, rels, operation=operation)
else:
from . import repair # avoid import cycle
repair.delayedstrip(repo.ui, repo, list(mapping), operation)
repair.delayedstrip(repo.ui, repo, list(replacements), operation)
def addremove(repo, matcher, prefix, opts=None, dry_run=None, similarity=None):
if opts is None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment