Patchwork [5,of,5,EVOLVE] fold: improve error messages for multiple heads and roots

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date June 30, 2014, 6:28 p.m.
Message ID <a8b505057e4e4bac8ffa.1404152912@Iris>
Download mbox | patch
Permalink /patch/5087/
State Changes Requested
Headers show

Comments

Jordi Gutiérrez Hermoso - June 30, 2014, 6:28 p.m.
# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh@octave.org>
# Date 1404149929 14400
#      Mon Jun 30 13:38:49 2014 -0400
# Node ID a8b505057e4e4bac8ffa54bd0f89ef7eaa03edc6
# Parent  410a9c3b3232bbb0fd6cd4427b0174311c3ce803
fold: improve error messages for multiple heads and roots

This commit adds hints and i18n to the error messages about non-linear
revisions, along with corresponding tests.
Pierre-Yves David - June 30, 2014, 7 p.m.
On 06/30/2014 08:28 PM, Jordi Gutiérrez Hermoso wrote:
> # HG changeset patch
> # User Jordi Gutiérrez Hermoso <jordigh@octave.org>
> # Date 1404149929 14400
> #      Mon Jun 30 13:38:49 2014 -0400
> # Node ID a8b505057e4e4bac8ffa54bd0f89ef7eaa03edc6
> # Parent  410a9c3b3232bbb0fd6cd4427b0174311c3ce803
> fold: improve error messages for multiple heads and roots
>
> This commit adds hints and i18n to the error messages about non-linear
> revisions, along with corresponding tests.
>
> diff --git a/hgext/evolve.py b/hgext/evolve.py
> --- a/hgext/evolve.py
> +++ b/hgext/evolve.py
> @@ -2116,13 +2116,15 @@ def fold(ui, repo, *revs, **opts):
>
>       roots = repo.revs('roots(%ld)', revs)
>       if len(roots) > 1:
> -        raise util.Abort("set has multiple roots")
> +        raise util.Abort(_("cannot fold non-linear revisions"),
> +                           hint=_("multiple roots detected"))

The hint is usually used to transmit an action that can be carried to 
solve the situation.

What about moving this back in the message:

   cannot fold non linear revisions (multiple roots)

>       root = repo[roots[0]]
>       if root.phase() <= phases.public:
>           raise util.Abort(_("cannot fold public revisions"))
>       heads = repo.revs('heads(%ld)', revs)
>       if len(heads) > 1:
> -        raise util.Abort("set has multiple heads")
> +        raise util.Abort(_("cannot fold non-linear revisions"),
> +                           hint=_("multiple heads detected"))

Ditto.

>       head = repo[heads[0]]
>       wlock = lock = None
>       try:
> diff --git a/tests/test-evolve.t b/tests/test-evolve.t
> --- a/tests/test-evolve.t
> +++ b/tests/test-evolve.t
> @@ -619,6 +619,14 @@ Test fold
>     $ hg fold .
>     single revision specified, nothing to fold
>     [1]
> +  $ hg fold 0::10 --rev 1 --exact
> +  abort: cannot fold non-linear revisions
> +  (multiple heads detected)
> +  [255]
> +  $ hg fold -r 4 -r 6 --exact
> +  abort: cannot fold non-linear revisions
> +  (multiple roots detected)
> +  [255]
>     $ hg fold 10 1
>     abort: cannot fold non-linear revisions
>     (given revisions are unrelated to parent of working directory)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -2116,13 +2116,15 @@  def fold(ui, repo, *revs, **opts):
 
     roots = repo.revs('roots(%ld)', revs)
     if len(roots) > 1:
-        raise util.Abort("set has multiple roots")
+        raise util.Abort(_("cannot fold non-linear revisions"),
+                           hint=_("multiple roots detected"))
     root = repo[roots[0]]
     if root.phase() <= phases.public:
         raise util.Abort(_("cannot fold public revisions"))
     heads = repo.revs('heads(%ld)', revs)
     if len(heads) > 1:
-        raise util.Abort("set has multiple heads")
+        raise util.Abort(_("cannot fold non-linear revisions"),
+                           hint=_("multiple heads detected"))
     head = repo[heads[0]]
     wlock = lock = None
     try:
diff --git a/tests/test-evolve.t b/tests/test-evolve.t
--- a/tests/test-evolve.t
+++ b/tests/test-evolve.t
@@ -619,6 +619,14 @@  Test fold
   $ hg fold .
   single revision specified, nothing to fold
   [1]
+  $ hg fold 0::10 --rev 1 --exact
+  abort: cannot fold non-linear revisions
+  (multiple heads detected)
+  [255]
+  $ hg fold -r 4 -r 6 --exact
+  abort: cannot fold non-linear revisions
+  (multiple roots detected)
+  [255]
   $ hg fold 10 1
   abort: cannot fold non-linear revisions
   (given revisions are unrelated to parent of working directory)