author | Augie Fackler <augie@google.com> |
Wed, 10 Jun 2015 15:03:39 -0400 | |
changeset 1844 | 862cabc132fd |
parent 1843 | 0ba067a97d06 |
child 1845 | 24d8053020a2 |
permissions | -rw-r--r-- |
1843
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
1 |
from mercurial import revset |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
2 |
|
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
3 |
def topicset(repo, subset, x): |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
4 |
"""`topic([topic])` |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
5 |
Specified topic or all changes with any topic specified. |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
6 |
|
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
7 |
If `topic` starts with `re:` the remainder of the name is treated |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
8 |
as a regular expression. |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
9 |
|
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
10 |
TODO: make `topic(revset)` work the same as `branch(revset)`. |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
11 |
""" |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
12 |
args = revset.getargs(x, 0, 1, 'topic takes one or no arguments') |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
13 |
if args: |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
14 |
# match a specific topic |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
15 |
topic = revset.getstring(args[0], 'topic() argument must be a string') |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
16 |
_kind, _pattern, matcher = revset._stringmatcher(topic) |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
17 |
else: |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
18 |
matcher = lambda t: bool(t) |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
19 |
drafts = subset.filter(lambda r: repo[r].mutable()) |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
20 |
return drafts.filter(lambda r: matcher(repo[r].extra().get('topic', ''))) |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
21 |
|
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
22 |
def modsetup(): |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
23 |
revset.symbols.update({'topic': topicset}) |