topic-revset: strictly read string
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sat, 01 Sep 2018 21:47:00 +0200
changeset 4063 00c65abf99cd
parent 4062 6774820c8a2e
child 4064 a2c0133006c6
topic-revset: strictly read string Making a clear distinction between string and symbol passed to topic is important when it comes to empty topic. Filtering an empty topic name is harmless. Searching a non existent revision is not.
hgext3rd/topic/revset.py
--- a/hgext3rd/topic/revset.py	Sat Sep 01 21:45:15 2018 +0200
+++ b/hgext3rd/topic/revset.py	Sat Sep 01 21:47:00 2018 +0200
@@ -23,6 +23,11 @@
 
 revsetpredicate = registrar.revsetpredicate()
 
+def getstringstrict(x, err):
+    if x and (x[0] == 'string'):
+        return x[1]
+    raise error.ParseError(err)
+
 @revsetpredicate('topic([string or set])')
 def topicset(repo, subset, x):
     """All changesets with the specified topic or the topics of the given
@@ -39,7 +44,7 @@
         return (subset & mutable).filter(lambda r: bool(repo[r].topic()))
 
     try:
-        topic = revset.getstring(args[0], '')
+        topic = getstringstrict(args[0], '')
     except error.ParseError:
         # not a string, but another revset
         pass