Patchwork [V2] evolve: improve error message if unstable changes are disallowed

login
register
mail settings
Submitter Pulkit Goyal
Date Nov. 24, 2016, 5:43 p.m.
Message ID <920d5946d13339d9cf48.1480009428@pulkit-goyal>
Download mbox | patch
Permalink /patch/17743/
State Accepted
Headers show

Comments

Pulkit Goyal - Nov. 24, 2016, 5:43 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1479915042 -19800
#      Wed Nov 23 21:00:42 2016 +0530
# Node ID 920d5946d13339d9cf4828f678f0000b55063cd8
# Parent  cb2bac3253fbd52894ffcb4719a148fe6a3da38b
evolve: improve error message if unstable changes are disallowed

I saw a question on stackoverflow why evolve reports something like cannot
fold chain not ending with head. Even I was confused the first time about the
behavior. The error message can be improved to avoid confusion to people who
are unaware about the config in future.
Mateusz Kwapich - Nov. 25, 2016, 12:28 p.m.
LGTM, I suppose that timeless may also want to review it before it's
queued.

Excerpts from Pulkit Goyal's message of 2016-11-24 23:13:48 +0530:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1479915042 -19800
> #      Wed Nov 23 21:00:42 2016 +0530
> # Node ID 920d5946d13339d9cf4828f678f0000b55063cd8
> # Parent  cb2bac3253fbd52894ffcb4719a148fe6a3da38b
> evolve: improve error message if unstable changes are disallowed
> 
> I saw a question on stackoverflow why evolve reports something like cannot
> fold chain not ending with head. Even I was confused the first time about the
> behavior. The error message can be improved to avoid confusion to people who
> are unaware about the config in future.
> 
> diff -r cb2bac3253fb -r 920d5946d133 hgext/evolve.py
> --- a/hgext/evolve.py    Wed Nov 02 18:56:44 2016 +0100
> +++ b/hgext/evolve.py    Wed Nov 23 21:00:42 2016 +0530
> @@ -2514,7 +2514,8 @@
>              raise error.Abort('nothing to prune')
>  
>          if _disallowednewunstable(repo, revs):
> -            raise error.Abort(_("cannot prune in the middle of a stack"))
> +            raise error.Abort(_("cannot prune in the middle of a stack"),
> +                        hint = _("new unstable changesets are not allowed"))
>  
>          # defines successors changesets
>          sucs = scmutil.revrange(repo, succs)
> @@ -3234,8 +3235,9 @@
>              newunstable = _disallowednewunstable(repo, revs)
>              if newunstable:
>                  raise error.Abort(
> -                    _('cannot edit commit information in the middle of a stack'),
> -                    hint=_('%s will be affected') % repo[newunstable.first()])
> +                    _('cannot edit commit information in the middle of a '\
> +                    'stack'), hint=_('%s will become unstable and new unstable'\
> +                    ' changes are not allowed') % repo[newunstable.first()])
>              root = head = repo[revs.first()]
>  
>          wctx = repo[None]
> @@ -3299,7 +3301,8 @@
>      head = repo[heads.first()]
>      if _disallowednewunstable(repo, revs):
>          raise error.Abort(_("cannot fold chain not ending with a head "\
> -                            "or with branching"))
> +                            "or with branching"), hint = _("new unstable"\
> +                            " changesets are not allowed"))
>      return root, head
>  
>  def _disallowednewunstable(repo, revs):
> diff -r cb2bac3253fb -r 920d5946d133 tests/test-evolve.t
> --- a/tests/test-evolve.t    Wed Nov 02 18:56:44 2016 +0100
> +++ b/tests/test-evolve.t    Wed Nov 23 21:00:42 2016 +0530
> @@ -1301,9 +1301,11 @@
>    created new head
>    $ hg prune '26 + 27'
>    abort: cannot prune in the middle of a stack
> +  (new unstable changesets are not allowed)
>    [255]
>    $ hg prune '19::28'
>    abort: cannot prune in the middle of a stack
> +  (new unstable changesets are not allowed)
>    [255]
>    $ hg prune '26::'
>    3 changesets pruned
> @@ -1338,9 +1340,11 @@
>  
>    $ hg fold --exact "19 + 18"
>    abort: cannot fold chain not ending with a head or with branching
> +  (new unstable changesets are not allowed)
>    [255]
>    $ hg fold --exact "18::29"
>    abort: cannot fold chain not ending with a head or with branching
> +  (new unstable changesets are not allowed)
>    [255]
>    $ hg fold --exact "19::"
>    2 changesets folded
> @@ -1483,10 +1487,11 @@
>  check that metaedit respects allowunstable
>    $ hg metaedit '.^' --config 'experimental.evolution=createmarkers, allnewcommands'
>    abort: cannot edit commit information in the middle of a stack
> -  (c904da5245b0 will be affected)
> +  (c904da5245b0 will become unstable and new unstable changes are not allowed)
>    [255]
>    $ hg metaedit '18::20' --fold --config 'experimental.evolution=createmarkers, allnewcommands'
>    abort: cannot fold chain not ending with a head or with branching
> +  (new unstable changesets are not allowed)
>    [255]
>    $ hg metaedit --user foobar
>    0 files updated, 0 files merged, 0 files removed, 0 files unresolved
Kostia Balytskyi - Nov. 30, 2016, 12:02 a.m.
Shouldn’t we mention the config in a hint message?

