Patchwork [evolve_ext] fold: take an explicit list of revisions (BC)

login
register
mail settings
Submitter Greg Ward
Date June 22, 2014, 5:06 p.m.
Message ID <c59f66bda377f6f1540a.1403456789@lucifer.gerg.ca>
Download mbox | patch
Permalink /patch/5040/
State Changes Requested
Headers show

Comments

Greg Ward - June 22, 2014, 5:06 p.m.
# HG changeset patch
# User Greg Ward <greg@gerg.ca>
# Date 1403456616 14400
#      Sun Jun 22 13:03:36 2014 -0400
# Node ID c59f66bda377f6f1540aa37f0cd14b96dec0ee58
# Parent  2fbba0bf7e7c8cbff1f94bc95c4d6214df85ef81
fold: take an explicit list of revisions (BC)

This means anyone used to running "hg fold REV" will have to change
their habit to "hg fold REV::". The upside is that the new interface
is simpler, easier to describe, and more consistent with other hg
commands.

UI and code are modeled on graft, which similiarly takes one or more
input revisions, either with or without '-r'.

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -2072,32 +2072,22 @@ 
         lockmod.release(lock, wlock)
 
 @command('^fold|squash',
-    [('r', 'rev', [], _("explicitly specify the full set of revision to fold")),
+    [('r', 'rev', [], _('revisions to fold'), _('REV')),
     ] + commitopts + commitopts2,
     # allow to choose the seed ?
-    _('rev'))
+    _('[-r] REV...'))
 def fold(ui, repo, *revs, **opts):
-    """Fold multiple revisions into a single one
+    """combine multiple revisions into a single successor
 
-    The revisions from your current working directory to the given one are folded
-    into a single successor revision.
-
-    you can alternatively use --rev to explicitly specify revisions to be folded,
-    ignoring the current working directory parent.
+    The specified revisions are combined to create a single successor
+    revision that includes the changes from all of them.
     """
     revs = list(revs)
-    if 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 = ()
+    revs.extend(opts['rev'])
     if not revs:
-        ui.write_err('no revision to fold\n')
-        return 1
+        raise util.Abort('no revisions specified')
+    revs = scmutil.revrange(repo, revs)
+
     roots = repo.revs('roots(%ld)', revs)
     if len(roots) > 1:
         raise util.Abort("set has multiple roots")
diff --git a/tests/test-evolve.t b/tests/test-evolve.t
--- a/tests/test-evolve.t
+++ b/tests/test-evolve.t
@@ -614,12 +614,9 @@ 
 
   $ rm *.orig
   $ hg fold
-  no revision to fold
-  [1]
-  $ hg fold 6 --rev 10
-  abort: cannot specify both --rev and a target revision
+  abort: no revisions specified
   [255]
-  $ hg fold 6 # want to run hg fold 6
+  $ hg fold 6::
   2 changesets folded
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ glog
@@ -735,7 +732,7 @@ 
 Test fold with commit messages
 
   $ cd ../work
-  $ hg fold .^ --message "Folding with custom commit message"
+  $ hg fold -r '(.^)::' --message "Folding with custom commit message"
   2 changesets folded
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ glog
@@ -754,7 +751,7 @@ 
   >                   commit message
   > EOF
 
-  $ hg fold .^ --logfile commit-message
+  $ hg fold .^ -r . --logfile commit-message
   2 changesets folded
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg qlog