# HG changeset patch # User Anton Shestakov # Date 1536060619 -28800 # Node ID aabf436c11cb0b87f210bd00acde01bf6a5b309c # Parent 0171a7ceb5742ba09304afd7f3ab258e9de4228e topic: refactor revset.py slightly Checking both kind == 'literal' and topic.startswith('literal:') seems to be redundant, because of how stringutil.stringmatcher() works. diff -r 0171a7ceb574 -r aabf436c11cb hgext3rd/topic/revset.py --- a/hgext3rd/topic/revset.py Wed Sep 12 12:02:17 2018 +0200 +++ b/hgext3rd/topic/revset.py Tue Sep 04 19:30:19 2018 +0800 @@ -24,7 +24,7 @@ revsetpredicate = registrar.revsetpredicate() def getstringstrict(x, err): - if x and (x[0] == 'string'): + if x and x[0] == 'string': return x[1] raise error.ParseError(err) @@ -51,25 +51,19 @@ else: kind, pattern, matcher = mkmatcher(topic) + if topic.startswith('literal:') and pattern not in repo.topics: + raise error.RepoLookupError("topic '%s' does not exist" % pattern) + def matches(r): topic = repo[r].topic() if not topic: return False return matcher(topic) - if kind == 'literal': - # note: falls through to the revset case if no topic with this name - # exists and pattern kind is not specified explicitly - - 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) + return (subset & mutable).filter(matches) s = revset.getset(repo, revset.fullreposet(repo), x) - topics = set(repo[r].topic() for r in s) + topics = {repo[r].topic() for r in s} topics.discard('') def matches(r):