author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
Fri, 24 Mar 2017 09:21:05 +0100 | |
changeset 2227 | 4b621b56e3a1 |
parent 1986 | 042356d5ba59 |
child 2650 | db788700ed82 |
permissions | -rw-r--r-- |
1935
11d740319280
revset: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1923
diff
changeset
|
1 |
from __future__ import absolute_import |
11d740319280
revset: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1923
diff
changeset
|
2 |
|
1923 | 3 |
from mercurial.i18n import _ |
1935
11d740319280
revset: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1923
diff
changeset
|
4 |
from mercurial import ( |
11d740319280
revset: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1923
diff
changeset
|
5 |
error, |
11d740319280
revset: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1923
diff
changeset
|
6 |
revset, |
11d740319280
revset: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1923
diff
changeset
|
7 |
util, |
11d740319280
revset: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1923
diff
changeset
|
8 |
) |
1843
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
9 |
|
1935
11d740319280
revset: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1923
diff
changeset
|
10 |
from . import ( |
11d740319280
revset: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1923
diff
changeset
|
11 |
constants, |
11d740319280
revset: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1923
diff
changeset
|
12 |
destination, |
11d740319280
revset: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1923
diff
changeset
|
13 |
stack, |
11d740319280
revset: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1923
diff
changeset
|
14 |
) |
1845
24d8053020a2
constants: extract key for extra into a constant
Augie Fackler <augie@google.com>
parents:
1843
diff
changeset
|
15 |
|
1865
558dd43b599d
topic: work around stringmatcher moving during development of hg 3.6
Augie Fackler <raf@durin42.com>
parents:
1864
diff
changeset
|
16 |
try: |
558dd43b599d
topic: work around stringmatcher moving during development of hg 3.6
Augie Fackler <raf@durin42.com>
parents:
1864
diff
changeset
|
17 |
mkmatcher = revset._stringmatcher |
558dd43b599d
topic: work around stringmatcher moving during development of hg 3.6
Augie Fackler <raf@durin42.com>
parents:
1864
diff
changeset
|
18 |
except AttributeError: |
558dd43b599d
topic: work around stringmatcher moving during development of hg 3.6
Augie Fackler <raf@durin42.com>
parents:
1864
diff
changeset
|
19 |
mkmatcher = util.stringmatcher |
558dd43b599d
topic: work around stringmatcher moving during development of hg 3.6
Augie Fackler <raf@durin42.com>
parents:
1864
diff
changeset
|
20 |
|
558dd43b599d
topic: work around stringmatcher moving during development of hg 3.6
Augie Fackler <raf@durin42.com>
parents:
1864
diff
changeset
|
21 |
|
1843
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
22 |
def topicset(repo, subset, x): |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
23 |
"""`topic([topic])` |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
24 |
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
|
25 |
|
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
26 |
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
|
27 |
as a regular expression. |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
28 |
|
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
29 |
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
|
30 |
""" |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
31 |
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
|
32 |
if args: |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
33 |
# match a specific topic |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
34 |
topic = revset.getstring(args[0], 'topic() argument must be a string') |
1864
70d1191fceed
topic: allow use of topic(.) to match the p1 topic
Augie Fackler <raf@durin42.com>
parents:
1845
diff
changeset
|
35 |
if topic == '.': |
70d1191fceed
topic: allow use of topic(.) to match the p1 topic
Augie Fackler <raf@durin42.com>
parents:
1845
diff
changeset
|
36 |
topic = repo['.'].extra().get('topic', '') |
1865
558dd43b599d
topic: work around stringmatcher moving during development of hg 3.6
Augie Fackler <raf@durin42.com>
parents:
1864
diff
changeset
|
37 |
_kind, _pattern, matcher = mkmatcher(topic) |
1843
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
38 |
else: |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
39 |
matcher = lambda t: bool(t) |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
40 |
drafts = subset.filter(lambda r: repo[r].mutable()) |
1845
24d8053020a2
constants: extract key for extra into a constant
Augie Fackler <augie@google.com>
parents:
1843
diff
changeset
|
41 |
return drafts.filter( |
24d8053020a2
constants: extract key for extra into a constant
Augie Fackler <augie@google.com>
parents:
1843
diff
changeset
|
42 |
lambda r: matcher(repo[r].extra().get(constants.extrakey, ''))) |
1843
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
43 |
|
1870
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
44 |
def ngtipset(repo, subset, x): |
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
45 |
"""`ngtip([branch])` |
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
46 |
|
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
47 |
The untopiced tip. |
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
48 |
|
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
49 |
Name is horrible so that people change it. |
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
50 |
""" |
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
51 |
args = revset.getargs(x, 1, 1, 'topic takes one') |
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
52 |
# match a specific topic |
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
53 |
branch = revset.getstring(args[0], 'ngtip() argument must be a string') |
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
54 |
if branch == '.': |
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
55 |
branch = repo['.'].branch() |
1986
042356d5ba59
ngtip: rely on topicmap for 'ngtip'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1943
diff
changeset
|
56 |
return subset & revset.baseset(destination.ngtip(repo, branch)) |
1870
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
57 |
|
1910
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
58 |
def stackset(repo, subset, x): |
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
59 |
"""`stack()` |
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
60 |
All relevant changes in the current topic, |
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
61 |
|
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
62 |
This is roughly equivalent to 'topic(.) - obsolete' with a sorting moving |
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
63 |
unstable changeset after there future parent (as if evolve where already |
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
64 |
run).""" |
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
65 |
topic = repo.currenttopic |
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
66 |
if not topic: |
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
67 |
raise error.Abort(_('no active topic to list')) |
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
68 |
# ordering hack, boo |
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
69 |
return revset.baseset(stack.getstack(repo, topic)) & subset |
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
70 |
|
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
71 |
|
1943
cd56f4d8b5a3
revset: add a ui argument to 'modsetup'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1935
diff
changeset
|
72 |
def modsetup(ui): |
1843
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
73 |
revset.symbols.update({'topic': topicset}) |
1870
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
74 |
revset.symbols.update({'ngtip': ngtipset}) |
1910
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
75 |
revset.symbols.update({'stack': stackset}) |