add a duplicate option in touch stable
authorDenis Laxalde <denis.laxalde@logilab.fr>
Fri, 08 Feb 2013 22:12:46 +0000
branchstable
changeset 701 f752089479ce
parent 700 ebcfd72e7609
child 702 b5a85a8909d3
add a duplicate option in touch
README
hgext/evolve.py
tests/test-touch.t
--- a/README	Fri Feb 08 22:09:42 2013 +0000
+++ b/README	Fri Feb 08 22:12:46 2013 +0000
@@ -49,6 +49,7 @@
 - prune: various minor improvements
 - amend: drop deprecated --change option for amend
 - alias: add a grab aliast to be used instead of graft -O
+- touch: add a --duplicate option to *not* obsolete the old version
 
 3.0.0 -- 2013-02-02
 
--- a/hgext/evolve.py	Fri Feb 08 22:09:42 2013 +0000
+++ b/hgext/evolve.py	Fri Feb 08 22:12:46 2013 +0000
@@ -1568,7 +1568,9 @@
             lock.release()
 
 @command('^touch',
-    [('r', 'rev', [], 'revision to update'),],
+    [('r', 'rev', [], 'revision to update'),
+     ('D', 'duplicate', False,
+      'do not mark the new revision as successor of the old one')],
     # allow to choose the seed ?
     _('[-r] revs'))
 def touch(ui, repo, *revs, **opts):
@@ -1576,6 +1578,7 @@
 
     This is used to "resurrect" changesets
     """
+    duplicate = opts['duplicate']
     revs = list(revs)
     revs.extend(opts['rev'])
     if not revs:
@@ -1584,7 +1587,7 @@
     if not revs:
         ui.write_err('no revision to touch\n')
         return 1
-    if repo.revs('public() and %ld', revs):
+    if not duplicate and repo.revs('public() and %ld', revs):
         raise util.Abort("can't touch public revision")
     wlock = lock = None
     try:
@@ -1599,7 +1602,8 @@
                 new, _ = rewrite(repo, ctx, [], ctx,
                                  [ctx.p1().node(), ctx.p2().node()],
                                  commitopts={'extra': extra})
-                createmarkers(repo, [(ctx, (repo[new],))])
+                if not duplicate:
+                    createmarkers(repo, [(ctx, (repo[new],))])
                 phases.retractboundary(repo, ctx.phase(), [new])
                 if ctx in repo[None].parents():
                     repo.dirstate.setparents(new, node.nullid)
--- a/tests/test-touch.t	Fri Feb 08 22:09:42 2013 +0000
+++ b/tests/test-touch.t	Fri Feb 08 22:12:46 2013 +0000
@@ -48,3 +48,12 @@
   
   $ hg prune 3
   1 changesets pruned
+
+Duplicate
+
+  $ hg touch --duplicate .
+  $ hg log -G
+  @  5:[0-9a-f]{12} a (re)
+  
+  o  4:[0-9a-f]{12} a (re)
+