On 11/25/16, 12:28 PM, "Mercurial-devel on behalf of Mateusz Kwapich" <mercurial-devel-bounces@mercurial-scm.org on behalf of mitrandir@fb.com> wrote:

    LGTM, I suppose that timeless may also want to review it before it's
    queued.
    
    Excerpts from Pulkit Goyal's message of 2016-11-24 23:13:48 +0530:
    > # HG changeset patch

    > # User Pulkit Goyal <7895pulkit@gmail.com>

    > # Date 1479915042 -19800

    > #      Wed Nov 23 21:00:42 2016 +0530

    > # Node ID 920d5946d13339d9cf4828f678f0000b55063cd8

    > # Parent  cb2bac3253fbd52894ffcb4719a148fe6a3da38b

    > evolve: improve error message if unstable changes are disallowed

    > 

    > I saw a question on stackoverflow why evolve reports something like cannot

    > fold chain not ending with head. Even I was confused the first time about the

    > behavior. The error message can be improved to avoid confusion to people who

    > are unaware about the config in future.

    > 

    > diff -r cb2bac3253fb -r 920d5946d133 hgext/evolve.py

    > --- a/hgext/evolve.py    Wed Nov 02 18:56:44 2016 +0100

    > +++ b/hgext/evolve.py    Wed Nov 23 21:00:42 2016 +0530

    > @@ -2514,7 +2514,8 @@

    >              raise error.Abort('nothing to prune')

    >  

    >          if _disallowednewunstable(repo, revs):

    > -            raise error.Abort(_("cannot prune in the middle of a stack"))

    > +            raise error.Abort(_("cannot prune in the middle of a stack"),

    > +                        hint = _("new unstable changesets are not allowed"))

    >  

    >          # defines successors changesets

    >          sucs = scmutil.revrange(repo, succs)

    > @@ -3234,8 +3235,9 @@

    >              newunstable = _disallowednewunstable(repo, revs)

    >              if newunstable:

    >                  raise error.Abort(

    > -                    _('cannot edit commit information in the middle of a stack'),

    > -                    hint=_('%s will be affected') % repo[newunstable.first()])

    > +                    _('cannot edit commit information in the middle of a '\

    > +                    'stack'), hint=_('%s will become unstable and new unstable'\

    > +                    ' changes are not allowed') % repo[newunstable.first()])

    >              root = head = repo[revs.first()]

    >  

    >          wctx = repo[None]

    > @@ -3299,7 +3301,8 @@

    >      head = repo[heads.first()]

    >      if _disallowednewunstable(repo, revs):

    >          raise error.Abort(_("cannot fold chain not ending with a head "\

    > -                            "or with branching"))

    > +                            "or with branching"), hint = _("new unstable"\

    > +                            " changesets are not allowed"))

    >      return root, head

    >  

    >  def _disallowednewunstable(repo, revs):

    > diff -r cb2bac3253fb -r 920d5946d133 tests/test-evolve.t

    > --- a/tests/test-evolve.t    Wed Nov 02 18:56:44 2016 +0100

    > +++ b/tests/test-evolve.t    Wed Nov 23 21:00:42 2016 +0530

    > @@ -1301,9 +1301,11 @@

    >    created new head

    >    $ hg prune '26 + 27'

    >    abort: cannot prune in the middle of a stack

    > +  (new unstable changesets are not allowed)

    >    [255]

    >    $ hg prune '19::28'

    >    abort: cannot prune in the middle of a stack

    > +  (new unstable changesets are not allowed)

    >    [255]

    >    $ hg prune '26::'

    >    3 changesets pruned

    > @@ -1338,9 +1340,11 @@

    >  

    >    $ hg fold --exact "19 + 18"

    >    abort: cannot fold chain not ending with a head or with branching

    > +  (new unstable changesets are not allowed)

    >    [255]

    >    $ hg fold --exact "18::29"

    >    abort: cannot fold chain not ending with a head or with branching

    > +  (new unstable changesets are not allowed)

    >    [255]

    >    $ hg fold --exact "19::"

    >    2 changesets folded

    > @@ -1483,10 +1487,11 @@

    >  check that metaedit respects allowunstable

    >    $ hg metaedit '.^' --config 'experimental.evolution=createmarkers, allnewcommands'

    >    abort: cannot edit commit information in the middle of a stack

    > -  (c904da5245b0 will be affected)

    > +  (c904da5245b0 will become unstable and new unstable changes are not allowed)

    >    [255]

    >    $ hg metaedit '18::20' --fold --config 'experimental.evolution=createmarkers, allnewcommands'

    >    abort: cannot fold chain not ending with a head or with branching

    > +  (new unstable changesets are not allowed)

    >    [255]

    >    $ hg metaedit --user foobar

    >    0 files updated, 0 files merged, 0 files removed, 0 files unresolved

    
    -- 
    _______________________________________________
    Mercurial-devel mailing list
    Mercurial-devel@mercurial-scm.org
    https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel&d=DgIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=Pp-gQYFgs4tKlSFPF5kfCw&m=QukFSh3cja_kc0KmG_KvCqtbq77q1UqiBomG5m3Nr5I&s=ywLFcN2fvyXbzsLQIBB1XabV0Yo8otsCIb7EyuVAJt0&e=
