equal
deleted
inserted
replaced
22 mkmatcher = util.stringmatcher |
22 mkmatcher = util.stringmatcher |
23 |
23 |
24 revsetpredicate = registrar.revsetpredicate() |
24 revsetpredicate = registrar.revsetpredicate() |
25 |
25 |
26 def getstringstrict(x, err): |
26 def getstringstrict(x, err): |
27 if x and (x[0] == 'string'): |
27 if x and x[0] == 'string': |
28 return x[1] |
28 return x[1] |
29 raise error.ParseError(err) |
29 raise error.ParseError(err) |
30 |
30 |
31 @revsetpredicate('topic([string or set])') |
31 @revsetpredicate('topic([string or set])') |
32 def topicset(repo, subset, x): |
32 def topicset(repo, subset, x): |
49 # not a string, but another revset |
49 # not a string, but another revset |
50 pass |
50 pass |
51 else: |
51 else: |
52 kind, pattern, matcher = mkmatcher(topic) |
52 kind, pattern, matcher = mkmatcher(topic) |
53 |
53 |
|
54 if topic.startswith('literal:') and pattern not in repo.topics: |
|
55 raise error.RepoLookupError("topic '%s' does not exist" % pattern) |
|
56 |
54 def matches(r): |
57 def matches(r): |
55 topic = repo[r].topic() |
58 topic = repo[r].topic() |
56 if not topic: |
59 if not topic: |
57 return False |
60 return False |
58 return matcher(topic) |
61 return matcher(topic) |
59 |
62 |
60 if kind == 'literal': |
63 return (subset & mutable).filter(matches) |
61 # note: falls through to the revset case if no topic with this name |
|
62 # exists and pattern kind is not specified explicitly |
|
63 |
|
64 if pattern not in repo.topics and topic.startswith('literal:'): |
|
65 raise error.RepoLookupError("topic '%s' does not exist" |
|
66 % pattern) |
|
67 return (subset & mutable).filter(matches) |
|
68 else: |
|
69 return (subset & mutable).filter(matches) |
|
70 |
64 |
71 s = revset.getset(repo, revset.fullreposet(repo), x) |
65 s = revset.getset(repo, revset.fullreposet(repo), x) |
72 topics = set(repo[r].topic() for r in s) |
66 topics = {repo[r].topic() for r in s} |
73 topics.discard('') |
67 topics.discard('') |
74 |
68 |
75 def matches(r): |
69 def matches(r): |
76 if r in s: |
70 if r in s: |
77 return True |
71 return True |