changeset 40482:fbd168455b26 stable

histedit: crashing with a more useful error message on empty defaultrev Before this, `hg --config histedit.defaultrev= histedit` would crash with File "destutil.py", line 385, in desthistedit if revs: UnboundLocalError: local variable 'revs' referenced before assignment Differential Revision: https://phab.mercurial-scm.org/D5543
author rdamazio@google.com
date Wed, 09 Jan 2019 20:00:35 -0800
parents f467c353298c
children 6242a19004ca 593718ff5844
files mercurial/destutil.py tests/test-histedit-arguments.t
diffstat 2 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/destutil.py	Mon Jan 07 19:00:54 2019 -0500
+++ b/mercurial/destutil.py	Wed Jan 09 20:00:35 2019 -0800
@@ -381,6 +381,8 @@
         revs = stack.getstack(repo)
     elif default:
         revs = scmutil.revrange(repo, [default])
+    else:
+        raise error.Abort(_("config option histedit.defaultrev can't be empty"))
 
     if revs:
         # Take the first revision of the revset as the root
--- a/tests/test-histedit-arguments.t	Mon Jan 07 19:00:54 2019 -0500
+++ b/tests/test-histedit-arguments.t	Wed Jan 09 20:00:35 2019 -0800
@@ -112,6 +112,13 @@
   > pick 08d98a8350f3 4 five
   > EOF
 
+Test invalid config default
+---------------------------
+
+  $ hg histedit --config "histedit.defaultrev="
+  abort: config option histedit.defaultrev can't be empty
+  [255]
+
 Run on a revision not descendants of the initial parent
 --------------------------------------------------------------------