hgext/evolve.py
branchstable
changeset 702 b5a85a8909d3
parent 701 f752089479ce
child 710 79a1d2816bdb
--- a/hgext/evolve.py	Fri Feb 08 22:12:46 2013 +0000
+++ b/hgext/evolve.py	Fri Feb 08 22:44:43 2013 +0000
@@ -1594,14 +1594,23 @@
         wlock = repo.wlock()
         lock = repo.lock()
         tr = repo.transaction('touch')
+        revs.sort() # ensure parent are run first
+        newmapping = {}
         try:
             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)
                 new, _ = rewrite(repo, ctx, [], ctx,
-                                 [ctx.p1().node(), ctx.p2().node()],
+                                 [p1, p2],
                                  commitopts={'extra': extra})
+                # store touched version to help potential children
+                newmapping[ctx.node()] = new
                 if not duplicate:
                     createmarkers(repo, [(ctx, (repo[new],))])
                 phases.retractboundary(repo, ctx.phase(), [new])
@@ -1614,16 +1623,29 @@
         lockmod.release(lock, wlock)
 
 @command('^fold',
-    [('r', 'rev', [], _("revisions to fold")),
+    [('r', 'rev', [], _("explicitly specify the full set of revision to fold")),
     ],
     # allow to choose the seed ?
-    _('[-r] revs'))
+    _('rev'))
 def fold(ui, repo, *revs, **opts):
-    """Fold multiple revisions into a single one"""
+    """Fold multiple revisions into a single one
+
+    Revision from your current working directory to the specified one are fold
+    as a new one replacing the other
+
+    you can alternatively use --rev to explicitly specify revision to be fold
+    ignoring the current working directory parent.
+    """
     revs = list(revs)
-    revs.extend(opts['rev'])
     if revs:
-        revs = scmutil.revrange(repo, revs)
+        if opts.get('rev', ()):
+            raise util.Abort("cannot specify both --rev and a target revision")
+        targets = scmutil.revrange(repo, revs)
+        revs = repo.revs('(%ld::.) or (.::%ld)', targets, targets)
+    elif 'rev' in opts:
+        revs = scmutil.revrange(repo, opts['rev'])
+    else:
+        revs = ()
     if not revs:
         ui.write_err('no revision to fold\n')
         return 1