Patchwork [4,of,7,v2] rebase: improve error message for empty --source set

login
register
mail settings
Submitter Mads Kiilerich
Date Jan. 15, 2014, 2:24 a.m.
Message ID <3bff26f6716934d0c525.1389752683@localhost.localdomain>
Download mbox | patch
Permalink /patch/3327/
State Accepted
Headers show

Comments

Mads Kiilerich - Jan. 15, 2014, 2:24 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1384730518 18000
#      Sun Nov 17 18:21:58 2013 -0500
# Node ID 3bff26f6716934d0c5257784e857af9c6dfb153c
# Parent  a259f7b488ab54d37ef1fd0574b583e2c63914fd
rebase: improve error message for empty --source set

Before, it just said 'nothing to rebase' in this case. Now, it aborts
mentioning the reason: 'empty "source" revision set'.

Specifying revisions that cannot be rebased is a 'soft' error, but specifying
an empty set deserves an abort that explains exactly what the problem is.
Augie Fackler - Jan. 15, 2014, 4:05 p.m.
On Wed, Jan 15, 2014 at 03:24:43AM +0100, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1384730518 18000
> #      Sun Nov 17 18:21:58 2013 -0500
> # Node ID 3bff26f6716934d0c5257784e857af9c6dfb153c
> # Parent  a259f7b488ab54d37ef1fd0574b583e2c63914fd
> rebase: improve error message for empty --source set

okay, I lied on the other thread - I'm going to take 1 through 4 (inclusive) of this series, and will squint at 5-7 shortly.

>
> Before, it just said 'nothing to rebase' in this case. Now, it aborts
> mentioning the reason: 'empty "source" revision set'.
>
> Specifying revisions that cannot be rebased is a 'soft' error, but specifying
> an empty set deserves an abort that explains exactly what the problem is.
>
> diff --git a/hgext/rebase.py b/hgext/rebase.py
> --- a/hgext/rebase.py
> +++ b/hgext/rebase.py
> @@ -226,7 +226,11 @@ def rebase(ui, repo, **opts):
>                                         'nothing to rebase'))
>              elif srcf:
>                  src = scmutil.revrange(repo, [srcf])
> +                if not src:
> +                    raise util.Abort(_('empty "source" revision set - '
> +                                       'nothing to rebase'))
>                  rebaseset = repo.revs('(%ld)::', src)
> +                assert rebaseset
>              else:
>                  base = scmutil.revrange(repo, [basef or '.'])
>                  rebaseset = repo.revs(
> diff --git a/tests/test-rebase-parameters.t b/tests/test-rebase-parameters.t
> --- a/tests/test-rebase-parameters.t
> +++ b/tests/test-rebase-parameters.t
> @@ -83,6 +83,10 @@ These fail:
>    abort: empty "rev" revision set - nothing to rebase
>    [255]
>
> +  $ hg rebase --source '1 & !1'
> +  abort: empty "source" revision set - nothing to rebase
> +  [255]
> +
>    $ hg rebase
>    nothing to rebase
>    [1]
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -226,7 +226,11 @@  def rebase(ui, repo, **opts):
                                        'nothing to rebase'))
             elif srcf:
                 src = scmutil.revrange(repo, [srcf])
+                if not src:
+                    raise util.Abort(_('empty "source" revision set - '
+                                       'nothing to rebase'))
                 rebaseset = repo.revs('(%ld)::', src)
+                assert rebaseset
             else:
                 base = scmutil.revrange(repo, [basef or '.'])
                 rebaseset = repo.revs(
diff --git a/tests/test-rebase-parameters.t b/tests/test-rebase-parameters.t
--- a/tests/test-rebase-parameters.t
+++ b/tests/test-rebase-parameters.t
@@ -83,6 +83,10 @@  These fail:
   abort: empty "rev" revision set - nothing to rebase
   [255]
 
+  $ hg rebase --source '1 & !1'
+  abort: empty "source" revision set - nothing to rebase
+  [255]
+
   $ hg rebase
   nothing to rebase
   [1]