# HG changeset patch # User Anton Shestakov # Date 1580217124 -25200 # Node ID 6742ce1893731986d49f31b74e6bbfd40a944716 # Parent 2fcaee044a8c1b337c2569231145a611dcc72f4d compat: add a context manager that calls _quick_access_changeid_invalidate() diff -r 2fcaee044a8c -r 6742ce189373 hgext3rd/evolve/cmdrewrite.py --- a/hgext3rd/evolve/cmdrewrite.py Fri Jan 17 20:40:24 2020 +0700 +++ b/hgext3rd/evolve/cmdrewrite.py Tue Jan 28 20:12:04 2020 +0700 @@ -576,7 +576,7 @@ if opts.get('revert'): hg.updaterepo(repo, newid, True) else: - with repo.dirstate.parentchange(): + with repo.dirstate.parentchange(), compat.parentchange(repo): repo.dirstate.setparents(newid, node.nullid) _uncommitdirstate(repo, old, match, interactive) if not repo[newid].files(): @@ -1445,7 +1445,7 @@ tr = repo.currenttransaction() phases.retractboundary(repo, tr, ctx.phase(), [new]) if ctx in repo[None].parents(): - with repo.dirstate.parentchange(): + with repo.dirstate.parentchange(), compat.parentchange(repo): repo.dirstate.setparents(new, node.nullid) @eh.command( diff -r 2fcaee044a8c -r 6742ce189373 hgext3rd/evolve/compat.py --- a/hgext3rd/evolve/compat.py Fri Jan 17 20:40:24 2020 +0700 +++ b/hgext3rd/evolve/compat.py Tue Jan 28 20:12:04 2020 +0700 @@ -6,8 +6,9 @@ Compatibility module """ +import array +import contextlib import inspect -import array from mercurial import ( context, @@ -530,3 +531,12 @@ if util.safehasattr(cl.index, 'get_rev'): return cl.index.get_rev return cl.nodemap.get + +@contextlib.contextmanager +def parentchange(repo): + try: + yield + finally: + # hg <= 5.2 (85c4cd73996b) + if util.safehasattr(repo, '_quick_access_changeid_invalidate'): + repo._quick_access_changeid_invalidate() diff -r 2fcaee044a8c -r 6742ce189373 hgext3rd/evolve/evolvecmd.py --- a/hgext3rd/evolve/evolvecmd.py Fri Jan 17 20:40:24 2020 +0700 +++ b/hgext3rd/evolve/evolvecmd.py Tue Jan 28 20:12:04 2020 +0700 @@ -296,7 +296,7 @@ flag=obsolete.bumpedfix, operation=b'evolve') bmupdate(newid) # reroute the working copy parent to the new changeset - with repo.dirstate.parentchange(): + with repo.dirstate.parentchange(), compat.parentchange(repo): repo.dirstate.setparents(newid, nodemod.nullid) return (True, replacementnode) @@ -623,7 +623,7 @@ othernode = evolvestate[b'other-divergent'] otherdiv = repo[othernode] - with repo.dirstate.parentchange(): + with repo.dirstate.parentchange(), compat.parentchange(repo): repo.dirstate.setparents(publicnode, nodemod.nullid) dirstatedance(repo, divergent, publicnode, None) # check if node to be committed has changes same as public one @@ -636,7 +636,7 @@ operation=b'evolve') return (True, publicnode) try: - with repo.dirstate.parentchange(): + with repo.dirstate.parentchange(), compat.parentchange(repo): repo.dirstate.setparents(resparent, nodemod.nullid) dirstatedance(repo, divergent, resparent, None) @@ -1006,7 +1006,7 @@ assert tr is not None r = _evolvemerge(repo, orig, dest, pctx, keepbranch) if compat.hasconflict(r): # some conflict - with repo.dirstate.parentchange(): + with repo.dirstate.parentchange(), compat.parentchange(repo): repo.setparents(dest.node(), orig.node()) repo.dirstate.write(tr) # fix up dirstate for copies and renames @@ -2150,14 +2150,14 @@ # p1 is obsolete and p2 is not obsolete, current working # directory parent should be successor of p1, so we should # set dirstate parents to (succ of p1, p2) - with repo.dirstate.parentchange(): + with repo.dirstate.parentchange(), compat.parentchange(repo): repo.dirstate.setparents(currentp1, ctxparents[1].node()) elif p2obs and not p1obs: # p2 is obsolete and p1 is not obsolete, current working # directory parent should be successor of p2, so we should # set dirstate parents to (succ of p2, p1) - with repo.dirstate.parentchange(): + with repo.dirstate.parentchange(), compat.parentchange(repo): repo.dirstate.setparents(ctxparents[0].node(), currentp1) @@ -2165,12 +2165,12 @@ # both the parents were obsoleted, if orphanmerge is set, we # are processing the second parent first (to keep parent order) if evolvestate.get(b'orphanmerge'): - with repo.dirstate.parentchange(): + with repo.dirstate.parentchange(), compat.parentchange(repo): repo.dirstate.setparents(ctxparents[0].node(), currentp1) pass else: - with repo.dirstate.parentchange(): + with repo.dirstate.parentchange(), compat.parentchange(repo): repo.dirstate.setparents(repo.dirstate.parents()[0], nodemod.nullid) with repo.ui.configoverride(overrides, b'evolve-continue'):