--- a/hgext3rd/evolve/cmdrewrite.py Mon May 27 02:42:11 2019 +0200
+++ b/hgext3rd/evolve/cmdrewrite.py Mon May 13 18:39:43 2019 +0530
@@ -1348,8 +1348,6 @@
This is used to "resurrect" changesets
"""
_checknotesize(ui, opts)
- duplicate = opts['duplicate']
- allowdivergence = opts['allowdivergence']
revs = list(revs)
revs.extend(opts['rev'])
if not revs:
@@ -1358,6 +1356,8 @@
if not revs:
ui.write_err('no revision to touch\n')
return 1
+
+ duplicate = opts['duplicate']
if not duplicate:
rewriteutil.precheck(repo, revs, 'touch')
tmpl = utility.shorttemplate
@@ -1367,63 +1367,69 @@
wlock = repo.wlock()
lock = repo.lock()
tr = repo.transaction('touch')
- revs.sort() # ensure parent are run first
- newmapping = {}
- for r in revs:
- ctx = repo[r]
- extra = ctx.extra().copy()
- extra['__touch-noise__'] = random.randint(0, 0xffffffff)
- # search for touched parent
- p1 = ctx.p1().node()
- p2 = ctx.p2().node()
- p1 = newmapping.get(p1, p1)
- p2 = newmapping.get(p2, p2)
-
- if not (duplicate or allowdivergence):
- # The user hasn't yet decided what to do with the revived
- # cset, let's ask
- sset = obsutil.successorssets(repo, ctx.node())
- nodivergencerisk = (len(sset) == 0
- or (len(sset) == 1
- and len(sset[0]) == 1
- and repo[sset[0][0]].rev() == ctx.rev()
- ))
- if nodivergencerisk:
- duplicate = False
- else:
- displayer.show(ctx)
- index = ui.promptchoice(
- _("reviving this changeset will create divergence"
- " unless you make a duplicate.\n(a)llow divergence or"
- " (d)uplicate the changeset? $$ &Allowdivergence $$ "
- "&Duplicate"), 0)
- choice = ['allowdivergence', 'duplicate'][index]
- if choice == 'allowdivergence':
- duplicate = False
- else:
- duplicate = True
-
- extradict = {'extra': extra}
- new, unusedvariable = rewriteutil.rewrite(repo, ctx, [], ctx,
- [p1, p2],
- commitopts=extradict)
- # store touched version to help potential children
- newmapping[ctx.node()] = new
-
- if not duplicate:
- metadata = {}
- if opts.get('note'):
- metadata['note'] = opts['note']
- obsolete.createmarkers(repo, [(ctx, (repo[new],))],
- metadata=metadata, operation="touch")
- phases.retractboundary(repo, tr, ctx.phase(), [new])
- if ctx in repo[None].parents():
- with repo.dirstate.parentchange():
- repo.dirstate.setparents(new, node.nullid)
+ touchnodes(ui, repo, revs, displayer, **opts)
tr.close()
finally:
lockmod.release(tr, lock, wlock)
+def touchnodes(ui, repo, revs, displayer, **opts):
+ duplicate = opts['duplicate']
+ allowdivergence = opts['allowdivergence']
+ revs.sort() # ensure parent are run first
+ newmapping = {}
+ for r in revs:
+ ctx = repo[r]
+ extra = ctx.extra().copy()
+ extra['__touch-noise__'] = random.randint(0, 0xffffffff)
+ # search for touched parent
+ p1 = ctx.p1().node()
+ p2 = ctx.p2().node()
+ p1 = newmapping.get(p1, p1)
+ p2 = newmapping.get(p2, p2)
+
+ if not (duplicate or allowdivergence):
+ # The user hasn't yet decided what to do with the revived
+ # cset, let's ask
+ sset = obsutil.successorssets(repo, ctx.node())
+ nodivergencerisk = (len(sset) == 0
+ or (len(sset) == 1
+ and len(sset[0]) == 1
+ and repo[sset[0][0]].rev() == ctx.rev()
+ ))
+ if nodivergencerisk:
+ duplicate = False
+ else:
+ displayer.show(ctx)
+ index = ui.promptchoice(
+ _("reviving this changeset will create divergence"
+ " unless you make a duplicate.\n(a)llow divergence or"
+ " (d)uplicate the changeset? $$ &Allowdivergence $$ "
+ "&Duplicate"), 0)
+ choice = ['allowdivergence', 'duplicate'][index]
+ if choice == 'allowdivergence':
+ duplicate = False
+ else:
+ duplicate = True
+
+ extradict = {'extra': extra}
+ new, unusedvariable = rewriteutil.rewrite(repo, ctx, [], ctx,
+ [p1, p2],
+ commitopts=extradict)
+ # store touched version to help potential children
+ newmapping[ctx.node()] = new
+
+ if not duplicate:
+ metadata = {}
+ if opts.get('note'):
+ metadata['note'] = opts['note']
+ obsolete.createmarkers(repo, [(ctx, (repo[new],))],
+ metadata=metadata, operation="touch")
+ tr = repo.currenttransaction()
+ phases.retractboundary(repo, tr, ctx.phase(), [new])
+ if ctx in repo[None].parents():
+ with repo.dirstate.parentchange():
+ repo.dirstate.setparents(new, node.nullid)
+
@eh.command(
'pick|grab',
[('r', 'rev', '', _('revision to pick'), _('REV')),