topic-revset: get the list of revset through the official localrepo API
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sat, 01 Sep 2018 14:00:41 +0200
changeset 4064 a2c0133006c6
parent 4063 00c65abf99cd
child 4065 fbc51e98cf13
topic-revset: get the list of revset through the official localrepo API This is simpler and faster. In addition we tighter the logic to be used in case of empty topic. We do not need to fall back to revision search.
hgext3rd/topic/revset.py
--- a/hgext3rd/topic/revset.py	Sat Sep 01 21:47:00 2018 +0200
+++ b/hgext3rd/topic/revset.py	Sat Sep 01 14:00:41 2018 +0200
@@ -61,17 +61,10 @@
             # note: falls through to the revset case if no topic with this name
             # exists and pattern kind is not specified explicitly
 
-            alltopics = set([repo.currenttopic])
-            for r in repo.unfiltered().set('all()'):
-                alltopics.add(r.topic(force=True))
-            alltopics.discard('')
-
-            if pattern in alltopics:
-                return (subset & mutable).filter(matches)
-
-            if topic.startswith('literal:'):
+            if pattern not in repo.topics and topic.startswith('literal:'):
                 raise error.RepoLookupError("topic '%s' does not exist"
                                             % pattern)
+            return (subset & mutable).filter(matches)
         else:
             return (subset & mutable).filter(matches)