From patchwork Sun Jun 22 23:52:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [evolve_ext,V2] fold: take an explicit list of revisions (BC) From: Greg Ward X-Patchwork-Id: 5041 Message-Id: <4ab7a80fc11f275c03d4.1403481156@lucifer.gerg.ca> To: pierre-yves.david@ens-lyon.org Cc: mercurial-devel@selenic.com Date: Sun, 22 Jun 2014 19:52:36 -0400 # HG changeset patch # User Greg Ward # Date 1403481137 14400 # Sun Jun 22 19:52:17 2014 -0400 # Node ID 4ab7a80fc11f275c03d4ddb94936a0688b71e6bc # 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'. 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 diff --git a/tests/test-tutorial.t b/tests/test-tutorial.t --- a/tests/test-tutorial.t +++ b/tests/test-tutorial.t @@ -473,25 +473,22 @@ The tutorial part is not written yet but can use `hg fold`: $ hg help fold - hg fold rev + hg fold [-r] REV... aliases: squash - 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. options: - -r --rev VALUE [+] explicitly specify the full set of revision to fold - -m --message TEXT use text as commit message - -l --logfile FILE read commit message from file - -d --date DATE record the specified date as commit date - -u --user USER record the specified user as committer + -r --rev REV [+] revisions to fold + -m --message TEXT use text as commit message + -l --logfile FILE read commit message from file + -d --date DATE record the specified date as commit date + -u --user USER record the specified user as committer [+] marked option can be specified multiple times