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.
--- 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