--- a/hgext/evolve.py Thu Aug 23 03:14:03 2012 +0200
+++ b/hgext/evolve.py Thu Aug 23 12:51:34 2012 +0200
@@ -9,6 +9,8 @@
'''a set of commands to handle changeset mutation'''
+import random
+
from mercurial import cmdutil
from mercurial import scmutil
from mercurial import node
@@ -797,6 +799,51 @@
finally:
lock.release()
+@command('^touch',
+ [('r', 'rev', [], 'revision to update'),],
+ # allow to choose the seed ?
+ _('[-r] revs'))
+def touch(ui, repo, *revs, **opts):
+ """Create successors with exact same property but hash
+
+ This is used to "resurect" changeset"""
+ 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 repo.revs('public() and %ld', revs):
+ raise util.Abort("can't touch public revision")
+ obsolete = extensions.find('obsolete')
+ wlock = repo.wlock()
+ try:
+ lock = repo.lock()
+ try:
+ tr = repo.transaction('touch')
+ try:
+ for r in revs:
+ ctx = repo[r]
+ extra = ctx.extra().copy()
+ extra['__touch-noise__'] = random.randint(0, 0xffffffff)
+ new, _ = rewrite(repo, ctx, [], ctx,
+ [ctx.p1().node(), ctx.p2().node()],
+ commitopts={'extra': extra})
+ obsolete.createmarkers(repo, [(ctx, (repo[new],))])
+ phases.retractboundary(repo, ctx.phase(), [new])
+ if ctx in repo[None].parents():
+ repo.dirstate.setparents(new, node.nullid)
+ tr.close()
+ finally:
+ tr.release()
+ finally:
+ lock.release()
+ finally:
+ wlock.release()
+
+
def graftwrapper(orig, ui, repo, *revs, **kwargs):
kwargs = dict(kwargs)
revs = list(revs) + kwargs.get('rev', [])