Mercurial > evolve
changeset 5615:947820d4b476 stable
compat: add implementations of new merge.update() and merge.clean_update()
This adds `compat.update()`, `compat.clean_update()`, which will
delegate to the same functions from `mercurial.merge` when they are
available, or fall back to calling `hg.updaterepo()` when they're not.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 02 Oct 2020 10:09:14 -0700 |
parents | 24a1ff0677a7 |
children | 87c4b86081c1 |
files | hgext3rd/evolve/cmdrewrite.py hgext3rd/evolve/compat.py hgext3rd/evolve/evolvecmd.py hgext3rd/evolve/rewind.py |
diffstat | 4 files changed, 33 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/cmdrewrite.py Fri Oct 02 09:51:45 2020 -0700 +++ b/hgext3rd/evolve/cmdrewrite.py Fri Oct 02 10:09:14 2020 -0700 @@ -173,7 +173,7 @@ compat.cleanupnodes(repo, replacements, operation=b'amend', metadata=metadata) phases.retractboundary(repo, tr, old.phase(), [newnode]) - hg.updaterepo(repo, newnode, True) + compat.clean_update(repo[newnode]) def _editandapply(ui, repo, pats, old, p1, fp, diffopts): newnode = None @@ -513,7 +513,7 @@ metadata=metadata) phases.retractboundary(repo, tr, oldphase, [newid]) if opts.get('revert'): - hg.updaterepo(repo, newid, True) + compat.clean_update(repo[newid]) else: with repo.dirstate.parentchange(), compat.parentchange(repo): movedirstate(repo, repo[newid], match) @@ -1478,7 +1478,7 @@ pctxnode = pickstate[b'oldpctx'] ui.status(_(b"aborting pick, updating to %s\n") % node.hex(pctxnode)[:12]) - hg.updaterepo(repo, pctxnode, True) + compat.clean_update(repo[pctxnode]) pickstate.delete() return 0
--- a/hgext3rd/evolve/compat.py Fri Oct 02 09:51:45 2020 -0700 +++ b/hgext3rd/evolve/compat.py Fri Oct 02 10:09:14 2020 -0700 @@ -12,6 +12,7 @@ from mercurial import ( context, copies, + hg, merge as mergemod, obsolete, pycompat, @@ -409,3 +410,19 @@ # hg <= 5.5 (2c86b9587740) def _update(*args, **kwargs): return mergemod.update(*args, **kwargs) + +if (util.safehasattr(mergemod, '_update') + and util.safehasattr(mergemod, 'update')): + + def update(ctx): + mergemod.update(ctx) + + def clean_update(ctx): + mergemod.clean_update(ctx) +else: + # hg <= 5.5 (c1b603cdc95a) + def update(ctx): + hg.updaterepo(ctx.repo(), ctx.node(), overwrite=False) + + def clean_update(ctx): + hg.updaterepo(ctx.repo(), ctx.node(), overwrite=True)
--- a/hgext3rd/evolve/evolvecmd.py Fri Oct 02 09:51:45 2020 -0700 +++ b/hgext3rd/evolve/evolvecmd.py Fri Oct 02 10:09:14 2020 -0700 @@ -596,7 +596,7 @@ if divergent not in repo[None].parents(): repo.ui.note(_(b"updating to \"local\" side of the conflict: %s\n") % divergent.hex()[:12]) - hg.updaterepo(repo, divergent.node(), False) + compat.update(divergent) # merging the two content-divergent changesets repo.ui.note(_(b"merging \"other\" %s changeset '%s'\n") % (TROUBLES['CONTENTDIVERGENT'], other.hex()[:12])) @@ -690,7 +690,7 @@ } newnode = repo.commit(text=desc, user=user, date=date, extra=extra) new = repo[newnode] - hg.updaterepo(repo, new.rev(), False) + compat.update(new) if haspubdiv and publicdiv == divergent: bypassphase(repo, (divergent, new), operation=b'evolve') else: @@ -1420,7 +1420,7 @@ # obsolete (perhaps made obsolete by the current `hg evolve`) unfi = repo.unfiltered() succ = utility._singlesuccessor(repo, unfi[startnode]) - hg.updaterepo(repo, repo[succ].node(), False) + compat.update(repo[succ]) if repo[b'.'].node() != startnode: ui.status(_(b'working directory is now at %s\n') % repo[b'.']) @@ -1638,7 +1638,7 @@ # `hg next --evolve` in play if evolvestate[b'command'] != b'evolve': pctx = repo[b'.'] - hg.updaterepo(repo, pctx.node(), True) + compat.clean_update(pctx) ui.status(_(b'evolve aborted\n')) ui.status(_(b'working directory is now at %s\n') % pctx.hex()[:12]) @@ -1795,20 +1795,20 @@ if olddiv: with repo.wlock(), repo.lock(): repo = repo.unfiltered() - hg.updaterepo(repo, olddiv, True) + pctx = repo[olddiv] + compat.clean_update(pctx) repair.strip(ui, repo, strips, False) updated = True - pctx = repo[olddiv] elif oldother: with repo.wlock(), repo.lock(): repo = repo.unfiltered() - hg.updaterepo(repo, oldother, True) + pctx = repo[oldother] + compat.clean_update(pctx) repair.strip(ui, repo, strips, False) updated = True - pctx = repo[oldother] if not updated: pctx = repo[b'.'] - hg.updaterepo(repo, pctx.node(), True) + compat.clean_update(pctx) ui.status(_(b'stopped the interrupted evolve\n')) ui.status(_(b'working directory is now at %s\n') % pctx) @@ -1869,7 +1869,7 @@ for c in repo.set(b'roots(%ld)', evolvedrevs)] # updating the working directory - hg.updaterepo(repo, startnode, True) + compat.clean_update(repo[startnode]) # Strip from the first evolved revision if evolvedrevs: @@ -1897,7 +1897,7 @@ evolvestate.load() if evolvestate[b'command'] != b'evolve': pctx = repo[b'.'] - hg.updaterepo(repo, pctx.node(), True) + compat.clean_update(pctx) ui.status(_(b'evolve aborted\n')) ui.status(_(b'working directory is now at %s\n') % pctx.hex()[:12])
--- a/hgext3rd/evolve/rewind.py Fri Oct 02 09:51:45 2020 -0700 +++ b/hgext3rd/evolve/rewind.py Fri Oct 02 10:09:14 2020 -0700 @@ -6,7 +6,6 @@ from mercurial import ( cmdutil, error, - hg, obsolete, obsutil, scmutil, @@ -123,7 +122,7 @@ obsolete.createmarkers(unfi, relationships, operation=b'rewind') if update_target is not None: if opts.get('keep'): - hg.updaterepo(repo, oldctx, True) + compat.clean_update(oldctx) # This is largely the same as the implementation in # strip.stripcmd() and cmdrewrite.cmdprune(). @@ -160,7 +159,7 @@ else: cmdutil.revert(repo.ui, repo, oldctx, **revertopts) else: - hg.updaterepo(repo, update_target, False) + compat.update(repo[update_target]) repo.ui.status(_(b'rewinded to %d changesets\n') % len(rewinded)) if relationships: