Pierre-Yves David avatar Pierre-Yves David committed b5a85a8

touch: properly handle touching multiple changeset

Comments (0)

Files changed (4)

 - 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
+- touch: fix touching multiple revision at the same time
 
 3.0.0 -- 2013-02-02
 
         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])
         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

tests/test-evolve.t

   $ hg fold
   no revision to fold
   [1]
-  $ hg fold 6::10
+  $ hg fold 6 --rev 10
+  abort: cannot specify both --rev and a target revision
+  [255]
+  $ hg fold 6 # want to run hg fold 6
   2 changesets folded
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ glog
 
   $ hg up 4
   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
-  $ hg fold 4::11
+  $ hg fold --rev 4::11
   3 changesets folded
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ glog

tests/test-touch.t

   
   o  4:[0-9a-f]{12} a (re)
   
+
+Multiple touch
+
+  $ echo C > c
+  $ hg add c
+  $ hg commit -m c
+  $ echo D > d
+  $ hg add d
+  $ hg commit -m d
+  $ hg log -G
+  @  7:[0-9a-f]{12} d (re)
+  |
+  o  6:[0-9a-f]{12} c (re)
+  |
+  o  5:[0-9a-f]{12} a (re)
+  
+  o  4:[0-9a-f]{12} a (re)
+  
+  $ hg touch 6:7
+  $ hg log -G
+  @  9:[0-9a-f]{12} d (re)
+  |
+  o  8:[0-9a-f]{12} c (re)
+  |
+  o  5:[0-9a-f]{12} a (re)
+  
+  o  4:[0-9a-f]{12} a (re)
+  
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.