diff -r 39ef492603c6 -r a046e78c3290 hgext/evolve.py --- 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'))