topic: return result early if there are no arguments to topic() revset
authorAnton Shestakov <av6@dwimlabs.net>
Thu, 30 Aug 2018 17:42:11 +0800
changeset 4057 054d288680b4
parent 4056 235f15c40556
child 4058 90783c9c8609
topic: return result early if there are no arguments to topic() revset
hgext3rd/topic/revset.py
--- a/hgext3rd/topic/revset.py	Fri Aug 31 00:31:01 2018 +0200
+++ b/hgext3rd/topic/revset.py	Thu Aug 30 17:42:11 2018 +0800
@@ -33,16 +33,17 @@
     TODO: make `topic(revset)` work the same as `branch(revset)`.
     """
     args = revset.getargs(x, 0, 1, 'topic takes one or no arguments')
-    if args:
+
+    mutable = revset._notpublic(repo, revset.fullreposet(repo), ())
+
+    if not args:
+        return (subset & mutable).filter(lambda r: bool(repo[r].topic()))
+    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)
-    else:
-        matcher = lambda t: bool(t)
-
-    mutable = revset._notpublic(repo, revset.fullreposet(repo), ())
 
     rawchange = repo.changelog.changelogrevision
     key = constants.extrakey