--- a/hgext3rd/evolve/evolvecmd.py Fri Mar 23 19:36:08 2018 +0530
+++ b/hgext3rd/evolve/evolvecmd.py Sat Mar 24 12:58:12 2018 +0530
@@ -1231,76 +1231,21 @@
def continueevolve(ui, repo, evolvestate, progresscb):
"""logic for handling of `hg evolve --continue`"""
- 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()
+ if (evolvestate['command'] == 'next' or
+ evolvestate['category'] == 'orphan'):
+ _completeorphan(ui, repo, evolvestate)
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(ctxparents[0].node(),
- currentp1)
-
- else:
- # both the parents were obsoleted, if orphanmerge is set, we
- # are processing the second parent first (to keep parent order)
- if evolvestate.get('orphanmerge'):
- with repo.dirstate.parentchange():
- repo.dirstate.setparents(ctxparents[0].node(),
- currentp1)
- 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
- newctx = repo[node] if node is not None else repo['.']
- compat.createmarkers(repo, [(ctx, (newctx,))], operation='evolve')
+ repo.ui.status(_("continuing interrupted '%s' resolution is not yet"
+ " supported\n") % evolvestate['category'])
+ return
# 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']
unfi = repo.unfiltered()
- if evolvestate['orphanmerge']:
- # processing a merge changeset with both parents obsoleted,
- # stabilized on second parent, insert in front of list to
- # re-process to stabilize on first parent
- evolvestate['revs'].insert(0, repo[node].rev())
- evolvestate['orphanmerge'] = False
for rev in evolvestate['revs']:
# XXX: prevent this lookup by storing nodes instead of revnums
curctx = unfi[rev]
@@ -1313,3 +1258,73 @@
else:
evolvestate['skippedrevs'].append(curctx.node())
return
+
+def _completeorphan(ui, repo, evolvestate):
+ """function to complete the interrupted orphan resolution"""
+
+ orig = repo[evolvestate['current']]
+ 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(ctxparents[0].node(),
+ currentp1)
+
+ else:
+ # both the parents were obsoleted, if orphanmerge is set, we
+ # are processing the second parent first (to keep parent order)
+ if evolvestate.get('orphanmerge'):
+ with repo.dirstate.parentchange():
+ repo.dirstate.setparents(ctxparents[0].node(),
+ currentp1)
+ 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
+ newctx = repo[node] if node is not None else repo['.']
+ compat.createmarkers(repo, [(ctx, (newctx,))], operation='evolve')
+
+ # make sure we are continuing evolve and not `hg next --evolve`
+ if evolvestate['command'] == 'evolve':
+ evolvestate['replacements'][ctx.node()] = node
+ if evolvestate['orphanmerge']:
+ # processing a merge changeset with both parents obsoleted,
+ # stabilized on second parent, insert in front of list to
+ # re-process to stabilize on first parent
+ evolvestate['revs'].insert(0, repo[node].rev())
+ evolvestate['orphanmerge'] = False