Commit b9fbc4f9 authored by Martin von Zweigbergk's avatar Martin von Zweigbergk
Browse files

compat: add a cleanupnodes() function

This first patch just makes it delegate to
scmutil.cleanupnodes(). Coming patches will add a bit more logic to
it.

--HG--
branch : stable
parent 6cd66a5bfb04
......@@ -170,8 +170,8 @@ def amendpatch(ui, repo, *pats, **opts):
if opts.get('note'):
metadata[b'note'] = opts['note']
replacements = {old.node(): [newnode]}
scmutil.cleanupnodes(repo, replacements, operation=b'amend',
metadata=metadata)
compat.cleanupnodes(repo, replacements, operation=b'amend',
metadata=metadata)
phases.retractboundary(repo, tr, old.phase(), [newnode])
hg.updaterepo(repo, newnode, True)
......@@ -509,8 +509,8 @@ def uncommit(ui, repo, *pats, **opts):
metadata[b'note'] = opts['note']
replacements = {old.node(): [newid]}
scmutil.cleanupnodes(repo, replacements, operation=b"uncommit",
metadata=metadata)
compat.cleanupnodes(repo, replacements, operation=b"uncommit",
metadata=metadata)
phases.retractboundary(repo, tr, oldphase, [newid])
if opts.get('revert'):
hg.updaterepo(repo, newid, True)
......@@ -749,13 +749,13 @@ def fold(ui, repo, *revs, **opts):
# (b99903534e06) didn't change any signatures.
if util.safehasattr(scmutil, 'nullrev'):
replacements = {tuple(ctx.node() for ctx in allctx): [newid]}
scmutil.cleanupnodes(repo, replacements, operation=b"fold",
metadata=metadata)
compat.cleanupnodes(repo, replacements, operation=b"fold",
metadata=metadata)
else:
# hg <= 4.7 (b99903534e06)
replacements = {ctx.node(): [newid] for ctx in allctx}
scmutil.cleanupnodes(repo, replacements, operation=b"fold",
metadata=metadata)
compat.cleanupnodes(repo, replacements, operation=b"fold",
metadata=metadata)
tr.close()
finally:
tr.release()
......@@ -885,14 +885,18 @@ def metaedit(ui, repo, *revs, **opts):
# Use this condition as a proxy since the commit we care about
# (b99903534e06) didn't change any signatures.
if util.safehasattr(scmutil, 'nullrev'):
mapping = {tuple(ctx.node() for ctx in allctx): (newid,)}
scmutil.cleanupnodes(repo, mapping, operation=b"metaedit",
metadata=metadata)
replacements = {
tuple(ctx.node() for ctx in allctx): (newid,)
}
compat.cleanupnodes(repo, replacements,
operation=b"metaedit",
metadata=metadata)
else:
# hg <= 4.7 (b99903534e06)
mapping = {ctx.node(): (newid,) for ctx in allctx}
scmutil.cleanupnodes(repo, mapping, operation=b"metaedit",
metadata=metadata)
replacements = {ctx.node(): (newid,) for ctx in allctx}
compat.cleanupnodes(repo, replacements,
operation=b"metaedit",
metadata=metadata)
else:
ui.status(_(b"nothing changed\n"))
tr.close()
......@@ -1121,8 +1125,8 @@ def cmdprune(ui, repo, *revs, **opts):
# Using a proxy condition to let people wrap cleanupnodes()
if util.safehasattr(scmutil, 'nullrev'):
replacements = {tuple(p.node() for p in precs): [s.node() for s in sucs]}
scmutil.cleanupnodes(repo, replacements, operation=b"prune", moves=moves,
metadata=metadata)
compat.cleanupnodes(repo, replacements, operation=b"prune", moves=moves,
metadata=metadata)
# informs that changeset have been pruned
ui.status(_(b'%i changesets pruned\n') % len(precs))
......@@ -1480,7 +1484,7 @@ def cmdpick(ui, repo, *revs, **opts):
else:
newctx = repo[newnode]
replacements = {origctx.node(): [newctx.node()]}
scmutil.cleanupnodes(repo, replacements, operation=b"pick")
compat.cleanupnodes(repo, replacements, operation=b"pick")
if newnode is None:
ui.warn(_(b"note: picking %d:%s created no changes to commit\n") %
......
......@@ -386,3 +386,7 @@ def parentchange(repo):
# hg <= 5.2 (85c4cd73996b)
if util.safehasattr(repo, '_quick_access_changeid_invalidate'):
repo._quick_access_changeid_invalidate()
def cleanupnodes(repo, replacements, operation, moves=None, metadata=None):
scmutil.cleanupnodes(repo, replacements=replacements, operation=operation,
moves=moves, metadata=metadata)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment