# HG changeset patch # User Martin von Zweigbergk <martinvonz@google.com> # Date 1620146385 25200 # Tue May 04 09:39:45 2021 -0700 # Branch stable # Node ID bfa47d370b2cd75da6fc119b2339245449fb7ea6 # Parent 991be5efe7cb07fee041b464e5cc110bb08cf548 compat: make compatible with upstream change to put nullid on repo This patch makes evolve compatible across Mercurial core commit d55b71393907. diff --git a/hgext3rd/evolve/__init__.py b/hgext3rd/evolve/__init__.py --- a/hgext3rd/evolve/__init__.py +++ b/hgext3rd/evolve/__init__.py @@ -1043,16 +1043,23 @@ _(b"make commit obsolete this revision (DEPRECATED)"))) @eh.wrapfunction(obsolete, '_checkinvalidmarkers') -def _checkinvalidmarkers(orig, markers): +def _checkinvalidmarkers(orig, *args): """search for marker with invalid data and raise error if needed Exist as a separated function to allow the evolve extension for a more subtle handling. """ + if len(args) == 2: + repo_nullid = args[0].nullid + markers = args[1] + else: + # hg <= 5.8 (d55b71393907) + repo_nullid = nullid + markers = args[0] if r'debugobsconvert' in sys.argv: return for mark in markers: - if nullid in mark[1]: + if repo_nullid in mark[1]: msg = _(b'bad obsolescence marker detected: invalid successors nullid') hint = _(b'You should run `hg debugobsconvert`') raise error.Abort(msg, hint=hint) # HG changeset patch # User Anton Shestakov <av6@dwimlabs.net> # Date 1628027063 -10800 # Wed Aug 04 00:44:23 2021 +0300 # Branch stable # Node ID f408cc176befd6ea61b99e253839082036742fd1 # Parent bfa47d370b2cd75da6fc119b2339245449fb7ea6 evolve: move movedirstate() to compat diff --git a/hgext3rd/evolve/cmdrewrite.py b/hgext3rd/evolve/cmdrewrite.py --- a/hgext3rd/evolve/cmdrewrite.py +++ b/hgext3rd/evolve/cmdrewrite.py @@ -340,52 +340,6 @@ newid = repo.commitctx(new) return newid -# TODO: call core's version once we've dropped support for hg <= 4.9 -def movedirstate(repo, newctx, match=None): - """Move the dirstate to newctx and adjust it as necessary. - - A matcher can be provided as an optimization. It is probably a bug to pass - a matcher that doesn't match all the differences between the parent of the - working copy and newctx. - """ - oldctx = repo[b'.'] - ds = repo.dirstate - dscopies = dict(ds.copies()) - ds.setparents(newctx.node(), node.nullid) - s = newctx.status(oldctx, match=match) - for f in s.modified: - if ds[f] == b'r': - # modified + removed -> removed - continue - ds.normallookup(f) - - for f in s.added: - if ds[f] == b'r': - # added + removed -> unknown - ds.drop(f) - elif ds[f] != b'a': - ds.add(f) - - for f in s.removed: - if ds[f] == b'a': - # removed + added -> normal - ds.normallookup(f) - elif ds[f] != b'r': - ds.remove(f) - - # Merge old parent and old working dir copies - oldcopies = copies.pathcopies(newctx, oldctx, match) - oldcopies.update(dscopies) - newcopies = { - dst: oldcopies.get(src, src) - for dst, src in oldcopies.items() - } - # Adjust the dirstate copies - for dst, src in newcopies.items(): - if src not in newctx or dst in newctx or ds[dst] != b'a': - src = None - ds.copy(src, dst) - @eh.command( b'uncommit', [(b'a', b'all', None, _(b'uncommit all changes when no arguments given')), @@ -515,7 +469,7 @@ compat.clean_update(repo[newid]) else: with repo.dirstate.parentchange(), compat.parentchange(repo): - movedirstate(repo, repo[newid], match) + compat.movedirstate(repo, repo[newid], match) if not repo[newid].files(): ui.warn(_(b"new changeset is empty\n")) ui.status(_(b"(use 'hg prune .' to remove it)\n")) diff --git a/hgext3rd/evolve/compat.py b/hgext3rd/evolve/compat.py --- a/hgext3rd/evolve/compat.py +++ b/hgext3rd/evolve/compat.py @@ -15,6 +15,7 @@ hg, logcmdutil, merge as mergemod, + node, obsolete, registrar, repair, @@ -432,3 +433,50 @@ def format_changeset_summary_fn(ui, repo, command, default_spec): return logcmdutil.changesetdisplayer(ui, repo, {b'template': default_spec}).show + +if True: + # TODO: call core's version once we've dropped support for hg <= 4.9 + def movedirstate(repo, newctx, match=None): + """Move the dirstate to newctx and adjust it as necessary. + + A matcher can be provided as an optimization. It is probably a bug to pass + a matcher that doesn't match all the differences between the parent of the + working copy and newctx. + """ + oldctx = repo[b'.'] + ds = repo.dirstate + dscopies = dict(ds.copies()) + ds.setparents(newctx.node(), node.nullid) + s = newctx.status(oldctx, match=match) + for f in s.modified: + if ds[f] == b'r': + # modified + removed -> removed + continue + ds.normallookup(f) + + for f in s.added: + if ds[f] == b'r': + # added + removed -> unknown + ds.drop(f) + elif ds[f] != b'a': + ds.add(f) + + for f in s.removed: + if ds[f] == b'a': + # removed + added -> normal + ds.normallookup(f) + elif ds[f] != b'r': + ds.remove(f) + + # Merge old parent and old working dir copies + oldcopies = copies.pathcopies(newctx, oldctx, match) + oldcopies.update(dscopies) + newcopies = { + dst: oldcopies.get(src, src) + for dst, src in oldcopies.items() + } + # Adjust the dirstate copies + for dst, src in newcopies.items(): + if src not in newctx or dst in newctx or ds[dst] != b'a': + src = None + ds.copy(src, dst) diff --git a/hgext3rd/evolve/evolvecmd.py b/hgext3rd/evolve/evolvecmd.py --- a/hgext3rd/evolve/evolvecmd.py +++ b/hgext3rd/evolve/evolvecmd.py @@ -37,7 +37,6 @@ from mercurial.i18n import _ from . import ( - cmdrewrite, compat, exthelper, rewriteutil, @@ -618,7 +617,7 @@ otherdiv = other if other.mutable() else divergent with repo.dirstate.parentchange(), compat.parentchange(repo): - cmdrewrite.movedirstate(repo, repo[publicnode]) + compat.movedirstate(repo, repo[publicnode]) # check if node to be committed has changes same as public one s = publicdiv.status() if not (s.added or s.removed or s.deleted or s.modified): @@ -631,7 +630,7 @@ return (True, publicnode) with repo.dirstate.parentchange(), compat.parentchange(repo): - cmdrewrite.movedirstate(repo, repo[resparent]) + compat.movedirstate(repo, repo[resparent]) # merge the branches mergebranches(repo, divergent, other, base) # HG changeset patch # User Anton Shestakov <av6@dwimlabs.net> # Date 1628027125 -10800 # Wed Aug 04 00:45:25 2021 +0300 # Branch stable # Node ID b7cb6e46c9c6f163ca4e8287ec92694ab807cc38 # Parent f408cc176befd6ea61b99e253839082036742fd1 compat: import copies as copiesmod to prepare for the next patch diff --git a/hgext3rd/evolve/compat.py b/hgext3rd/evolve/compat.py --- a/hgext3rd/evolve/compat.py +++ b/hgext3rd/evolve/compat.py @@ -11,7 +11,7 @@ from mercurial import ( cmdutil, context, - copies, + copies as copiesmod, hg, logcmdutil, merge as mergemod, @@ -95,7 +95,7 @@ except AttributeError: bmrevset = scmutil.bookmarkrevs -hg48 = util.safehasattr(copies, 'stringutil') +hg48 = util.safehasattr(copiesmod, 'stringutil') # code imported from Mercurial core at ae17555ef93f + patch def fixedcopytracing(repo, c1, c2, base): """A complete copy-patse of copies._fullcopytrace with a one line fix to @@ -104,6 +104,7 @@ gets in and once we drop support for 4.6, this should be removed.""" from mercurial import pathutil + copies = copiesmod # In certain scenarios (e.g. graft, update or rebase), base can be # overridden We still need to know a real common ancestor in this case We @@ -354,7 +355,7 @@ # hg <= 4.9 (7694b685bb10) fixupstreamed = util.safehasattr(scmutil, 'movedirstate') if not fixupstreamed: - copies._fullcopytracing = fixedcopytracing + copiesmod._fullcopytracing = fixedcopytracing # help category compatibility # hg <= 4.7 (c303d65d2e34) @@ -469,7 +470,7 @@ ds.remove(f) # Merge old parent and old working dir copies - oldcopies = copies.pathcopies(newctx, oldctx, match) + oldcopies = copiesmod.pathcopies(newctx, oldctx, match) oldcopies.update(dscopies) newcopies = { dst: oldcopies.get(src, src) # HG changeset patch # User Anton Shestakov <av6@dwimlabs.net> # Date 1628027166 -10800 # Wed Aug 04 00:46:06 2021 +0300 # Branch stable # Node ID 5578f21b43c1634ed76bee55cc2b510416fcb164 # Parent b7cb6e46c9c6f163ca4e8287ec92694ab807cc38 compat: use movedirstate() from core if on hg 5.9+ diff --git a/hgext3rd/evolve/compat.py b/hgext3rd/evolve/compat.py --- a/hgext3rd/evolve/compat.py +++ b/hgext3rd/evolve/compat.py @@ -12,6 +12,7 @@ cmdutil, context, copies as copiesmod, + dirstate, hg, logcmdutil, merge as mergemod, @@ -435,7 +436,9 @@ return logcmdutil.changesetdisplayer(ui, repo, {b'template': default_spec}).show -if True: +if util.safehasattr(dirstate.dirstate, 'set_clean'): + movedirstate = scmutil.movedirstate +else: # hg <= 5.8 (8a50fb0784a9) # TODO: call core's version once we've dropped support for hg <= 4.9 def movedirstate(repo, newctx, match=None): """Move the dirstate to newctx and adjust it as necessary.