timeless - Dec. 12, 2016, 2:41 a.m.
I'm not going to stop this from going in, it's definitely an improvement.

>> @@ -3299,7 +3301,8 @@
>>      head = repo[heads.first()]
>>      if _disallowednewunstable(repo, revs):
>>          raise error.Abort(_("cannot fold chain not ending with a head "\
>> -                            "or with branching"))
>> +                            "or with branching"), hint = _("new unstable"\
>> +                            " changesets are not allowed"))

1. From a UX perspective, I think I'd rather this be split. I think.
Users shouldn't have to figure out "am I branching" or "am I folding a
chain that doesn't end in a head".

Alternatively, I'm tempted to say "can only fold chains without
branches that end in a head"....

2. It'd be helpful if there was a wiki page or something that talked
about these cases, preferably such that searching for these error
messages led to it.

I'm not sure if I want it to be a wiki, or docs included w/ source,
but something somewhere...
Pierre-Yves David - Dec. 17, 2016, 7:53 a.m.
3That changesets is a pure improvement, over the previous state, so I 
took it. (I changed 'evolve:' into 'prune:' in the summary)

Can  you followup with a series taking timeless input in account and 
with some sort of document/pointing at the 'allowunstable' option?

On 12/12/2016 03:41 AM, timeless wrote:
> I'm not going to stop this from going in, it's definitely an improvement.
>
>>> @@ -3299,7 +3301,8 @@
>>>      head = repo[heads.first()]
>>>      if _disallowednewunstable(repo, revs):
>>>          raise error.Abort(_("cannot fold chain not ending with a head "\
>>> -                            "or with branching"))
>>> +                            "or with branching"), hint = _("new unstable"\
>>> +                            " changesets are not allowed"))
>
> 1. From a UX perspective, I think I'd rather this be split. I think.
> Users shouldn't have to figure out "am I branching" or "am I folding a
> chain that doesn't end in a head".
>
> Alternatively, I'm tempted to say "can only fold chains without
> branches that end in a head"....
>
> 2. It'd be helpful if there was a wiki page or something that talked
> about these cases, preferably such that searching for these error
> messages led to it.
>
> I'm not sure if I want it to be a wiki, or docs included w/ source,
> but something somewhere...
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff -r cb2bac3253fb -r 920d5946d133 hgext/evolve.py
--- a/hgext/evolve.py	Wed Nov 02 18:56:44 2016 +0100
+++ b/hgext/evolve.py	Wed Nov 23 21:00:42 2016 +0530
@@ -2514,7 +2514,8 @@ 
             raise error.Abort('nothing to prune')
 
         if _disallowednewunstable(repo, revs):
