Patchwork [1,of,5,EVOLVE] fold: clarify message for empty revision set and abort instead (BC)

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date June 30, 2014, 6:28 p.m.
Message ID <5b362328531a3e47a18b.1404152908@Iris>
Download mbox | patch
Permalink /patch/5084/
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 1404138435 14400
#      Mon Jun 30 10:27:15 2014 -0400
# Node ID 5b362328531a3e47a18b21cb80659e81c37edf3a
# Parent  404a000bb38b0139ad93feb4327a5f2d1ea8c0f8
fold: clarify message for empty revision set and abort instead (BC)

I find it clearer that there are no revisions to fold because none
were specified. Otherwise it seems ambiguous: maybe there are no
revisions to fold because it's impossible to fold whatever was given?
In analogy of other commands that are given no revisions (e.g. strip,
graft), this is also now an abort instead of a mere error message,
which is a BC.

This patch also uses i18n and thus removes the usage of "_" as a
temporary variable.

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -2098,8 +2098,7 @@  def fold(ui, repo, *revs, **opts):
     else:
         revs = ()
     if not revs:
-        ui.write_err('no revision to fold\n')
-        return 1
+        raise util.Abort(_('no revisions specified'))
     roots = repo.revs('roots(%ld)', revs)
     if len(roots) > 1:
         raise util.Abort("set has multiple roots")
@@ -2129,9 +2128,9 @@  def fold(ui, repo, *revs, **opts):
                 commitopts['message'] =  "\n".join(msgs)
                 commitopts['edit'] = True
 
-            newid, _ = rewrite(repo, root, allctx, head,
-                             [root.p1().node(), root.p2().node()],
-                             commitopts=commitopts)
+            newid, unusedvariable = rewrite(repo, root, allctx, head,
+                                            [root.p1().node(), root.p2().node()],
+                                            commitopts=commitopts)
             phases.retractboundary(repo, targetphase, [newid])
             createmarkers(repo, [(ctx, (repo[newid],))
                                  for ctx in allctx])
diff --git a/tests/test-evolve.t b/tests/test-evolve.t
--- a/tests/test-evolve.t
+++ b/tests/test-evolve.t
@@ -614,8 +614,8 @@  Test fold
 
   $ rm *.orig
   $ hg fold
-  no revision to fold
-  [1]
+  abort: no revisions specified
+  [255]
   $ hg fold 6 --rev 10
   abort: cannot specify both --rev and a target revision
   [255]