[PATCH evolve-ext] fold: disallow multiple revisions without --exact

Kyle Lippincott spectral at pewpew.net
Fri Nov 4 21:09:40 EDT 2016


On Fri, Nov 4, 2016 at 4:58 PM, Martin von Zweigbergk via Mercurial-devel <
mercurial-devel at mercurial-scm.org> wrote:

> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz at google.com>
> # Date 1478303512 25200
> #      Fri Nov 04 16:51:52 2016 -0700
> # Node ID bb80851fe9a6e14263f0076074108556377141f9
> # Parent  cb2bac3253fbd52894ffcb4719a148fe6a3da38b
> fold: disallow multiple revisions without --exact
>

Per conversation on IRC, I think that the opposite would be safer: disallow
single revisions without explicit user consent (i.e. return to the original
behavior, according to https://www.mercurial-scm.org/wiki/EvolveUI#Why.3F).
The situation I'm afraid of with this change is something like this (sorry
for the mild hypotheticals involved here):

    If we assume a series of draft changes with A(t1), B(t1), C(t2), D(t3),
E(t3,@),
    then a hypothetical `hg fold topic(t1)` would error, but `hg fold
topic(t2)` would fold C,D,E.

I had been thinking that `hg fold .^` would be the primary reason for the
current non-exact (so I proposed `hg fold --prev` as equivalent to `hg fold
.^::.`), but https://www.mercurial-scm.org/wiki/EvolveUI#Why.3F says it's
really more like "most-recent N commits".  I think requiring the user to
count would not be ideal and it causes confusion with revision numbers, so
I don't think that --prev would work with an argument.

Instead, if we assume that most people stay tip-most in their work in
progress chains, we could have a `hg fold --from X` as an "alias" for `hg
fold X::.`, except that for safety reasons it should probably check that
max(X) < .

With that, merging the wip is, usually, `hg fold --from <nodeid of base of
wip>`.  I think --to would be unnecessary - the number of times it's useful
would be much lower (again, if we assume most non-power-users stay
tip-most, and power-users can be expected to use revsets properly).





>
> 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. It seems very likely that users who pass
> more than one revision wants to fold exactly those revisions, so let's
> abort and hint that they may be looking for --exact.
>
> diff -r cb2bac3253fb -r bb80851fe9a6 hgext/evolve.py
> --- a/hgext/evolve.py   Wed Nov 02 18:56:44 2016 +0100
> +++ b/hgext/evolve.py   Fri Nov 04 16:51:52 2016 -0700
> @@ -3115,6 +3115,11 @@
>      revs = scmutil.revrange(repo, revs)
>
>      if not opts['exact']:
> +        if len(revs) > 1:
> +            raise error.Abort(_("cannot fold from working directory to "
> +                                "more than one revision"),
> +                              hint=_("did you mean to use --exact?"))
> +
>          # 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]
> diff -r cb2bac3253fb -r bb80851fe9a6 tests/test-evolve.t
> --- a/tests/test-evolve.t       Wed Nov 02 18:56:44 2016 +0100
> +++ b/tests/test-evolve.t       Fri Nov 04 16:51:52 2016 -0700
> @@ -688,7 +688,11 @@
>    $ hg fold -r 4 -r 6 --exact
>    abort: cannot fold non-linear revisions (multiple roots given)
>    [255]
> -  $ hg fold 10 1
> +  $ hg fold 4::5
> +  abort: cannot fold from working directory to more than one revision
> +  (did you mean to use --exact?)
> +  [255]
> +  $ hg fold 1
>    abort: cannot fold non-linear revisions
>    (given revisions are unrelated to parent of working directory)
>    [255]
> diff -r cb2bac3253fb -r bb80851fe9a6 tests/test-userguide.t
> --- a/tests/test-userguide.t    Wed Nov 02 18:56:44 2016 +0100
> +++ b/tests/test-userguide.t    Fri Nov 04 16:51:52 2016 -0700
> @@ -109,7 +109,7 @@
>    7:05e61aab8294  step 1
>    8:be6d5bc8e4cc  step 2
>    9:35f432d9f7c1  step 3
> -  $ hg fold -d '0 0' -m 'fix bug 64' -r 7::
> +  $ hg fold -d '0 0' -m 'fix bug 64' -r 7
>    3 changesets folded
>    1 files updated, 0 files merged, 0 files removed, 0 files unresolved
>    $ hg --hidden shortlog -G -r 6::
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20161104/1547d72f/attachment.html>


More information about the Mercurial-devel mailing list