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

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

Comments

Mads Kiilerich - Jan. 15, 2014, 2:24 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1384634789 18000
#      Sat Nov 16 15:46:29 2013 -0500
# Node ID a259f7b488ab54d37ef1fd0574b583e2c63914fd
# Parent  e4dc4c89b03aec583bc95af794d7a497359264d1
rebase: improve error message for empty --rev set

Before, it just said 'nothing to rebase' in this case. Now, it aborts
mentioning the reason: 'empty "rev" 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.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -221,6 +221,9 @@  def rebase(ui, repo, **opts):
 
             if revf:
                 rebaseset = scmutil.revrange(repo, revf)
+                if not rebaseset:
+                    raise util.Abort(_('empty "rev" revision set - '
+                                       'nothing to rebase'))
             elif srcf:
                 src = scmutil.revrange(repo, [srcf])
                 rebaseset = repo.revs('(%ld)::', src)
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
@@ -79,6 +79,10 @@  These fail:
   abort: cannot specify both a revision and a base
   [255]
 
+  $ hg rebase --rev '1 & !1'
+  abort: empty "rev" revision set - nothing to rebase
+  [255]
+
   $ hg rebase
   nothing to rebase
   [1]