topic: prepare to handle non-string arguments to topic() revset
authorAnton Shestakov <av6@dwimlabs.net>
Thu, 30 Aug 2018 18:02:41 +0800
changeset 4058 90783c9c8609
parent 4057 054d288680b4
child 4059 1914a53fe792
topic: prepare to handle non-string arguments to topic() revset
hgext3rd/topic/revset.py
--- a/hgext3rd/topic/revset.py	Thu Aug 30 17:42:11 2018 +0800
+++ b/hgext3rd/topic/revset.py	Thu Aug 30 18:02:41 2018 +0800
@@ -1,6 +1,7 @@
 from __future__ import absolute_import
 
 from mercurial import (
+    error,
     registrar,
     revset,
     util,
@@ -38,9 +39,13 @@
 
     if not args:
         return (subset & mutable).filter(lambda r: bool(repo[r].topic()))
+
+    try:
+        topic = revset.getstring(args[0], 'topic() argument must be a string')
+    except error.ParseError:
+        # not a string, but another revset
+        raise
     else:
-        # match a specific topic
-        topic = revset.getstring(args[0], 'topic() argument must be a string')
         if topic == '.':
             topic = repo['.'].extra().get('topic', '')
         _kind, _pattern, matcher = mkmatcher(topic)