-            raise error.Abort(_("cannot prune in the middle of a stack"))
+            raise error.Abort(_("cannot prune in the middle of a stack"),
+                        hint = _("new unstable changesets are not allowed"))
 
         # defines successors changesets
         sucs = scmutil.revrange(repo, succs)
@@ -3234,8 +3235,9 @@ 
             newunstable = _disallowednewunstable(repo, revs)
             if newunstable:
                 raise error.Abort(
-                    _('cannot edit commit information in the middle of a stack'),
-                    hint=_('%s will be affected') % repo[newunstable.first()])
+                    _('cannot edit commit information in the middle of a '\
+                    'stack'), hint=_('%s will become unstable and new unstable'\
+                    ' changes are not allowed') % repo[newunstable.first()])
             root = head = repo[revs.first()]
 
         wctx = repo[None]
@@ -3299,7 +3301,8 @@ 
     head = repo[heads.first()]
     if _disallowednewunstable(repo, revs):
         raise error.Abort(_("cannot fold chain not ending with a head "\
-                            "or with branching"))
+                            "or with branching"), hint = _("new unstable"\
+                            " changesets are not allowed"))
     return root, head
 
 def _disallowednewunstable(repo, revs):
diff -r cb2bac3253fb -r 920d5946d133 tests/test-evolve.t
--- a/tests/test-evolve.t	Wed Nov 02 18:56:44 2016 +0100
+++ b/tests/test-evolve.t	Wed Nov 23 21:00:42 2016 +0530
@@ -1301,9 +1301,11 @@ 
   created new head
   $ hg prune '26 + 27'
   abort: cannot prune in the middle of a stack
+  (new unstable changesets are not allowed)
   [255]
   $ hg prune '19::28'
   abort: cannot prune in the middle of a stack
+  (new unstable changesets are not allowed)
   [255]
   $ hg prune '26::'
   3 changesets pruned
@@ -1338,9 +1340,11 @@ 
 
   $ hg fold --exact "19 + 18"
   abort: cannot fold chain not ending with a head or with branching
+  (new unstable changesets are not allowed)
   [255]
   $ hg fold --exact "18::29"
   abort: cannot fold chain not ending with a head or with branching
+  (new unstable changesets are not allowed)
   [255]
   $ hg fold --exact "19::"
   2 changesets folded
@@ -1483,10 +1487,11 @@ 
 check that metaedit respects allowunstable
   $ hg metaedit '.^' --config 'experimental.evolution=createmarkers, allnewcommands'
   abort: cannot edit commit information in the middle of a stack
-  (c904da5245b0 will be affected)
+  (c904da5245b0 will become unstable and new unstable changes are not allowed)
   [255]
   $ hg metaedit '18::20' --fold --config 'experimental.evolution=createmarkers, allnewcommands'
   abort: cannot fold chain not ending with a head or with branching
+  (new unstable changesets are not allowed)
   [255]
   $ hg metaedit --user foobar
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved