[PATCH 5 of 5 topic-experiment] topics: abort if user wants to show the stack of a non-existent topic
Pulkit Goyal
7895pulkit at gmail.com
Sun Jun 18 18:12:24 EDT 2017
# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1497822215 -19800
# Mon Jun 19 03:13:35 2017 +0530
# Node ID 8d8ac3adc1f9e03625d293ae78f250b115154d94
# Parent 83df91589000c05359805c96fa84a3995896ee3c
topics: abort if user wants to show the stack of a non-existent topic
diff --git a/hgext3rd/topic/stack.py b/hgext3rd/topic/stack.py
--- a/hgext3rd/topic/stack.py
+++ b/hgext3rd/topic/stack.py
@@ -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 = []
diff --git a/tests/test-topic-stack.t b/tests/test-topic-stack.t
--- a/tests/test-topic-stack.t
+++ b/tests/test-topic-stack.t
@@ -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]
More information about the Mercurial-devel
mailing list