histedit: crashing with a more useful error message on empty defaultrev stable
authorrdamazio@google.com
Wed, 09 Jan 2019 20:00:35 -0800
branchstable
changeset 40482 fbd168455b26
parent 40481 f467c353298c
child 41215 6242a19004ca
child 41290 593718ff5844
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
mercurial/destutil.py
tests/test-histedit-arguments.t
--- 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
 --------------------------------------------------------------------