Mercurial > evolve
diff hgext/evolve.py @ 1782:a046e78c3290
fold: require --from flag for folding revisions to working copy
It's very easy to think that "hg fold 4::6" will fold exactly those
revisions. In reality, it will fold those *and* any revisions between
them and the working copy. To prevent users from making that mistake,
require the use of a new --from flag for folding revisions from the
given set to the working copy. With this change, I'm sure some users
will be surprised that the command can not be run without either
--from or --exact, but at least the consequences will be smaller (the
command simply aborts and the user can try again).
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 12 Jan 2017 13:47:49 -0800 |
parents | 39ef492603c6 |
children | f22120b12715 |
line wrap: on
line diff
--- a/hgext/evolve.py Tue Dec 13 10:28:09 2016 -0800 +++ b/hgext/evolve.py Thu Jan 12 13:47:49 2017 -0800 @@ -3068,16 +3068,17 @@ @command('^fold|squash', [('r', 'rev', [], _("revision to fold")), - ('', 'exact', None, _("only fold specified revisions")) + ('', 'exact', None, _("only fold specified revisions")), + ('', 'from', None, _("fold revisions linearly to working copy parent")) ] + commitopts + commitopts2, _('hg fold [OPTION]... [-r] REV')) def fold(ui, repo, *revs, **opts): """fold multiple revisions into a single one - By default, folds all the revisions linearly between the given revisions + With --from, folds all the revisions linearly between the given revisions and the parent of the working directory. - Use --exact for folding only the specified revisions while ignoring the + With --exact, folds only the specified revisions while ignoring the parent of the working directory. In this case, the given revisions must form a linear unbroken chain. @@ -3087,18 +3088,18 @@ - Fold the current revision with its parent:: - hg fold .^ + hg fold --from .^ - Fold all draft revisions with working directory parent:: - hg fold 'draft()' + hg fold --from 'draft()' See :hg:`help phases` for more about draft revisions and :hg:`help revsets` for more about the `draft()` keyword - Fold revisions between 3 and 6 with the working directory parent:: - hg fold 3::6 + hg fold --from 3::6 - Fold revisions 3 and 4: @@ -3115,7 +3116,9 @@ revs = scmutil.revrange(repo, revs) - if not opts['exact']: + if opts['from'] and opts['exact']: + raise error.Abort(_('cannot use both --from and --exact')) + elif opts['from']: # Try to extend given revision starting from the working directory extrevs = repo.revs('(%ld::.) or (.::%ld)', revs, revs) discardedrevs = [r for r in revs if r not in extrevs] @@ -3124,6 +3127,11 @@ hint=_("given revisions are unrelated to parent " "of working directory")) revs = extrevs + elif opts['exact']: + # Nothing to do; "revs" is already set correctly + pass + else: + raise error.Abort(_('must specify either --from or --exact')) if len(revs) == 1: ui.write_err(_('single revision specified, nothing to fold\n'))