[PATCH 02 of 10] rebase: improve error message for empty --rev set

Julien Cristau julien.cristau at logilab.fr
Wed Apr 23 08:17:41 CDT 2014


On Sun, Jan 12, 2014 at 17:08:00 +0100, Mads Kiilerich wrote:

> # HG changeset patch
> # User Mads Kiilerich <madski at unity3d.com>
> # Date 1384634789 18000
> #      Sat Nov 16 15:46:29 2013 -0500
> # Node ID d4c3a8ae89b0e2bf1e8a0bebb3fd6ba49ad1ac62
> # Parent  e3be09b53038b39614eff4e57b47896cca103a31
> rebase: improve error message for empty --rev set
> 
> Before it just said 'nothing to rebase', now it also hints to the reason:
> 'rev revset is empty'.
> 
Hi,

this changeset breaks my expectation (and the documentation) that hg
rebase exits 1 if it has nothing to do.  I don't really understand why
empty --rev set is any more of a hard error than other cases where
there's nothing to rebase.
E.g. the code at
http://hg.logilab.org/master/cubes/vcreview/file/6540bef1775a/test/unittest_rebase.py#l206
relies on the previous behaviour, and explodes on 2.9.

Any chance I can sell you on the patch below?
(I'm not completely sure about the "source set" case, so it's not
included)

# HG changeset patch
# User Julien Cristau <julien.cristau at logilab.fr>
# Date 1398253895 -7200
#      Wed Apr 23 13:51:35 2014 +0200
# Branch stable
# Node ID 8a0d3c3e18434f39633ef165439763447beda7bf
# Parent  dae36d3e1c60465bfb56f210b4cb3b231f46e5dd
rebase: don't abort if we're asked to rebase an empty revset

The documentation says we exit 1 if we have nothing to do, so avoid
breaking that contract when we're passed an empty revset.

This was changed in http://www.selenic.com/hg/rev/a259f7b488ab to
improve the error message; keep the improved message, just not the
abort.

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -220,12 +220,13 @@ def rebase(ui, repo, **opts):
                 dest = scmutil.revsingle(repo, destf)
 
             if revf:
                 rebaseset = scmutil.revrange(repo, revf)
                 if not rebaseset:
-                    raise util.Abort(_('empty "rev" revision set - '
-                                       'nothing to rebase'))
+                    ui.status(_('empty "rev" revision set - '
+                                'nothing to rebase\n'))
+                    return 1
             elif srcf:
                 src = scmutil.revrange(repo, [srcf])
                 if not src:
                     raise util.Abort(_('empty "source" revision set - '
                                        'nothing to rebase'))
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
@@ -78,12 +78,12 @@ These fail:
   $ hg rebase --base 5 --rev 4
   abort: cannot specify both a revision and a base
   [255]
 
   $ hg rebase --rev '1 & !1'
-  abort: empty "rev" revision set - nothing to rebase
-  [255]
+  empty "rev" revision set - nothing to rebase
+  [1]
 
   $ hg rebase --source '1 & !1'
   abort: empty "source" revision set - nothing to rebase
   [255]
 

Cheers,
Julien
-- 
Julien Cristau          <julien.cristau at logilab.fr>
Logilab		        http://www.logilab.fr/
Informatique scientifique & gestion de connaissances


More information about the Mercurial-devel mailing list