author | Pulkit Goyal <7895pulkit@gmail.com> |
Tue, 04 Jul 2017 01:30:14 +0530 | |
changeset 2712 | f19b314d8475 |
parent 2692 | 96843c68acc8 |
child 2915 | b3abdb3d819e |
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 |
|
11d740319280
revset: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1923
diff
changeset
|
3 |
from mercurial import ( |
11d740319280
revset: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1923
diff
changeset
|
4 |
revset, |
11d740319280
revset: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1923
diff
changeset
|
5 |
util, |
11d740319280
revset: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1923
diff
changeset
|
6 |
) |
1843
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
7 |
|
1935
11d740319280
revset: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1923
diff
changeset
|
8 |
from . import ( |
11d740319280
revset: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1923
diff
changeset
|
9 |
constants, |
11d740319280
revset: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1923
diff
changeset
|
10 |
destination, |
11d740319280
revset: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1923
diff
changeset
|
11 |
stack, |
11d740319280
revset: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1923
diff
changeset
|
12 |
) |
1845
24d8053020a2
constants: extract key for extra into a constant
Augie Fackler <augie@google.com>
parents:
1843
diff
changeset
|
13 |
|
1865
558dd43b599d
topic: work around stringmatcher moving during development of hg 3.6
Augie Fackler <raf@durin42.com>
parents:
1864
diff
changeset
|
14 |
try: |
558dd43b599d
topic: work around stringmatcher moving during development of hg 3.6
Augie Fackler <raf@durin42.com>
parents:
1864
diff
changeset
|
15 |
mkmatcher = revset._stringmatcher |
558dd43b599d
topic: work around stringmatcher moving during development of hg 3.6
Augie Fackler <raf@durin42.com>
parents:
1864
diff
changeset
|
16 |
except AttributeError: |
558dd43b599d
topic: work around stringmatcher moving during development of hg 3.6
Augie Fackler <raf@durin42.com>
parents:
1864
diff
changeset
|
17 |
mkmatcher = util.stringmatcher |
558dd43b599d
topic: work around stringmatcher moving during development of hg 3.6
Augie Fackler <raf@durin42.com>
parents:
1864
diff
changeset
|
18 |
|
558dd43b599d
topic: work around stringmatcher moving during development of hg 3.6
Augie Fackler <raf@durin42.com>
parents:
1864
diff
changeset
|
19 |
|
1843
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
20 |
def topicset(repo, subset, x): |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
21 |
"""`topic([topic])` |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
22 |
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
|
23 |
|
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
24 |
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
|
25 |
as a regular expression. |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
26 |
|
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
27 |
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
|
28 |
""" |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
29 |
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
|
30 |
if args: |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
31 |
# match a specific topic |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
32 |
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
|
33 |
if topic == '.': |
70d1191fceed
topic: allow use of topic(.) to match the p1 topic
Augie Fackler <raf@durin42.com>
parents:
1845
diff
changeset
|
34 |
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
|
35 |
_kind, _pattern, matcher = mkmatcher(topic) |
1843
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
36 |
else: |
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
37 |
matcher = lambda t: bool(t) |
2686
fc3a66ad635b
compat: fix topicset for mercurial 4.1
Boris Feld <boris.feld@octobus.net>
parents:
2682
diff
changeset
|
38 |
|
2692
96843c68acc8
topic: directly use the '_notpublic' revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2686
diff
changeset
|
39 |
mutable = revset._notpublic(repo, revset.fullreposet(repo), ()) |
2651
6a3df2404472
topic-revset: update the revset to no longer build changectx
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2650
diff
changeset
|
40 |
|
6a3df2404472
topic-revset: update the revset to no longer build changectx
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2650
diff
changeset
|
41 |
rawchange = repo.changelog.changelogrevision |
6a3df2404472
topic-revset: update the revset to no longer build changectx
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2650
diff
changeset
|
42 |
key = constants.extrakey |
6a3df2404472
topic-revset: update the revset to no longer build changectx
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2650
diff
changeset
|
43 |
|
6a3df2404472
topic-revset: update the revset to no longer build changectx
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2650
diff
changeset
|
44 |
def matchtopic(r): |
6a3df2404472
topic-revset: update the revset to no longer build changectx
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2650
diff
changeset
|
45 |
topic = rawchange(r).extra.get(key) |
6a3df2404472
topic-revset: update the revset to no longer build changectx
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2650
diff
changeset
|
46 |
if topic is None: |
6a3df2404472
topic-revset: update the revset to no longer build changectx
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2650
diff
changeset
|
47 |
return False |
6a3df2404472
topic-revset: update the revset to no longer build changectx
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2650
diff
changeset
|
48 |
return matcher(topic) |
6a3df2404472
topic-revset: update the revset to no longer build changectx
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2650
diff
changeset
|
49 |
return (subset & mutable).filter(matchtopic) |
1843
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
50 |
|
1870
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
51 |
def ngtipset(repo, subset, x): |
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
52 |
"""`ngtip([branch])` |
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
53 |
|
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
54 |
The untopiced tip. |
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
55 |
|
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
56 |
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
|
57 |
""" |
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
58 |
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
|
59 |
# match a specific topic |
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
60 |
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
|
61 |
if branch == '.': |
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
62 |
branch = repo['.'].branch() |
1986
042356d5ba59
ngtip: rely on topicmap for 'ngtip'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1943
diff
changeset
|
63 |
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
|
64 |
|
1910
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
65 |
def stackset(repo, subset, x): |
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
66 |
"""`stack()` |
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
67 |
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
|
68 |
|
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
69 |
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
|
70 |
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
|
71 |
run).""" |
2681
aa4db71a6224
topics: return a parse error if stack() revset is passed with argument
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2669
diff
changeset
|
72 |
err = 'stack() takes no argument, it works on current topic' |
aa4db71a6224
topics: return a parse error if stack() revset is passed with argument
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2669
diff
changeset
|
73 |
revset.getargs(x, 0, 0, err) |
1910
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
74 |
topic = repo.currenttopic |
2669
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2668
diff
changeset
|
75 |
topic = None |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2668
diff
changeset
|
76 |
branch = None |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2668
diff
changeset
|
77 |
if not topic and repo.currenttopic: |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2668
diff
changeset
|
78 |
topic = repo.currenttopic |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2668
diff
changeset
|
79 |
if not topic: |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2668
diff
changeset
|
80 |
branch = repo[None].branch() |
2712
f19b314d8475
topics: add t0 and b0 to the stack
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2692
diff
changeset
|
81 |
return revset.baseset(stack.getstack(repo, branch=branch, topic=topic)[1:]) & subset |
1910
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
82 |
|
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
83 |
|
1943
cd56f4d8b5a3
revset: add a ui argument to 'modsetup'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1935
diff
changeset
|
84 |
def modsetup(ui): |
1843
0ba067a97d06
revset: add a topic() revset for querying topics
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
85 |
revset.symbols.update({'topic': topicset}) |
1870
8dd5200b4086
topic: introduce a 'ngtip' concept
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1865
diff
changeset
|
86 |
revset.symbols.update({'ngtip': ngtipset}) |
1910
24986e5a537c
stack: add a 'stack()' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1901
diff
changeset
|
87 |
revset.symbols.update({'stack': stackset}) |