Mercurial > evolve
changeset 5549:d83b24d38853 stable
compat: let cleanupnodes() handle compat across hg commit b99903534e06
This makes it so `compat.cleanupnodes()` requires the `replacements`
dict to have an iterable as key. On older Mercurials (< 4.7) we
convert that into many items with a single value as key instead.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 26 Aug 2020 09:07:52 -0700 |
parents | 7370725cdba7 |
children | fd2d61769bd0 |
files | hgext3rd/evolve/cmdrewrite.py hgext3rd/evolve/compat.py |
diffstat | 2 files changed, 26 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/cmdrewrite.py Wed Aug 26 08:18:59 2020 -0700 +++ b/hgext3rd/evolve/cmdrewrite.py Wed Aug 26 09:07:52 2020 -0700 @@ -169,7 +169,7 @@ metadata = {} if opts.get('note'): metadata[b'note'] = opts['note'] - replacements = {old.node(): [newnode]} + replacements = {(old.node(),): [newnode]} compat.cleanupnodes(repo, replacements, operation=b'amend', metadata=metadata) phases.retractboundary(repo, tr, old.phase(), [newnode]) @@ -508,7 +508,7 @@ if opts.get('note'): metadata[b'note'] = opts['note'] - replacements = {old.node(): [newid]} + replacements = {(old.node(),): [newid]} compat.cleanupnodes(repo, replacements, operation=b"uncommit", metadata=metadata) phases.retractboundary(repo, tr, oldphase, [newid]) @@ -745,17 +745,9 @@ p2.node()], commitopts=commitopts) phases.retractboundary(repo, tr, targetphase, [newid]) - # Use this condition as a proxy since the commit we care about - # (b99903534e06) didn't change any signatures. - if util.safehasattr(scmutil, 'nullrev'): - replacements = {tuple(ctx.node() for ctx in allctx): [newid]} - compat.cleanupnodes(repo, replacements, operation=b"fold", - metadata=metadata) - else: - # hg <= 4.7 (b99903534e06) - replacements = {ctx.node(): [newid] for ctx in allctx} - compat.cleanupnodes(repo, replacements, operation=b"fold", - metadata=metadata) + replacements = {tuple(ctx.node() for ctx in allctx): [newid]} + compat.cleanupnodes(repo, replacements, operation=b"fold", + metadata=metadata) tr.close() finally: tr.release() @@ -882,21 +874,9 @@ metadata[b'note'] = opts['note'] phases.retractboundary(repo, tr, targetphase, [newid]) - # Use this condition as a proxy since the commit we care about - # (b99903534e06) didn't change any signatures. - if util.safehasattr(scmutil, 'nullrev'): - replacements = { - tuple(ctx.node() for ctx in allctx): (newid,) - } - compat.cleanupnodes(repo, replacements, - operation=b"metaedit", - metadata=metadata) - else: - # hg <= 4.7 (b99903534e06) - replacements = {ctx.node(): (newid,) for ctx in allctx} - compat.cleanupnodes(repo, replacements, - operation=b"metaedit", - metadata=metadata) + replacements = {tuple(ctx.node() for ctx in allctx): (newid,)} + compat.cleanupnodes(repo, replacements, operation=b"metaedit", + metadata=metadata) else: ui.status(_(b"nothing changed\n")) tr.close() @@ -1035,9 +1015,9 @@ msg = b"please add --fold if you want to do a fold" raise error.Abort(msg) elif biject: - replacements = {p.node(): [s.node()] for p, s in zip(precs, sucs)} + replacements = {(p.node(),): [s.node()] for p, s in zip(precs, sucs)} else: - replacements = {p.node(): [s.node() for s in sucs] for p in precs} + replacements = {(p.node(),): [s.node() for s in sucs] for p in precs} wdp = repo[b'.'] @@ -1117,14 +1097,11 @@ # but then revset took a lazy arrow in the knee and became much # slower. The new forms makes as much sense and a much faster. for dest in ctx.ancestors(): - if not dest.obsolete() and dest.node() not in replacements: + if not dest.obsolete() and (dest.node(),) not in replacements: moves[ctx.node()] = dest.node() break if len(sucs) == 1 and len(precs) > 1 and fold: - # hg <= 4.7 (b99903534e06) - # 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]} + replacements = {tuple(p.node() for p in precs): [s.node() for s in sucs]} compat.cleanupnodes(repo, replacements, operation=b"prune", moves=moves, metadata=metadata) @@ -1480,10 +1457,10 @@ if pickstate: pickstate.delete() if newnode is None: - replacements = {origctx.node(): []} + replacements = {(origctx.node(),): []} else: newctx = repo[newnode] - replacements = {origctx.node(): [newctx.node()]} + replacements = {(origctx.node(),): [newctx.node()]} compat.cleanupnodes(repo, replacements, operation=b"pick") if newnode is None:
--- a/hgext3rd/evolve/compat.py Wed Aug 26 08:18:59 2020 -0700 +++ b/hgext3rd/evolve/compat.py Wed Aug 26 09:07:52 2020 -0700 @@ -388,5 +388,16 @@ repo._quick_access_changeid_invalidate() def cleanupnodes(repo, replacements, operation, moves=None, metadata=None): - scmutil.cleanupnodes(repo, replacements=replacements, operation=operation, + # Use this condition as a proxy since the commit we care about + # (b99903534e06) didn't change any signatures. + if util.safehasattr(scmutil, 'nullrev'): + fixedreplacements = replacements + else: + # hg <= 4.7 (b99903534e06) + fixedreplacements = {} + for oldnodes, newnodes in replacements.items(): + for oldnode in oldnodes: + fixedreplacements[oldnode] = newnodes + + scmutil.cleanupnodes(repo, replacements=fixedreplacements, operation=operation, moves=moves, metadata=metadata)