Mercurial > evolve
comparison hgext3rd/topic/revset.py @ 1901:85390446f8c1
packaging: fix setup.py and install as hgext3rd.topic
This changeset is doing two things (gasp):
- It fixes various errors in the setup.py
- It move the topic source and install into hgext3rd.topic.
This last part (code source move) use hgext3rd as namespace package to prevent
installation nightmare. This won't be officially supported until Mercurial 3.8,
but in the meantime, 3.7 user can enable it using the full package name:
[extensions]
hgext3rd.topic=
Thanks goes to Julien Cristau <julien.cristau@logilab.fr> for the initial
version of this.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Thu, 17 Mar 2016 09:12:18 -0700 |
parents | src/topic/revset.py@8dd5200b4086 |
children | 24986e5a537c |
comparison
equal
deleted
inserted
replaced
1899:b65f39791f92 | 1901:85390446f8c1 |
---|---|
1 from mercurial import revset | |
2 from mercurial import util | |
3 | |
4 from . import constants, destination | |
5 | |
6 try: | |
7 mkmatcher = revset._stringmatcher | |
8 except AttributeError: | |
9 mkmatcher = util.stringmatcher | |
10 | |
11 | |
12 def topicset(repo, subset, x): | |
13 """`topic([topic])` | |
14 Specified topic or all changes with any topic specified. | |
15 | |
16 If `topic` starts with `re:` the remainder of the name is treated | |
17 as a regular expression. | |
18 | |
19 TODO: make `topic(revset)` work the same as `branch(revset)`. | |
20 """ | |
21 args = revset.getargs(x, 0, 1, 'topic takes one or no arguments') | |
22 if args: | |
23 # match a specific topic | |
24 topic = revset.getstring(args[0], 'topic() argument must be a string') | |
25 if topic == '.': | |
26 topic = repo['.'].extra().get('topic', '') | |
27 _kind, _pattern, matcher = mkmatcher(topic) | |
28 else: | |
29 matcher = lambda t: bool(t) | |
30 drafts = subset.filter(lambda r: repo[r].mutable()) | |
31 return drafts.filter( | |
32 lambda r: matcher(repo[r].extra().get(constants.extrakey, ''))) | |
33 | |
34 def ngtipset(repo, subset, x): | |
35 """`ngtip([branch])` | |
36 | |
37 The untopiced tip. | |
38 | |
39 Name is horrible so that people change it. | |
40 """ | |
41 args = revset.getargs(x, 1, 1, 'topic takes one') | |
42 # match a specific topic | |
43 branch = revset.getstring(args[0], 'ngtip() argument must be a string') | |
44 if branch == '.': | |
45 branch = repo['.'].branch() | |
46 return subset & destination.ngtip(repo, branch) | |
47 | |
48 def modsetup(): | |
49 revset.symbols.update({'topic': topicset}) | |
50 revset.symbols.update({'ngtip': ngtipset}) |