topics: abort if user wants to show the stack of a non-existent topic
authorPulkit Goyal <7895pulkit@gmail.com>
Mon, 19 Jun 2017 03:13:35 +0530
changeset 2627 42abd3bd30ee
parent 2626 bc36a608e9e4
child 2630 8503ba8b82e3
topics: abort if user wants to show the stack of a non-existent topic
README
hgext3rd/topic/stack.py
tests/test-topic-stack.t
--- a/README	Mon Jun 19 02:50:35 2017 +0530
+++ b/README	Mon Jun 19 03:13:35 2017 +0530
@@ -125,6 +125,7 @@
 -------------------
 
  - stack: also show the unstable status for the current changeset (issue5553)
+ - stack: properly abort when and unknown topic is requested,
  - topic: fix issue5441 in the linear case,
 
 6.4.0 -- 2017-06-16
--- a/hgext3rd/topic/stack.py	Mon Jun 19 02:50:35 2017 +0530
+++ b/hgext3rd/topic/stack.py	Mon Jun 19 03:13:35 2017 +0530
@@ -22,6 +22,10 @@
     return ' '.join(prefix % suffix for suffix in labelssuffix)
 
 def showstack(ui, repo, topic, opts):
+
+    if topic not in repo.topics:
+        raise error.Abort(_('cannot resolve "%s": no such topic found') % topic)
+
     fm = ui.formatter('topicstack', opts)
     prev = None
     entries = []
--- a/tests/test-topic-stack.t	Mon Jun 19 02:50:35 2017 +0530
+++ b/tests/test-topic-stack.t	Mon Jun 19 03:13:35 2017 +0530
@@ -319,3 +319,11 @@
   t2@ c_D (current)
   t1: c_c
     ^ c_b
+
+Trying to list non existing topic
+  $ hg stack thisdoesnotexist
+  abort: cannot resolve "thisdoesnotexist": no such topic found
+  [255]
+  $ hg topic --list thisdoesnotexist
+  abort: cannot resolve "thisdoesnotexist": no such topic found
+  [255]