--- a/hgext3rd/evolve/evolvecmd.py Fri Mar 16 15:24:56 2018 +0530
+++ b/hgext3rd/evolve/evolvecmd.py Wed Mar 14 21:21:10 2018 +0530
@@ -1126,88 +1126,7 @@
evolvestate = state.cmdstate(repo)
# Continuation handling
if contopt:
- if not evolvestate:
- raise error.Abort('no evolve to continue')
- evolvestate.load()
- orig = repo[evolvestate['current']]
- with repo.wlock(), repo.lock():
- ctx = orig
- source = ctx.extra().get('source')
- extra = {}
- if source:
- extra['source'] = source
- extra['intermediate-source'] = ctx.hex()
- else:
- extra['source'] = ctx.hex()
- user = ctx.user()
- date = ctx.date()
- message = ctx.description()
- ui.status(_('evolving %d:%s "%s"\n') % (ctx.rev(), ctx,
- message.split('\n', 1)[0]))
- targetphase = max(ctx.phase(), phases.draft)
- overrides = {('phases', 'new-commit'): targetphase}
-
- ctxparents = orig.parents()
- if len(ctxparents) == 2:
- currentp1 = repo.dirstate.parents()[0]
- p1obs = ctxparents[0].obsolete()
- p2obs = ctxparents[1].obsolete()
- # asumming that the parent of current wdir is successor of one
- # of p1 or p2 of the original changeset
- if p1obs and not p2obs:
- # 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():
- 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():
- repo.dirstate.setparents(currentp1,
- ctxparents[0].node())
-
- else:
- # both the parents were obsolete, not sure what logic will
- # required here
- # XXX: add tests for this and see what is required here
- pass
-
- with repo.ui.configoverride(overrides, 'evolve-continue'):
- node = repo.commit(text=message, user=user,
- date=date, extra=extra)
-
- # resolving conflicts can lead to empty wdir and node can be None in
- # those cases
- if node is not None:
- obsolete.createmarkers(repo, [(ctx, (repo[node],))])
- else:
- obsolete.createmarkers(repo, [(ctx, (repo['.'],))])
-
- # make sure we are continuing evolve and not `hg next --evolve`
- if evolvestate['command'] == 'evolve':
- evolvestate['replacements'][ctx.node()] = node
- category = evolvestate['category']
- confirm = evolvestate['confirm']
- startnode = evolvestate['startnode']
- unfi = repo.unfiltered()
- for rev in evolvestate['revs']:
- # XXX: prevent this lookup by storing nodes instead of revnums
- curctx = unfi[rev]
- if (curctx.node() not in evolvestate['replacements'] and
- curctx.node() not in evolvestate['skippedrevs']):
- newnode = _solveone(ui, repo, curctx, evolvestate, False,
- confirm, progresscb, category)
- if newnode[0]:
- evolvestate['replacements'][curctx.node()] = newnode[1]
- else:
- evolvestate['skippedrevs'].append(curctx.node())
-
- _cleanup(ui, repo, unfi[startnode], True)
- evolvestate.delete()
- return
+ return continueevolve(ui, repo, evolvestate, progresscb)
cmdutil.bailifchanged(repo)
@@ -1239,3 +1158,88 @@
evolvestate['skippedrevs'].append(curctx.node())
progresscb()
_cleanup(ui, repo, startnode, showprogress)
+
+def continueevolve(ui, repo, evolvestate, progresscb):
+ """logic for handling of `hg evolve --continue`"""
+ if not evolvestate:
+ raise error.Abort('no evolve to continue')
+ evolvestate.load()
+ orig = repo[evolvestate['current']]
+ with repo.wlock(), repo.lock():
+ ctx = orig
+ source = ctx.extra().get('source')
+ extra = {}
+ if source:
+ extra['source'] = source
+ extra['intermediate-source'] = ctx.hex()
+ else:
+ extra['source'] = ctx.hex()
+ user = ctx.user()
+ date = ctx.date()
+ message = ctx.description()
+ ui.status(_('evolving %d:%s "%s"\n') % (ctx.rev(), ctx,
+ message.split('\n', 1)[0]))
+ targetphase = max(ctx.phase(), phases.draft)
+ overrides = {('phases', 'new-commit'): targetphase}
+
+ ctxparents = orig.parents()
+ if len(ctxparents) == 2:
+ currentp1 = repo.dirstate.parents()[0]
+ p1obs = ctxparents[0].obsolete()
+ p2obs = ctxparents[1].obsolete()
+ # asumming that the parent of current wdir is successor of one
+ # of p1 or p2 of the original changeset
+ if p1obs and not p2obs:
+ # 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():
+ 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():
+ repo.dirstate.setparents(currentp1,
+ ctxparents[0].node())
+
+ else:
+ # both the parents were obsolete, not sure what logic will
+ # required here
+ # XXX: add tests for this and see what is required here
+ pass
+
+ with repo.ui.configoverride(overrides, 'evolve-continue'):
+ node = repo.commit(text=message, user=user,
+ date=date, extra=extra)
+
+ # resolving conflicts can lead to empty wdir and node can be None in
+ # those cases
+ if node is not None:
+ obsolete.createmarkers(repo, [(ctx, (repo[node],))])
+ else:
+ obsolete.createmarkers(repo, [(ctx, (repo['.'],))])
+
+ # make sure we are continuing evolve and not `hg next --evolve`
+ if evolvestate['command'] == 'evolve':
+ evolvestate['replacements'][ctx.node()] = node
+ category = evolvestate['category']
+ confirm = evolvestate['confirm']
+ startnode = evolvestate['startnode']
+ unfi = repo.unfiltered()
+ for rev in evolvestate['revs']:
+ # XXX: prevent this lookup by storing nodes instead of revnums
+ curctx = unfi[rev]
+ if (curctx.node() not in evolvestate['replacements'] and
+ curctx.node() not in evolvestate['skippedrevs']):
+ newnode = _solveone(ui, repo, curctx, evolvestate, False,
+ confirm, progresscb, category)
+ if newnode[0]:
+ evolvestate['replacements'][curctx.node()] = newnode[1]
+ else:
+ evolvestate['skippedrevs'].append(curctx.node())
+
+ _cleanup(ui, repo, unfi[startnode], True)
+ evolvestate.delete()
+ return