diff hgext3rd/topic/revset.py @ 4058:90783c9c8609

topic: prepare to handle non-string arguments to topic() revset
author Anton Shestakov <av6@dwimlabs.net>
date Thu, 30 Aug 2018 18:02:41 +0800
parents 054d288680b4
children 1914a53fe792
line wrap: on
line diff
--- 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)