--- a/hgext3rd/evolve/__init__.py Sun Jul 23 05:32:23 2017 +0200
+++ b/hgext3rd/evolve/__init__.py Sun Jul 23 05:42:41 2017 +0200
@@ -219,7 +219,6 @@
import os
import sys
-import random
import re
import collections
import errno
@@ -301,6 +300,7 @@
commandopt = 'allnewcommands'
obsexcmsg = utility.obsexcmsg
+shorttemplate = utility.shorttemplate
colortable = {'evolve.node': 'yellow',
'evolve.user': 'green',
@@ -1893,8 +1893,6 @@
raise error.Abort("base of divergent changeset %s not found" % ctx,
hint='this case is not yet handled')
-shorttemplate = "[{label('evolve.rev', rev)}] {desc|firstline}\n"
-
def _gettopic(ctx):
"""handle topic fetching with or without the extension"""
return getattr(ctx, 'topic', lambda: '')()
@@ -2409,92 +2407,6 @@
kwargs['biject'] = False
return cmdprune(ui, repo, *revs, **kwargs)
-@eh.command(
- '^touch',
- [('r', 'rev', [], 'revision to update'),
- ('D', 'duplicate', False,
- 'do not mark the new revision as successor of the old one'),
- ('A', 'allowdivergence', False,
- 'mark the new revision as successor of the old one potentially creating '
- 'divergence')],
- # allow to choose the seed ?
- _('[-r] revs'))
-def touch(ui, repo, *revs, **opts):
- """create successors that are identical to their predecessors except
- for the changeset ID
-
- This is used to "resurrect" changesets
- """
- duplicate = opts['duplicate']
- allowdivergence = opts['allowdivergence']
- revs = list(revs)
- revs.extend(opts['rev'])
- if not revs:
- revs = ['.']
- revs = scmutil.revrange(repo, revs)
- if not revs:
- ui.write_err('no revision to touch\n')
- return 1
- if not duplicate and repo.revs('public() and %ld', revs):
- raise error.Abort("can't touch public revision")
- displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
- wlock = lock = tr = None
- try:
- 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 = compat.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
-
- new, unusedvariable = rewrite(repo, ctx, [], ctx,
- [p1, p2],
- commitopts={'extra': extra})
- # store touched version to help potential children
- newmapping[ctx.node()] = new
-
- if not duplicate:
- obsolete.createmarkers(repo, [(ctx, (repo[new],))])
- phases.retractboundary(repo, tr, ctx.phase(), [new])
- if ctx in repo[None].parents():
- with repo.dirstate.parentchange():
- repo.dirstate.setparents(new, node.nullid)
- tr.close()
- finally:
- lockmod.release(tr, lock, wlock)
-
@eh.wrapcommand('graft')
def graftwrapper(orig, ui, repo, *revs, **kwargs):
kwargs = dict(kwargs)
--- a/hgext3rd/evolve/evocommands.py Sun Jul 23 05:32:23 2017 +0200
+++ b/hgext3rd/evolve/evocommands.py Sun Jul 23 05:42:41 2017 +0200
@@ -13,6 +13,8 @@
from __future__ import absolute_import
+import random
+
from mercurial import (
bookmarks as bookmarksmod,
cmdutil,
@@ -32,8 +34,10 @@
from mercurial.i18n import _
from . import (
+ compat,
exthelper,
rewriteutil,
+ utility,
)
eh = exthelper.exthelper()
@@ -627,3 +631,91 @@
tr.close()
finally:
lockmod.release(tr, lock, wlock)
+
+@eh.command(
+ '^touch',
+ [('r', 'rev', [], 'revision to update'),
+ ('D', 'duplicate', False,
+ 'do not mark the new revision as successor of the old one'),
+ ('A', 'allowdivergence', False,
+ 'mark the new revision as successor of the old one potentially creating '
+ 'divergence')],
+ # allow to choose the seed ?
+ _('[-r] revs'))
+def touch(ui, repo, *revs, **opts):
+ """create successors that are identical to their predecessors except
+ for the changeset ID
+
+ This is used to "resurrect" changesets
+ """
+ duplicate = opts['duplicate']
+ allowdivergence = opts['allowdivergence']
+ revs = list(revs)
+ revs.extend(opts['rev'])
+ if not revs:
+ revs = ['.']
+ revs = scmutil.revrange(repo, revs)
+ if not revs:
+ ui.write_err('no revision to touch\n')
+ return 1
+ if not duplicate and repo.revs('public() and %ld', revs):
+ raise error.Abort("can't touch public revision")
+ tmpl = utility.shorttemplate
+ displayer = cmdutil.show_changeset(ui, repo, {'template': tmpl})
+ wlock = lock = tr = None
+ try:
+ 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 = compat.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:
+ obsolete.createmarkers(repo, [(ctx, (repo[new],))])
+ phases.retractboundary(repo, tr, ctx.phase(), [new])
+ if ctx in repo[None].parents():
+ with repo.dirstate.parentchange():
+ repo.dirstate.setparents(new, node.nullid)
+ tr.close()
+ finally:
+ lockmod.release(tr, lock, wlock)
--- a/hgext3rd/evolve/utility.py Sun Jul 23 05:32:23 2017 +0200
+++ b/hgext3rd/evolve/utility.py Sun Jul 23 05:42:41 2017 +0200
@@ -5,6 +5,8 @@
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
+shorttemplate = "[{label('evolve.rev', rev)}] {desc|firstline}\n"
+
def obsexcmsg(ui, message, important=False):
verbose = ui.configbool('experimental', 'verbose-obsolescence-exchange',
False)