Mercurial > hg
annotate mercurial/revset.py @ 31866:1454726b6d7c
upgrade: drop the prefix to the 'blocksourcerequirements' function
Now that we are in the 'upgrade' module we can simplify the name.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Mon, 10 Apr 2017 17:56:29 +0200 |
parents | 81abd0d12c86 |
children | 5e3b49defbff |
rev | line source |
---|---|
11275 | 1 # revset.py - revision set queries for mercurial |
2 # | |
3 # Copyright 2010 Matt Mackall <mpm@selenic.com> | |
4 # | |
5 # This software may be used and distributed according to the terms of the | |
6 # GNU General Public License version 2 or any later version. | |
7 | |
25971
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
8 from __future__ import absolute_import |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
9 |
20690
13c0327eeb6f
revset: changed ancestors revset to return lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20659
diff
changeset
|
10 import heapq |
25971
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
11 import re |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
12 |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
13 from .i18n import _ |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
14 from . import ( |
26713
a271925699d6
revset: reintroduce and experimental revset for update destination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26638
diff
changeset
|
15 destutil, |
25971
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
16 encoding, |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
17 error, |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
18 hbisect, |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
19 match as matchmod, |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
20 node, |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
21 obsolete as obsmod, |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
22 pathutil, |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
23 phases, |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
24 registrar, |
25971
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
25 repoview, |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
26 revsetlang, |
30881
1be65deb3d54
smartset: move set classes and related functions from revset module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30850
diff
changeset
|
27 smartset, |
25971
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
28 util, |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
29 ) |
11275 | 30 |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
31 # helpers for processing parsed tree |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
32 getsymbol = revsetlang.getsymbol |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
33 getstring = revsetlang.getstring |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
34 getinteger = revsetlang.getinteger |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
35 getlist = revsetlang.getlist |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
36 getrange = revsetlang.getrange |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
37 getargs = revsetlang.getargs |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
38 getargsdict = revsetlang.getargsdict |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
39 |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
40 # constants used as an argument of match() and matchany() |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
41 anyorder = revsetlang.anyorder |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
42 defineorder = revsetlang.defineorder |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
43 followorder = revsetlang.followorder |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
44 |
30881
1be65deb3d54
smartset: move set classes and related functions from revset module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30850
diff
changeset
|
45 baseset = smartset.baseset |
1be65deb3d54
smartset: move set classes and related functions from revset module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30850
diff
changeset
|
46 generatorset = smartset.generatorset |
1be65deb3d54
smartset: move set classes and related functions from revset module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30850
diff
changeset
|
47 spanset = smartset.spanset |
1be65deb3d54
smartset: move set classes and related functions from revset module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30850
diff
changeset
|
48 fullreposet = smartset.fullreposet |
1be65deb3d54
smartset: move set classes and related functions from revset module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30850
diff
changeset
|
49 |
16409
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
50 def _revancestors(repo, revs, followfirst): |
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
51 """Like revlog.ancestors(), but supports followfirst.""" |
24306
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24219
diff
changeset
|
52 if followfirst: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24219
diff
changeset
|
53 cut = 1 |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24219
diff
changeset
|
54 else: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24219
diff
changeset
|
55 cut = None |
16409
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
56 cl = repo.changelog |
20690
13c0327eeb6f
revset: changed ancestors revset to return lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20659
diff
changeset
|
57 |
13c0327eeb6f
revset: changed ancestors revset to return lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20659
diff
changeset
|
58 def iterate(): |
22832
2f1d2a42f040
revancestors: replace `descending` with `sort(reverse=False)`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22831
diff
changeset
|
59 revs.sort(reverse=True) |
24939
85544a52ee84
revset: use an iterator instead of a dequeue in ancestors()
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24938
diff
changeset
|
60 irevs = iter(revs) |
20691
c1f666e27345
revset: optimized _revancestors method based on order of revisions
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20690
diff
changeset
|
61 h = [] |
c1f666e27345
revset: optimized _revancestors method based on order of revisions
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20690
diff
changeset
|
62 |
25143
91c49621b2b8
_revancestors: use 'next' to remove the verbose try except clauses
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25131
diff
changeset
|
63 inputrev = next(irevs, None) |
91c49621b2b8
_revancestors: use 'next' to remove the verbose try except clauses
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25131
diff
changeset
|
64 if inputrev is not None: |
24939
85544a52ee84
revset: use an iterator instead of a dequeue in ancestors()
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24938
diff
changeset
|
65 heapq.heappush(h, -inputrev) |
20691
c1f666e27345
revset: optimized _revancestors method based on order of revisions
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20690
diff
changeset
|
66 |
23956
b1e026c25552
revset: fix ancestors(null) to include null revision (issue4512)
Yuya Nishihara <yuya@tcha.org>
parents:
23954
diff
changeset
|
67 seen = set() |
20690
13c0327eeb6f
revset: changed ancestors revset to return lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20659
diff
changeset
|
68 while h: |
13c0327eeb6f
revset: changed ancestors revset to return lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20659
diff
changeset
|
69 current = -heapq.heappop(h) |
24940
6b54f749659b
revset: avoid returning duplicates when returning ancestors
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24939
diff
changeset
|
70 if current == inputrev: |
25143
91c49621b2b8
_revancestors: use 'next' to remove the verbose try except clauses
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25131
diff
changeset
|
71 inputrev = next(irevs, None) |
91c49621b2b8
_revancestors: use 'next' to remove the verbose try except clauses
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25131
diff
changeset
|
72 if inputrev is not None: |
24940
6b54f749659b
revset: avoid returning duplicates when returning ancestors
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
24939
diff
changeset
|
73 heapq.heappush(h, -inputrev) |
20690
13c0327eeb6f
revset: changed ancestors revset to return lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20659
diff
changeset
|
74 if current not in seen: |
13c0327eeb6f
revset: changed ancestors revset to return lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20659
diff
changeset
|
75 seen.add(current) |
13c0327eeb6f
revset: changed ancestors revset to return lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20659
diff
changeset
|
76 yield current |
13c0327eeb6f
revset: changed ancestors revset to return lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20659
diff
changeset
|
77 for parent in cl.parentrevs(current)[:cut]: |
13c0327eeb6f
revset: changed ancestors revset to return lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20659
diff
changeset
|
78 if parent != node.nullrev: |
13c0327eeb6f
revset: changed ancestors revset to return lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20659
diff
changeset
|
79 heapq.heappush(h, -parent) |
13c0327eeb6f
revset: changed ancestors revset to return lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20659
diff
changeset
|
80 |
22795
c21342159fad
generatorset: drop the leading underscore in the class name
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22794
diff
changeset
|
81 return generatorset(iterate(), iterasc=False) |
16409
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
82 |
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
83 def _revdescendants(repo, revs, followfirst): |
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
84 """Like revlog.descendants() but supports followfirst.""" |
24306
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24219
diff
changeset
|
85 if followfirst: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24219
diff
changeset
|
86 cut = 1 |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24219
diff
changeset
|
87 else: |
6ddc86eedc3b
style: kill ersatz if-else ternary operators
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24219
diff
changeset
|
88 cut = None |
16409
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
89 |
20692
7af341082b76
revset: changed descendants revset to use lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20691
diff
changeset
|
90 def iterate(): |
7af341082b76
revset: changed descendants revset to use lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20691
diff
changeset
|
91 cl = repo.changelog |
25549
f93ff3ab8d14
revset: mark spots that should use 'smartset.min()'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25548
diff
changeset
|
92 # XXX this should be 'parentset.min()' assuming 'parentset' is a |
f93ff3ab8d14
revset: mark spots that should use 'smartset.min()'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25548
diff
changeset
|
93 # smartset (and if it is not, it should.) |
20692
7af341082b76
revset: changed descendants revset to use lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20691
diff
changeset
|
94 first = min(revs) |
7af341082b76
revset: changed descendants revset to use lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20691
diff
changeset
|
95 nullrev = node.nullrev |
7af341082b76
revset: changed descendants revset to use lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20691
diff
changeset
|
96 if first == nullrev: |
7af341082b76
revset: changed descendants revset to use lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20691
diff
changeset
|
97 # Are there nodes with a null first parent and a non-null |
7af341082b76
revset: changed descendants revset to use lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20691
diff
changeset
|
98 # second one? Maybe. Do we care? Probably not. |
7af341082b76
revset: changed descendants revset to use lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20691
diff
changeset
|
99 for i in cl: |
16409
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
100 yield i |
20692
7af341082b76
revset: changed descendants revset to use lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20691
diff
changeset
|
101 else: |
7af341082b76
revset: changed descendants revset to use lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20691
diff
changeset
|
102 seen = set(revs) |
7af341082b76
revset: changed descendants revset to use lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20691
diff
changeset
|
103 for i in cl.revs(first + 1): |
7af341082b76
revset: changed descendants revset to use lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20691
diff
changeset
|
104 for x in cl.parentrevs(i)[:cut]: |
7af341082b76
revset: changed descendants revset to use lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20691
diff
changeset
|
105 if x != nullrev and x in seen: |
7af341082b76
revset: changed descendants revset to use lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20691
diff
changeset
|
106 seen.add(i) |
7af341082b76
revset: changed descendants revset to use lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20691
diff
changeset
|
107 yield i |
7af341082b76
revset: changed descendants revset to use lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20691
diff
changeset
|
108 break |
7af341082b76
revset: changed descendants revset to use lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20691
diff
changeset
|
109 |
22795
c21342159fad
generatorset: drop the leading underscore in the class name
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22794
diff
changeset
|
110 return generatorset(iterate(), iterasc=True) |
16409
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
111 |
26095
6eed95ca4c03
revset: mark reachablerootspure as private
Yuya Nishihara <yuya@tcha.org>
parents:
26094
diff
changeset
|
112 def _reachablerootspure(repo, minroot, roots, heads, includepath): |
26002
fd92bfbbe02d
revset: rename revsbetween to reachableroots and add an argument
Laurent Charignon <lcharignon@fb.com>
parents:
26001
diff
changeset
|
113 """return (heads(::<roots> and ::<heads>)) |
fd92bfbbe02d
revset: rename revsbetween to reachableroots and add an argument
Laurent Charignon <lcharignon@fb.com>
parents:
26001
diff
changeset
|
114 |
fd92bfbbe02d
revset: rename revsbetween to reachableroots and add an argument
Laurent Charignon <lcharignon@fb.com>
parents:
26001
diff
changeset
|
115 If includepath is True, return (<roots>::<heads>).""" |
16862
b6efeb27e733
revset: introduce and use _revsbetween
Bryan O'Sullivan <bryano@fb.com>
parents:
16861
diff
changeset
|
116 if not roots: |
26094
df41c7be16d6
reachableroots: construct and sort baseset in revset module
Yuya Nishihara <yuya@tcha.org>
parents:
26093
diff
changeset
|
117 return [] |
16862
b6efeb27e733
revset: introduce and use _revsbetween
Bryan O'Sullivan <bryano@fb.com>
parents:
16861
diff
changeset
|
118 parentrevs = repo.changelog.parentrevs |
26053
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26006
diff
changeset
|
119 roots = set(roots) |
22487
e40bb83d0989
revset: stop using a baseset instead of a plain list in _revsbetween
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22483
diff
changeset
|
120 visit = list(heads) |
16862
b6efeb27e733
revset: introduce and use _revsbetween
Bryan O'Sullivan <bryano@fb.com>
parents:
16861
diff
changeset
|
121 reachable = set() |
b6efeb27e733
revset: introduce and use _revsbetween
Bryan O'Sullivan <bryano@fb.com>
parents:
16861
diff
changeset
|
122 seen = {} |
25566
15412bba5a68
revset: prefetch all attributes before loop in _revsbetween
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25554
diff
changeset
|
123 # prefetch all the things! (because python is slow) |
15412bba5a68
revset: prefetch all attributes before loop in _revsbetween
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25554
diff
changeset
|
124 reached = reachable.add |
15412bba5a68
revset: prefetch all attributes before loop in _revsbetween
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25554
diff
changeset
|
125 dovisit = visit.append |
15412bba5a68
revset: prefetch all attributes before loop in _revsbetween
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25554
diff
changeset
|
126 nextvisit = visit.pop |
16862
b6efeb27e733
revset: introduce and use _revsbetween
Bryan O'Sullivan <bryano@fb.com>
parents:
16861
diff
changeset
|
127 # open-code the post-order traversal due to the tiny size of |
b6efeb27e733
revset: introduce and use _revsbetween
Bryan O'Sullivan <bryano@fb.com>
parents:
16861
diff
changeset
|
128 # sys.getrecursionlimit() |
b6efeb27e733
revset: introduce and use _revsbetween
Bryan O'Sullivan <bryano@fb.com>
parents:
16861
diff
changeset
|
129 while visit: |
25566
15412bba5a68
revset: prefetch all attributes before loop in _revsbetween
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25554
diff
changeset
|
130 rev = nextvisit() |
16862
b6efeb27e733
revset: introduce and use _revsbetween
Bryan O'Sullivan <bryano@fb.com>
parents:
16861
diff
changeset
|
131 if rev in roots: |
25566
15412bba5a68
revset: prefetch all attributes before loop in _revsbetween
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25554
diff
changeset
|
132 reached(rev) |
26002
fd92bfbbe02d
revset: rename revsbetween to reachableroots and add an argument
Laurent Charignon <lcharignon@fb.com>
parents:
26001
diff
changeset
|
133 if not includepath: |
fd92bfbbe02d
revset: rename revsbetween to reachableroots and add an argument
Laurent Charignon <lcharignon@fb.com>
parents:
26001
diff
changeset
|
134 continue |
16862
b6efeb27e733
revset: introduce and use _revsbetween
Bryan O'Sullivan <bryano@fb.com>
parents:
16861
diff
changeset
|
135 parents = parentrevs(rev) |
b6efeb27e733
revset: introduce and use _revsbetween
Bryan O'Sullivan <bryano@fb.com>
parents:
16861
diff
changeset
|
136 seen[rev] = parents |
b6efeb27e733
revset: introduce and use _revsbetween
Bryan O'Sullivan <bryano@fb.com>
parents:
16861
diff
changeset
|
137 for parent in parents: |
b6efeb27e733
revset: introduce and use _revsbetween
Bryan O'Sullivan <bryano@fb.com>
parents:
16861
diff
changeset
|
138 if parent >= minroot and parent not in seen: |
25566
15412bba5a68
revset: prefetch all attributes before loop in _revsbetween
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25554
diff
changeset
|
139 dovisit(parent) |
16862
b6efeb27e733
revset: introduce and use _revsbetween
Bryan O'Sullivan <bryano@fb.com>
parents:
16861
diff
changeset
|
140 if not reachable: |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
141 return baseset() |
26002
fd92bfbbe02d
revset: rename revsbetween to reachableroots and add an argument
Laurent Charignon <lcharignon@fb.com>
parents:
26001
diff
changeset
|
142 if not includepath: |
fd92bfbbe02d
revset: rename revsbetween to reachableroots and add an argument
Laurent Charignon <lcharignon@fb.com>
parents:
26001
diff
changeset
|
143 return reachable |
16862
b6efeb27e733
revset: introduce and use _revsbetween
Bryan O'Sullivan <bryano@fb.com>
parents:
16861
diff
changeset
|
144 for rev in sorted(seen): |
b6efeb27e733
revset: introduce and use _revsbetween
Bryan O'Sullivan <bryano@fb.com>
parents:
16861
diff
changeset
|
145 for parent in seen[rev]: |
b6efeb27e733
revset: introduce and use _revsbetween
Bryan O'Sullivan <bryano@fb.com>
parents:
16861
diff
changeset
|
146 if parent in reachable: |
25566
15412bba5a68
revset: prefetch all attributes before loop in _revsbetween
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25554
diff
changeset
|
147 reached(rev) |
26091
60bbd4f9abd1
reachableroots: sort the smartset in the pure version too
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26060
diff
changeset
|
148 return reachable |
16862
b6efeb27e733
revset: introduce and use _revsbetween
Bryan O'Sullivan <bryano@fb.com>
parents:
16861
diff
changeset
|
149 |
26006
1ffd97cbf9a2
reachableroots: default to the C implementation
Laurent Charignon <lcharignon@fb.com>
parents:
26002
diff
changeset
|
150 def reachableroots(repo, roots, heads, includepath=False): |
1ffd97cbf9a2
reachableroots: default to the C implementation
Laurent Charignon <lcharignon@fb.com>
parents:
26002
diff
changeset
|
151 """return (heads(::<roots> and ::<heads>)) |
1ffd97cbf9a2
reachableroots: default to the C implementation
Laurent Charignon <lcharignon@fb.com>
parents:
26002
diff
changeset
|
152 |
1ffd97cbf9a2
reachableroots: default to the C implementation
Laurent Charignon <lcharignon@fb.com>
parents:
26002
diff
changeset
|
153 If includepath is True, return (<roots>::<heads>).""" |
1ffd97cbf9a2
reachableroots: default to the C implementation
Laurent Charignon <lcharignon@fb.com>
parents:
26002
diff
changeset
|
154 if not roots: |
1ffd97cbf9a2
reachableroots: default to the C implementation
Laurent Charignon <lcharignon@fb.com>
parents:
26002
diff
changeset
|
155 return baseset() |
26093
204131131766
reachableroots: use smartset min
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26091
diff
changeset
|
156 minroot = roots.min() |
26053
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26006
diff
changeset
|
157 roots = list(roots) |
26006
1ffd97cbf9a2
reachableroots: default to the C implementation
Laurent Charignon <lcharignon@fb.com>
parents:
26002
diff
changeset
|
158 heads = list(heads) |
1ffd97cbf9a2
reachableroots: default to the C implementation
Laurent Charignon <lcharignon@fb.com>
parents:
26002
diff
changeset
|
159 try: |
26094
df41c7be16d6
reachableroots: construct and sort baseset in revset module
Yuya Nishihara <yuya@tcha.org>
parents:
26093
diff
changeset
|
160 revs = repo.changelog.reachableroots(minroot, heads, roots, includepath) |
26006
1ffd97cbf9a2
reachableroots: default to the C implementation
Laurent Charignon <lcharignon@fb.com>
parents:
26002
diff
changeset
|
161 except AttributeError: |
26095
6eed95ca4c03
revset: mark reachablerootspure as private
Yuya Nishihara <yuya@tcha.org>
parents:
26094
diff
changeset
|
162 revs = _reachablerootspure(repo, minroot, roots, heads, includepath) |
26094
df41c7be16d6
reachableroots: construct and sort baseset in revset module
Yuya Nishihara <yuya@tcha.org>
parents:
26093
diff
changeset
|
163 revs = baseset(revs) |
df41c7be16d6
reachableroots: construct and sort baseset in revset module
Yuya Nishihara <yuya@tcha.org>
parents:
26093
diff
changeset
|
164 revs.sort() |
df41c7be16d6
reachableroots: construct and sort baseset in revset module
Yuya Nishihara <yuya@tcha.org>
parents:
26093
diff
changeset
|
165 return revs |
26006
1ffd97cbf9a2
reachableroots: default to the C implementation
Laurent Charignon <lcharignon@fb.com>
parents:
26002
diff
changeset
|
166 |
11275 | 167 # helpers |
168 | |
169 def getset(repo, subset, x): | |
170 if not x: | |
11383
de544774ebea
revset: all your error messages are belong to _
Martin Geisler <mg@lazybytes.net>
parents:
11349
diff
changeset
|
171 raise error.ParseError(_("missing argument")) |
31809
35b8bb1ef02b
revset: stop supporting predicate that returns plain list (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31662
diff
changeset
|
172 return methods[x[0]](repo, subset, *x[1:]) |
11275 | 173 |
17003
42c472877825
revset: add a utility for obtaining the source of a given rev
Matt Harbison <matt_harbison@yahoo.com>
parents:
17002
diff
changeset
|
174 def _getrevsource(repo, r): |
42c472877825
revset: add a utility for obtaining the source of a given rev
Matt Harbison <matt_harbison@yahoo.com>
parents:
17002
diff
changeset
|
175 extra = repo[r].extra() |
42c472877825
revset: add a utility for obtaining the source of a given rev
Matt Harbison <matt_harbison@yahoo.com>
parents:
17002
diff
changeset
|
176 for label in ('source', 'transplant_source', 'rebase_source'): |
42c472877825
revset: add a utility for obtaining the source of a given rev
Matt Harbison <matt_harbison@yahoo.com>
parents:
17002
diff
changeset
|
177 if label in extra: |
42c472877825
revset: add a utility for obtaining the source of a given rev
Matt Harbison <matt_harbison@yahoo.com>
parents:
17002
diff
changeset
|
178 try: |
42c472877825
revset: add a utility for obtaining the source of a given rev
Matt Harbison <matt_harbison@yahoo.com>
parents:
17002
diff
changeset
|
179 return repo[extra[label]].rev() |
42c472877825
revset: add a utility for obtaining the source of a given rev
Matt Harbison <matt_harbison@yahoo.com>
parents:
17002
diff
changeset
|
180 except error.RepoLookupError: |
42c472877825
revset: add a utility for obtaining the source of a given rev
Matt Harbison <matt_harbison@yahoo.com>
parents:
17002
diff
changeset
|
181 pass |
42c472877825
revset: add a utility for obtaining the source of a given rev
Matt Harbison <matt_harbison@yahoo.com>
parents:
17002
diff
changeset
|
182 return None |
42c472877825
revset: add a utility for obtaining the source of a given rev
Matt Harbison <matt_harbison@yahoo.com>
parents:
17002
diff
changeset
|
183 |
11275 | 184 # operator methods |
185 | |
186 def stringset(repo, subset, x): | |
187 x = repo[x].rev() | |
25265
e16456831516
revset: drop magic of fullreposet membership test (issue4682)
Yuya Nishihara <yuya@tcha.org>
parents:
25094
diff
changeset
|
188 if (x in subset |
e16456831516
revset: drop magic of fullreposet membership test (issue4682)
Yuya Nishihara <yuya@tcha.org>
parents:
25094
diff
changeset
|
189 or x == node.nullrev and isinstance(subset, fullreposet)): |
20364
a6cf48b2880d
revset: added baseset class (still empty) to improve revset performance
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20289
diff
changeset
|
190 return baseset([x]) |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
191 return baseset() |
11275 | 192 |
29932
09a84e747c88
revset: pass around ordering flags to operations
Yuya Nishihara <yuya@tcha.org>
parents:
29931
diff
changeset
|
193 def rangeset(repo, subset, x, y, order): |
23162
69524a05a7fa
revset-rangeset: call 'getset' on a 'fullreposet'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23139
diff
changeset
|
194 m = getset(repo, fullreposet(repo), x) |
69524a05a7fa
revset-rangeset: call 'getset' on a 'fullreposet'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23139
diff
changeset
|
195 n = getset(repo, fullreposet(repo), y) |
11456
88abbb046e66
revset: deal with empty sets in range endpoints
Matt Mackall <mpm@selenic.com>
parents:
11446
diff
changeset
|
196 |
88abbb046e66
revset: deal with empty sets in range endpoints
Matt Mackall <mpm@selenic.com>
parents:
11446
diff
changeset
|
197 if not m or not n: |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
198 return baseset() |
30043
49d5434d68fb
revset: extract function that creates range set from computed revisions
Yuya Nishihara <yuya@tcha.org>
parents:
29955
diff
changeset
|
199 return _makerangeset(repo, subset, m.first(), n.last(), order) |
49d5434d68fb
revset: extract function that creates range set from computed revisions
Yuya Nishihara <yuya@tcha.org>
parents:
29955
diff
changeset
|
200 |
30803
d389f19f14aa
revset: do not transform range* operators in parsed tree
Yuya Nishihara <yuya@tcha.org>
parents:
30802
diff
changeset
|
201 def rangeall(repo, subset, x, order): |
d389f19f14aa
revset: do not transform range* operators in parsed tree
Yuya Nishihara <yuya@tcha.org>
parents:
30802
diff
changeset
|
202 assert x is None |
d389f19f14aa
revset: do not transform range* operators in parsed tree
Yuya Nishihara <yuya@tcha.org>
parents:
30802
diff
changeset
|
203 return _makerangeset(repo, subset, 0, len(repo) - 1, order) |
d389f19f14aa
revset: do not transform range* operators in parsed tree
Yuya Nishihara <yuya@tcha.org>
parents:
30802
diff
changeset
|
204 |
30044
69b61d0bb008
revset: do not rewrite ':y' to '0:y' (issue5385)
Yuya Nishihara <yuya@tcha.org>
parents:
30043
diff
changeset
|
205 def rangepre(repo, subset, y, order): |
69b61d0bb008
revset: do not rewrite ':y' to '0:y' (issue5385)
Yuya Nishihara <yuya@tcha.org>
parents:
30043
diff
changeset
|
206 # ':y' can't be rewritten to '0:y' since '0' may be hidden |
69b61d0bb008
revset: do not rewrite ':y' to '0:y' (issue5385)
Yuya Nishihara <yuya@tcha.org>
parents:
30043
diff
changeset
|
207 n = getset(repo, fullreposet(repo), y) |
69b61d0bb008
revset: do not rewrite ':y' to '0:y' (issue5385)
Yuya Nishihara <yuya@tcha.org>
parents:
30043
diff
changeset
|
208 if not n: |
69b61d0bb008
revset: do not rewrite ':y' to '0:y' (issue5385)
Yuya Nishihara <yuya@tcha.org>
parents:
30043
diff
changeset
|
209 return baseset() |
69b61d0bb008
revset: do not rewrite ':y' to '0:y' (issue5385)
Yuya Nishihara <yuya@tcha.org>
parents:
30043
diff
changeset
|
210 return _makerangeset(repo, subset, 0, n.last(), order) |
69b61d0bb008
revset: do not rewrite ':y' to '0:y' (issue5385)
Yuya Nishihara <yuya@tcha.org>
parents:
30043
diff
changeset
|
211 |
30803
d389f19f14aa
revset: do not transform range* operators in parsed tree
Yuya Nishihara <yuya@tcha.org>
parents:
30802
diff
changeset
|
212 def rangepost(repo, subset, x, order): |
d389f19f14aa
revset: do not transform range* operators in parsed tree
Yuya Nishihara <yuya@tcha.org>
parents:
30802
diff
changeset
|
213 m = getset(repo, fullreposet(repo), x) |
d389f19f14aa
revset: do not transform range* operators in parsed tree
Yuya Nishihara <yuya@tcha.org>
parents:
30802
diff
changeset
|
214 if not m: |
d389f19f14aa
revset: do not transform range* operators in parsed tree
Yuya Nishihara <yuya@tcha.org>
parents:
30802
diff
changeset
|
215 return baseset() |
d389f19f14aa
revset: do not transform range* operators in parsed tree
Yuya Nishihara <yuya@tcha.org>
parents:
30802
diff
changeset
|
216 return _makerangeset(repo, subset, m.first(), len(repo) - 1, order) |
d389f19f14aa
revset: do not transform range* operators in parsed tree
Yuya Nishihara <yuya@tcha.org>
parents:
30802
diff
changeset
|
217 |
30043
49d5434d68fb
revset: extract function that creates range set from computed revisions
Yuya Nishihara <yuya@tcha.org>
parents:
29955
diff
changeset
|
218 def _makerangeset(repo, subset, m, n, order): |
25766
d51dac68ec98
revset: work around x:y range where x or y is wdir()
Yuya Nishihara <yuya@tcha.org>
parents:
25765
diff
changeset
|
219 if m == n: |
d51dac68ec98
revset: work around x:y range where x or y is wdir()
Yuya Nishihara <yuya@tcha.org>
parents:
25765
diff
changeset
|
220 r = baseset([m]) |
d51dac68ec98
revset: work around x:y range where x or y is wdir()
Yuya Nishihara <yuya@tcha.org>
parents:
25765
diff
changeset
|
221 elif n == node.wdirrev: |
d51dac68ec98
revset: work around x:y range where x or y is wdir()
Yuya Nishihara <yuya@tcha.org>
parents:
25765
diff
changeset
|
222 r = spanset(repo, m, len(repo)) + baseset([n]) |
d51dac68ec98
revset: work around x:y range where x or y is wdir()
Yuya Nishihara <yuya@tcha.org>
parents:
25765
diff
changeset
|
223 elif m == node.wdirrev: |
d51dac68ec98
revset: work around x:y range where x or y is wdir()
Yuya Nishihara <yuya@tcha.org>
parents:
25765
diff
changeset
|
224 r = baseset([m]) + spanset(repo, len(repo) - 1, n - 1) |
d51dac68ec98
revset: work around x:y range where x or y is wdir()
Yuya Nishihara <yuya@tcha.org>
parents:
25765
diff
changeset
|
225 elif m < n: |
20526
9ad6dae67845
revset: changed revsets to use spanset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20525
diff
changeset
|
226 r = spanset(repo, m, n + 1) |
11456
88abbb046e66
revset: deal with empty sets in range endpoints
Matt Mackall <mpm@selenic.com>
parents:
11446
diff
changeset
|
227 else: |
20526
9ad6dae67845
revset: changed revsets to use spanset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20525
diff
changeset
|
228 r = spanset(repo, m, n - 1) |
29944
5f56a3b9675e
revset: fix order of nested 'range' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29943
diff
changeset
|
229 |
5f56a3b9675e
revset: fix order of nested 'range' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29943
diff
changeset
|
230 if order == defineorder: |
5f56a3b9675e
revset: fix order of nested 'range' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29943
diff
changeset
|
231 return r & subset |
5f56a3b9675e
revset: fix order of nested 'range' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29943
diff
changeset
|
232 else: |
5f56a3b9675e
revset: fix order of nested 'range' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29943
diff
changeset
|
233 # carrying the sorting over when possible would be more efficient |
5f56a3b9675e
revset: fix order of nested 'range' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29943
diff
changeset
|
234 return subset & r |
11275 | 235 |
29932
09a84e747c88
revset: pass around ordering flags to operations
Yuya Nishihara <yuya@tcha.org>
parents:
29931
diff
changeset
|
236 def dagrange(repo, subset, x, y, order): |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
237 r = fullreposet(repo) |
26002
fd92bfbbe02d
revset: rename revsbetween to reachableroots and add an argument
Laurent Charignon <lcharignon@fb.com>
parents:
26001
diff
changeset
|
238 xs = reachableroots(repo, getset(repo, r, x), getset(repo, r, y), |
fd92bfbbe02d
revset: rename revsbetween to reachableroots and add an argument
Laurent Charignon <lcharignon@fb.com>
parents:
26001
diff
changeset
|
239 includepath=True) |
29139
64c1955a0461
revset: make dagrange preserve order of input set
Yuya Nishihara <yuya@tcha.org>
parents:
29119
diff
changeset
|
240 return subset & xs |
16860
e1aa1ed30030
revset: turn dagrange into a function
Bryan O'Sullivan <bryano@fb.com>
parents:
16859
diff
changeset
|
241 |
29932
09a84e747c88
revset: pass around ordering flags to operations
Yuya Nishihara <yuya@tcha.org>
parents:
29931
diff
changeset
|
242 def andset(repo, subset, x, y, order): |
11275 | 243 return getset(repo, getset(repo, subset, x), y) |
244 | |
29932
09a84e747c88
revset: pass around ordering flags to operations
Yuya Nishihara <yuya@tcha.org>
parents:
29931
diff
changeset
|
245 def differenceset(repo, subset, x, y, order): |
28217
d2ac8b57a75d
revset: use smartset minus operator
Durham Goode <durham@fb.com>
parents:
28139
diff
changeset
|
246 return getset(repo, subset, x) - getset(repo, subset, y) |
d2ac8b57a75d
revset: use smartset minus operator
Durham Goode <durham@fb.com>
parents:
28139
diff
changeset
|
247 |
29929
b3845cab4ddc
revset: wrap arguments of 'or' by 'list' node
Yuya Nishihara <yuya@tcha.org>
parents:
29922
diff
changeset
|
248 def _orsetlist(repo, subset, xs): |
25929
289149111d46
revset: make balanced addsets by orset() without using _combinesets()
Yuya Nishihara <yuya@tcha.org>
parents:
25927
diff
changeset
|
249 assert xs |
289149111d46
revset: make balanced addsets by orset() without using _combinesets()
Yuya Nishihara <yuya@tcha.org>
parents:
25927
diff
changeset
|
250 if len(xs) == 1: |
289149111d46
revset: make balanced addsets by orset() without using _combinesets()
Yuya Nishihara <yuya@tcha.org>
parents:
25927
diff
changeset
|
251 return getset(repo, subset, xs[0]) |
289149111d46
revset: make balanced addsets by orset() without using _combinesets()
Yuya Nishihara <yuya@tcha.org>
parents:
25927
diff
changeset
|
252 p = len(xs) // 2 |
29929
b3845cab4ddc
revset: wrap arguments of 'or' by 'list' node
Yuya Nishihara <yuya@tcha.org>
parents:
29922
diff
changeset
|
253 a = _orsetlist(repo, subset, xs[:p]) |
b3845cab4ddc
revset: wrap arguments of 'or' by 'list' node
Yuya Nishihara <yuya@tcha.org>
parents:
29922
diff
changeset
|
254 b = _orsetlist(repo, subset, xs[p:]) |
25929
289149111d46
revset: make balanced addsets by orset() without using _combinesets()
Yuya Nishihara <yuya@tcha.org>
parents:
25927
diff
changeset
|
255 return a + b |
11275 | 256 |
29932
09a84e747c88
revset: pass around ordering flags to operations
Yuya Nishihara <yuya@tcha.org>
parents:
29931
diff
changeset
|
257 def orset(repo, subset, x, order): |
29934
2c6a05b938d8
revset: fix order of nested 'or' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29933
diff
changeset
|
258 xs = getlist(x) |
2c6a05b938d8
revset: fix order of nested 'or' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29933
diff
changeset
|
259 if order == followorder: |
2c6a05b938d8
revset: fix order of nested 'or' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29933
diff
changeset
|
260 # slow path to take the subset order |
2c6a05b938d8
revset: fix order of nested 'or' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29933
diff
changeset
|
261 return subset & _orsetlist(repo, fullreposet(repo), xs) |
2c6a05b938d8
revset: fix order of nested 'or' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29933
diff
changeset
|
262 else: |
2c6a05b938d8
revset: fix order of nested 'or' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29933
diff
changeset
|
263 return _orsetlist(repo, subset, xs) |
29929
b3845cab4ddc
revset: wrap arguments of 'or' by 'list' node
Yuya Nishihara <yuya@tcha.org>
parents:
29922
diff
changeset
|
264 |
29932
09a84e747c88
revset: pass around ordering flags to operations
Yuya Nishihara <yuya@tcha.org>
parents:
29931
diff
changeset
|
265 def notset(repo, subset, x, order): |
20366
5ec6321f49a9
revset: added substraction to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20365
diff
changeset
|
266 return subset - getset(repo, subset, x) |
11275 | 267 |
27987
b19d8d5d6b51
revset: flatten chained 'list' operations (aka function args) (issue5072)
Yuya Nishihara <yuya@tcha.org>
parents:
27945
diff
changeset
|
268 def listset(repo, subset, *xs): |
27517
c60a9c16ae25
revset: add hint for list error to use or
timeless <timeless@mozdev.org>
parents:
27440
diff
changeset
|
269 raise error.ParseError(_("can't use a list in this context"), |
c60a9c16ae25
revset: add hint for list error to use or
timeless <timeless@mozdev.org>
parents:
27440
diff
changeset
|
270 hint=_('see hg help "revsets.x or y"')) |
11275 | 271 |
25704
70a2082f855a
revset: add parsing rule for key=value pair
Yuya Nishihara <yuya@tcha.org>
parents:
25689
diff
changeset
|
272 def keyvaluepair(repo, subset, k, v): |
70a2082f855a
revset: add parsing rule for key=value pair
Yuya Nishihara <yuya@tcha.org>
parents:
25689
diff
changeset
|
273 raise error.ParseError(_("can't use a key-value pair in this context")) |
70a2082f855a
revset: add parsing rule for key=value pair
Yuya Nishihara <yuya@tcha.org>
parents:
25689
diff
changeset
|
274 |
29932
09a84e747c88
revset: pass around ordering flags to operations
Yuya Nishihara <yuya@tcha.org>
parents:
29931
diff
changeset
|
275 def func(repo, subset, a, b, order): |
29441
9e8d258708bb
revset: check invalid function syntax "func-name"() explicitly
Yuya Nishihara <yuya@tcha.org>
parents:
29425
diff
changeset
|
276 f = getsymbol(a) |
9e8d258708bb
revset: check invalid function syntax "func-name"() explicitly
Yuya Nishihara <yuya@tcha.org>
parents:
29425
diff
changeset
|
277 if f in symbols: |
30392
155d7ea98085
revset: avoid shadowing a variable with a list comprehension
Augie Fackler <augie@google.com>
parents:
30332
diff
changeset
|
278 func = symbols[f] |
155d7ea98085
revset: avoid shadowing a variable with a list comprehension
Augie Fackler <augie@google.com>
parents:
30332
diff
changeset
|
279 if getattr(func, '_takeorder', False): |
155d7ea98085
revset: avoid shadowing a variable with a list comprehension
Augie Fackler <augie@google.com>
parents:
30332
diff
changeset
|
280 return func(repo, subset, b, order) |
155d7ea98085
revset: avoid shadowing a variable with a list comprehension
Augie Fackler <augie@google.com>
parents:
30332
diff
changeset
|
281 return func(repo, subset, b) |
25632
015c0d1087a3
revset: don't suggest private or undocumented queries
Matt Harbison <matt_harbison@yahoo.com>
parents:
25630
diff
changeset
|
282 |
015c0d1087a3
revset: don't suggest private or undocumented queries
Matt Harbison <matt_harbison@yahoo.com>
parents:
25630
diff
changeset
|
283 keep = lambda fn: getattr(fn, '__doc__', None) is not None |
015c0d1087a3
revset: don't suggest private or undocumented queries
Matt Harbison <matt_harbison@yahoo.com>
parents:
25630
diff
changeset
|
284 |
015c0d1087a3
revset: don't suggest private or undocumented queries
Matt Harbison <matt_harbison@yahoo.com>
parents:
25630
diff
changeset
|
285 syms = [s for (s, fn) in symbols.items() if keep(fn)] |
29441
9e8d258708bb
revset: check invalid function syntax "func-name"() explicitly
Yuya Nishihara <yuya@tcha.org>
parents:
29425
diff
changeset
|
286 raise error.UnknownIdentifier(f, syms) |
11275 | 287 |
288 # functions | |
289 | |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
290 # symbols are callables like: |
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
291 # fn(repo, subset, x) |
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
292 # with: |
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
293 # repo - current repository instance |
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
294 # subset - of revisions to be examined |
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
295 # x - argument in tree form |
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
296 symbols = {} |
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
297 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
298 # symbols which can't be used for a DoS attack for any given input |
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
299 # (e.g. those which accept regexes as plain strings shouldn't be included) |
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
300 # functions that just return a lot of changesets (like all) don't count here |
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
301 safesymbols = set() |
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
302 |
28395
0383f7a5e86c
revset: replace predicate by revsetpredicate of registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28393
diff
changeset
|
303 predicate = registrar.revsetpredicate() |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
304 |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
305 @predicate('_destupdate') |
26713
a271925699d6
revset: reintroduce and experimental revset for update destination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26638
diff
changeset
|
306 def _destupdate(repo, subset, x): |
a271925699d6
revset: reintroduce and experimental revset for update destination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26638
diff
changeset
|
307 # experimental revset for update destination |
30962
11c253997b0e
destutil: drop now-unused "check" parameter from destupdate()
Martin von Zweigbergk <martinvonz@google.com>
parents:
30881
diff
changeset
|
308 args = getargsdict(x, 'limit', 'clean') |
26713
a271925699d6
revset: reintroduce and experimental revset for update destination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26638
diff
changeset
|
309 return subset & baseset([destutil.destupdate(repo, **args)[0]]) |
a271925699d6
revset: reintroduce and experimental revset for update destination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26638
diff
changeset
|
310 |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
311 @predicate('_destmerge') |
26716
c027641f8a83
revset: rename and test '_destmerge'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26714
diff
changeset
|
312 def _destmerge(repo, subset, x): |
c027641f8a83
revset: rename and test '_destmerge'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26714
diff
changeset
|
313 # experimental revset for merge destination |
28139
5476a7a039c0
destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28015
diff
changeset
|
314 sourceset = None |
5476a7a039c0
destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28015
diff
changeset
|
315 if x is not None: |
5476a7a039c0
destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28015
diff
changeset
|
316 sourceset = getset(repo, fullreposet(repo), x) |
5476a7a039c0
destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28015
diff
changeset
|
317 return subset & baseset([destutil.destmerge(repo, sourceset=sourceset)]) |
26303
c99b4d6efdd8
merge: move default destination computation in a revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26232
diff
changeset
|
318 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
319 @predicate('adds(pattern)', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
320 def adds(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
321 """Changesets that add a file matching pattern. |
20289
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
322 |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
323 The pattern without explicit kind like ``glob:`` is expected to be |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
324 relative to the current directory and match against a file or a |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
325 directory. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
326 """ |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
327 # i18n: "adds" is a keyword |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
328 pat = getstring(x, _("adds requires a pattern")) |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
329 return checkstatus(repo, subset, pat, 1) |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
330 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
331 @predicate('ancestor(*changeset)', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
332 def ancestor(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
333 """A greatest common ancestor of the changesets. |
18536
ae645d4f084c
revset: change ancestor to accept 0 or more arguments (issue3750)
Paul Cavallaro <ptc@fb.com>
parents:
18495
diff
changeset
|
334 |
ae645d4f084c
revset: change ancestor to accept 0 or more arguments (issue3750)
Paul Cavallaro <ptc@fb.com>
parents:
18495
diff
changeset
|
335 Accepts 0 or more changesets. |
ae645d4f084c
revset: change ancestor to accept 0 or more arguments (issue3750)
Paul Cavallaro <ptc@fb.com>
parents:
18495
diff
changeset
|
336 Will return empty list when passed no args. |
ae645d4f084c
revset: change ancestor to accept 0 or more arguments (issue3750)
Paul Cavallaro <ptc@fb.com>
parents:
18495
diff
changeset
|
337 Greatest common ancestor of a single changeset is that changeset. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
338 """ |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
339 # i18n: "ancestor" is a keyword |
18536
ae645d4f084c
revset: change ancestor to accept 0 or more arguments (issue3750)
Paul Cavallaro <ptc@fb.com>
parents:
18495
diff
changeset
|
340 l = getlist(x) |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
341 rl = fullreposet(repo) |
18536
ae645d4f084c
revset: change ancestor to accept 0 or more arguments (issue3750)
Paul Cavallaro <ptc@fb.com>
parents:
18495
diff
changeset
|
342 anc = None |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
343 |
18536
ae645d4f084c
revset: change ancestor to accept 0 or more arguments (issue3750)
Paul Cavallaro <ptc@fb.com>
parents:
18495
diff
changeset
|
344 # (getset(repo, rl, i) for i in l) generates a list of lists |
ae645d4f084c
revset: change ancestor to accept 0 or more arguments (issue3750)
Paul Cavallaro <ptc@fb.com>
parents:
18495
diff
changeset
|
345 for revs in (getset(repo, rl, i) for i in l): |
ae645d4f084c
revset: change ancestor to accept 0 or more arguments (issue3750)
Paul Cavallaro <ptc@fb.com>
parents:
18495
diff
changeset
|
346 for r in revs: |
ae645d4f084c
revset: change ancestor to accept 0 or more arguments (issue3750)
Paul Cavallaro <ptc@fb.com>
parents:
18495
diff
changeset
|
347 if anc is None: |
20991
a05d694599f9
revlog: use context ancestor instead of changelog ancestor
Mads Kiilerich <madski@unity3d.com>
parents:
20895
diff
changeset
|
348 anc = repo[r] |
18536
ae645d4f084c
revset: change ancestor to accept 0 or more arguments (issue3750)
Paul Cavallaro <ptc@fb.com>
parents:
18495
diff
changeset
|
349 else: |
20991
a05d694599f9
revlog: use context ancestor instead of changelog ancestor
Mads Kiilerich <madski@unity3d.com>
parents:
20895
diff
changeset
|
350 anc = anc.ancestor(repo[r]) |
a05d694599f9
revlog: use context ancestor instead of changelog ancestor
Mads Kiilerich <madski@unity3d.com>
parents:
20895
diff
changeset
|
351 |
a05d694599f9
revlog: use context ancestor instead of changelog ancestor
Mads Kiilerich <madski@unity3d.com>
parents:
20895
diff
changeset
|
352 if anc is not None and anc.rev() in subset: |
a05d694599f9
revlog: use context ancestor instead of changelog ancestor
Mads Kiilerich <madski@unity3d.com>
parents:
20895
diff
changeset
|
353 return baseset([anc.rev()]) |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
354 return baseset() |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
355 |
16409
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
356 def _ancestors(repo, subset, x, followfirst=False): |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
357 heads = getset(repo, fullreposet(repo), x) |
22944
5aae3dea8044
revset: better naming of variables containing the value of a single argument
Mads Kiilerich <madski@unity3d.com>
parents:
22891
diff
changeset
|
358 if not heads: |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
359 return baseset() |
22944
5aae3dea8044
revset: better naming of variables containing the value of a single argument
Mads Kiilerich <madski@unity3d.com>
parents:
22891
diff
changeset
|
360 s = _revancestors(repo, heads, followfirst) |
23003
62d19ce9d7b6
revset-_ancestor: use & instead of filter
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22999
diff
changeset
|
361 return subset & s |
16409
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
362 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
363 @predicate('ancestors(set)', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
364 def ancestors(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
365 """Changesets that are ancestors of a changeset in set. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
366 """ |
16409
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
367 return _ancestors(repo, subset, x) |
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
368 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
369 @predicate('_firstancestors', safe=True) |
16409
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
370 def _firstancestors(repo, subset, x): |
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
371 # ``_firstancestors(set)`` |
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
372 # Like ``ancestors(set)`` but follows only the first parents. |
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
373 return _ancestors(repo, subset, x, followfirst=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
374 |
29932
09a84e747c88
revset: pass around ordering flags to operations
Yuya Nishihara <yuya@tcha.org>
parents:
29931
diff
changeset
|
375 def ancestorspec(repo, subset, x, n, order): |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
376 """``set~n`` |
16683 | 377 Changesets that are the Nth ancestor (first parents only) of a changeset |
378 in set. | |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
379 """ |
30801
67ee7874e53b
revset: factor out getinteger() helper
Yuya Nishihara <yuya@tcha.org>
parents:
30800
diff
changeset
|
380 n = getinteger(n, _("~ expects a number")) |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
381 ps = set() |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
382 cl = repo.changelog |
23163
6f1b8b3f12fd
revset-ancestorspec: call 'getset' on a 'fullreposet'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23162
diff
changeset
|
383 for r in getset(repo, fullreposet(repo), x): |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
384 for i in range(n): |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
385 r = cl.parentrevs(r)[0] |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
386 ps.add(r) |
22531
22ba2c0825da
revset: use `subset &` in `ancestorspec`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22530
diff
changeset
|
387 return subset & ps |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
388 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
389 @predicate('author(string)', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
390 def author(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
391 """Alias for ``user(string)``. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
392 """ |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
393 # i18n: "author" is a keyword |
30782
db38cfc7c29d
revset: stop lowercasing the regex pattern for 'author'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30772
diff
changeset
|
394 n = getstring(x, _("author requires a string")) |
db38cfc7c29d
revset: stop lowercasing the regex pattern for 'author'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30772
diff
changeset
|
395 kind, pattern, matcher = _substringmatcher(n, casesensitive=False) |
db38cfc7c29d
revset: stop lowercasing the regex pattern for 'author'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30772
diff
changeset
|
396 return subset.filter(lambda x: matcher(repo[x].user()), |
28424
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
397 condrepr=('<user %r>', n)) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
398 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
399 @predicate('bisect(string)', safe=True) |
15134
81adf7777f8f
revset: rename bisected() to bisect()
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15133
diff
changeset
|
400 def bisect(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
401 """Changesets marked in the specified bisect status: |
15136
18219c0789ae
revset.bisect: add new 'range' set to the bisect keyword
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15135
diff
changeset
|
402 |
15153
fa0a464e4ca5
hbisect: add two new revset descriptions: 'goods' and 'bads'
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15147
diff
changeset
|
403 - ``good``, ``bad``, ``skip``: csets explicitly marked as good/bad/skip |
17424
e7cfe3587ea4
fix trivial spelling errors
Mads Kiilerich <mads@kiilerich.com>
parents:
17390
diff
changeset
|
404 - ``goods``, ``bads`` : csets topologically good/bad |
15153
fa0a464e4ca5
hbisect: add two new revset descriptions: 'goods' and 'bads'
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15147
diff
changeset
|
405 - ``range`` : csets taking part in the bisection |
fa0a464e4ca5
hbisect: add two new revset descriptions: 'goods' and 'bads'
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15147
diff
changeset
|
406 - ``pruned`` : csets that are goods, bads or skipped |
fa0a464e4ca5
hbisect: add two new revset descriptions: 'goods' and 'bads'
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15147
diff
changeset
|
407 - ``untested`` : csets whose fate is yet unknown |
fa0a464e4ca5
hbisect: add two new revset descriptions: 'goods' and 'bads'
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15147
diff
changeset
|
408 - ``ignored`` : csets ignored due to DAG topology |
16647
14913fcb30c6
bisect: track the current changeset (issue3382)
Bryan O'Sullivan <bryano@fb.com>
parents:
16640
diff
changeset
|
409 - ``current`` : the cset currently being bisected |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
410 """ |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
411 # i18n: "bisect" is a keyword |
15135
f19de58af225
revset.bisect: move bisect() code to hbisect.py
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15134
diff
changeset
|
412 status = getstring(x, _("bisect requires a string")).lower() |
16467
7f59900e3f8b
revset: fix O(n**2) behaviour of bisect() (issue3381)
Bryan O'Sullivan <bryano@fb.com>
parents:
16453
diff
changeset
|
413 state = set(hbisect.get(repo, status)) |
22532
0cf46b8298fe
revset: use `subset &` in `bisect`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22531
diff
changeset
|
414 return subset & state |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
415 |
15134
81adf7777f8f
revset: rename bisected() to bisect()
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15133
diff
changeset
|
416 # Backward-compatibility |
81adf7777f8f
revset: rename bisected() to bisect()
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15133
diff
changeset
|
417 # - no help entry so that we do not advertise it any more |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
418 @predicate('bisected', safe=True) |
15134
81adf7777f8f
revset: rename bisected() to bisect()
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15133
diff
changeset
|
419 def bisected(repo, subset, x): |
81adf7777f8f
revset: rename bisected() to bisect()
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15133
diff
changeset
|
420 return bisect(repo, subset, x) |
81adf7777f8f
revset: rename bisected() to bisect()
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15133
diff
changeset
|
421 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
422 @predicate('bookmark([name])', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
423 def bookmark(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
424 """The named bookmark or all bookmarks. |
16822
da55d8a77390
revset: add pattern matching to 'bookmarks' revset expression
Simon King <simon@simonking.org.uk>
parents:
16821
diff
changeset
|
425 |
30799
0b49449a01f4
help: use :hg: role and canonical name to point to revset string patterns
Yuya Nishihara <yuya@tcha.org>
parents:
30784
diff
changeset
|
426 Pattern matching is supported for `name`. See :hg:`help revisions.patterns`. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
427 """ |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
428 # i18n: "bookmark" is a keyword |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
429 args = getargs(x, 0, 1, _('bookmark takes one or no arguments')) |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
430 if args: |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
431 bm = getstring(args[0], |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
432 # i18n: "bookmark" is a keyword |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
433 _('the argument to bookmark must be a string')) |
26481
7d132557e44a
util: extract stringmatcher() from revset
Matt Harbison <matt_harbison@yahoo.com>
parents:
26307
diff
changeset
|
434 kind, pattern, matcher = util.stringmatcher(bm) |
22499
8c9f9e346acc
revset: unify code flow in `bookmark`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22498
diff
changeset
|
435 bms = set() |
16822
da55d8a77390
revset: add pattern matching to 'bookmarks' revset expression
Simon King <simon@simonking.org.uk>
parents:
16821
diff
changeset
|
436 if kind == 'literal': |
22105
3efe3c2609e0
revset: bookmark revset interprets 'literal:' prefix correctly (issue4329)
Michael O'Connor <mkoconnor@gmail.com>
parents:
21939
diff
changeset
|
437 bmrev = repo._bookmarks.get(pattern, None) |
16822
da55d8a77390
revset: add pattern matching to 'bookmarks' revset expression
Simon King <simon@simonking.org.uk>
parents:
16821
diff
changeset
|
438 if not bmrev: |
23978
eeb5d5ab14a6
revset: raise RepoLookupError to make present() predicate continue the query
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23956
diff
changeset
|
439 raise error.RepoLookupError(_("bookmark '%s' does not exist") |
26538
5c9ec1cc671a
revset: strip off "literal:" prefix from bookmark not found error
Yuya Nishihara <yuya@tcha.org>
parents:
26537
diff
changeset
|
440 % pattern) |
22499
8c9f9e346acc
revset: unify code flow in `bookmark`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22498
diff
changeset
|
441 bms.add(repo[bmrev].rev()) |
16822
da55d8a77390
revset: add pattern matching to 'bookmarks' revset expression
Simon King <simon@simonking.org.uk>
parents:
16821
diff
changeset
|
442 else: |
da55d8a77390
revset: add pattern matching to 'bookmarks' revset expression
Simon King <simon@simonking.org.uk>
parents:
16821
diff
changeset
|
443 matchrevs = set() |
18495
8260fa9f30b9
bookmarks: don't use bookmarks.listbookmarks in local computations
Kevin Bullock <kbullock@ringworld.org>
parents:
18473
diff
changeset
|
444 for name, bmrev in repo._bookmarks.iteritems(): |
16822
da55d8a77390
revset: add pattern matching to 'bookmarks' revset expression
Simon King <simon@simonking.org.uk>
parents:
16821
diff
changeset
|
445 if matcher(name): |
da55d8a77390
revset: add pattern matching to 'bookmarks' revset expression
Simon King <simon@simonking.org.uk>
parents:
16821
diff
changeset
|
446 matchrevs.add(bmrev) |
da55d8a77390
revset: add pattern matching to 'bookmarks' revset expression
Simon King <simon@simonking.org.uk>
parents:
16821
diff
changeset
|
447 if not matchrevs: |
23978
eeb5d5ab14a6
revset: raise RepoLookupError to make present() predicate continue the query
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23956
diff
changeset
|
448 raise error.RepoLookupError(_("no bookmarks exist" |
eeb5d5ab14a6
revset: raise RepoLookupError to make present() predicate continue the query
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23956
diff
changeset
|
449 " that match '%s'") % pattern) |
16822
da55d8a77390
revset: add pattern matching to 'bookmarks' revset expression
Simon King <simon@simonking.org.uk>
parents:
16821
diff
changeset
|
450 for bmrev in matchrevs: |
22499
8c9f9e346acc
revset: unify code flow in `bookmark`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22498
diff
changeset
|
451 bms.add(repo[bmrev].rev()) |
8c9f9e346acc
revset: unify code flow in `bookmark`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22498
diff
changeset
|
452 else: |
8c9f9e346acc
revset: unify code flow in `bookmark`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22498
diff
changeset
|
453 bms = set([repo[r].rev() |
8c9f9e346acc
revset: unify code flow in `bookmark`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22498
diff
changeset
|
454 for r in repo._bookmarks.values()]) |
22500
171015d3b30c
revset: remove nullrev from the bookmark computation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22499
diff
changeset
|
455 bms -= set([node.nullrev]) |
22530
faf4f63533ff
revset: use `subset &` in `bookmark`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22529
diff
changeset
|
456 return subset & bms |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
457 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
458 @predicate('branch(string or set)', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
459 def branch(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
460 """ |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
461 All changesets belonging to the given branch or the branches of the given |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
462 changesets. |
16821
0946502fd3d5
revset: add pattern matching to 'branch' revset expression
Simon King <simon@simonking.org.uk>
parents:
16820
diff
changeset
|
463 |
30784
5dd67f0993ce
help: eliminate duplicate text for revset string patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
30783
diff
changeset
|
464 Pattern matching is supported for `string`. See |
30799
0b49449a01f4
help: use :hg: role and canonical name to point to revset string patterns
Yuya Nishihara <yuya@tcha.org>
parents:
30784
diff
changeset
|
465 :hg:`help revisions.patterns`. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
466 """ |
24374
77fd1fb538cd
revbranchcache: store repo on the object
Durham Goode <durham@fb.com>
parents:
24366
diff
changeset
|
467 getbi = repo.revbranchcache().branchinfo |
23787
678f53865c68
revset: use localrepo revbranchcache for branch name filtering
Mads Kiilerich <madski@unity3d.com>
parents:
23765
diff
changeset
|
468 |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
469 try: |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
470 b = getstring(x, '') |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
471 except error.ParseError: |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
472 # not a string, but another revspec, e.g. tip() |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
473 pass |
16821
0946502fd3d5
revset: add pattern matching to 'branch' revset expression
Simon King <simon@simonking.org.uk>
parents:
16820
diff
changeset
|
474 else: |
26481
7d132557e44a
util: extract stringmatcher() from revset
Matt Harbison <matt_harbison@yahoo.com>
parents:
26307
diff
changeset
|
475 kind, pattern, matcher = util.stringmatcher(b) |
16821
0946502fd3d5
revset: add pattern matching to 'branch' revset expression
Simon King <simon@simonking.org.uk>
parents:
16820
diff
changeset
|
476 if kind == 'literal': |
0946502fd3d5
revset: add pattern matching to 'branch' revset expression
Simon King <simon@simonking.org.uk>
parents:
16820
diff
changeset
|
477 # note: falls through to the revspec case if no branch with |
26537
832feae7c986
revset: do not fall through to revspec for literal: branch (issue4838)
Yuya Nishihara <yuya@tcha.org>
parents:
26481
diff
changeset
|
478 # this name exists and pattern kind is not specified explicitly |
16821
0946502fd3d5
revset: add pattern matching to 'branch' revset expression
Simon King <simon@simonking.org.uk>
parents:
16820
diff
changeset
|
479 if pattern in repo.branchmap(): |
28424
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
480 return subset.filter(lambda r: matcher(getbi(r)[0]), |
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
481 condrepr=('<branch %r>', b)) |
26537
832feae7c986
revset: do not fall through to revspec for literal: branch (issue4838)
Yuya Nishihara <yuya@tcha.org>
parents:
26481
diff
changeset
|
482 if b.startswith('literal:'): |
832feae7c986
revset: do not fall through to revspec for literal: branch (issue4838)
Yuya Nishihara <yuya@tcha.org>
parents:
26481
diff
changeset
|
483 raise error.RepoLookupError(_("branch '%s' does not exist") |
832feae7c986
revset: do not fall through to revspec for literal: branch (issue4838)
Yuya Nishihara <yuya@tcha.org>
parents:
26481
diff
changeset
|
484 % pattern) |
16821
0946502fd3d5
revset: add pattern matching to 'branch' revset expression
Simon King <simon@simonking.org.uk>
parents:
16820
diff
changeset
|
485 else: |
28424
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
486 return subset.filter(lambda r: matcher(getbi(r)[0]), |
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
487 condrepr=('<branch %r>', b)) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
488 |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
489 s = getset(repo, fullreposet(repo), x) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
490 b = set() |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
491 for r in s: |
24374
77fd1fb538cd
revbranchcache: store repo on the object
Durham Goode <durham@fb.com>
parents:
24366
diff
changeset
|
492 b.add(getbi(r)[0]) |
22867
5ee9b78ce805
revset-branch: remove usage of `set()`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22866
diff
changeset
|
493 c = s.__contains__ |
28424
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
494 return subset.filter(lambda r: c(r) or getbi(r)[0] in b, |
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
495 condrepr=lambda: '<branch %r>' % sorted(b)) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
496 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
497 @predicate('bumped()', safe=True) |
17829
c73f7a28953c
revset: add a bumped revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17825
diff
changeset
|
498 def bumped(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
499 """Mutable changesets marked as successors of public changesets. |
17829
c73f7a28953c
revset: add a bumped revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17825
diff
changeset
|
500 |
c73f7a28953c
revset: add a bumped revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17825
diff
changeset
|
501 Only non-public and non-obsolete changesets can be `bumped`. |
c73f7a28953c
revset: add a bumped revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17825
diff
changeset
|
502 """ |
c73f7a28953c
revset: add a bumped revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17825
diff
changeset
|
503 # i18n: "bumped" is a keyword |
c73f7a28953c
revset: add a bumped revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17825
diff
changeset
|
504 getargs(x, 0, 0, _("bumped takes no arguments")) |
c73f7a28953c
revset: add a bumped revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17825
diff
changeset
|
505 bumped = obsmod.getrevs(repo, 'bumped') |
20367
2ac278aab2b4
revset: added intersection to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20366
diff
changeset
|
506 return subset & bumped |
17829
c73f7a28953c
revset: add a bumped revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17825
diff
changeset
|
507 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
508 @predicate('bundle()', safe=True) |
17913
03e552aaae67
bundle: add revset expression to show bundle contents (issue3487)
Tomasz Kleczek <tkleczek@fb.com>
parents:
17886
diff
changeset
|
509 def bundle(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
510 """Changesets in the bundle. |
17913
03e552aaae67
bundle: add revset expression to show bundle contents (issue3487)
Tomasz Kleczek <tkleczek@fb.com>
parents:
17886
diff
changeset
|
511 |
03e552aaae67
bundle: add revset expression to show bundle contents (issue3487)
Tomasz Kleczek <tkleczek@fb.com>
parents:
17886
diff
changeset
|
512 Bundle must be specified by the -R option.""" |
03e552aaae67
bundle: add revset expression to show bundle contents (issue3487)
Tomasz Kleczek <tkleczek@fb.com>
parents:
17886
diff
changeset
|
513 |
03e552aaae67
bundle: add revset expression to show bundle contents (issue3487)
Tomasz Kleczek <tkleczek@fb.com>
parents:
17886
diff
changeset
|
514 try: |
18411
8b0f0dd56cec
bundlerepo: improve performance for bundle() revset expression
Mads Kiilerich <madski@unity3d.com>
parents:
18382
diff
changeset
|
515 bundlerevs = repo.changelog.bundlerevs |
17913
03e552aaae67
bundle: add revset expression to show bundle contents (issue3487)
Tomasz Kleczek <tkleczek@fb.com>
parents:
17886
diff
changeset
|
516 except AttributeError: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26571
diff
changeset
|
517 raise error.Abort(_("no bundle provided - specify with -R")) |
20367
2ac278aab2b4
revset: added intersection to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20366
diff
changeset
|
518 return subset & bundlerevs |
17913
03e552aaae67
bundle: add revset expression to show bundle contents (issue3487)
Tomasz Kleczek <tkleczek@fb.com>
parents:
17886
diff
changeset
|
519 |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
520 def checkstatus(repo, subset, pat, field): |
16521
592701c8eac6
revset: fix adds/modifies/removes and patterns (issue3403)
Patrick Mezard <patrick@mezard.eu>
parents:
16467
diff
changeset
|
521 hasset = matchmod.patkind(pat) == 'set' |
20457
ed7b674824a3
revset: added lazyset implementation to checkstatus
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20456
diff
changeset
|
522 |
23115
c23c03605c59
revset: don't recreate matcher for every revision
Martin von Zweigbergk <martinvonz@google.com>
parents:
23100
diff
changeset
|
523 mcache = [None] |
20457
ed7b674824a3
revset: added lazyset implementation to checkstatus
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20456
diff
changeset
|
524 def matches(x): |
ed7b674824a3
revset: added lazyset implementation to checkstatus
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20456
diff
changeset
|
525 c = repo[x] |
23115
c23c03605c59
revset: don't recreate matcher for every revision
Martin von Zweigbergk <martinvonz@google.com>
parents:
23100
diff
changeset
|
526 if not mcache[0] or hasset: |
c23c03605c59
revset: don't recreate matcher for every revision
Martin von Zweigbergk <martinvonz@google.com>
parents:
23100
diff
changeset
|
527 mcache[0] = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c) |
c23c03605c59
revset: don't recreate matcher for every revision
Martin von Zweigbergk <martinvonz@google.com>
parents:
23100
diff
changeset
|
528 m = mcache[0] |
c23c03605c59
revset: don't recreate matcher for every revision
Martin von Zweigbergk <martinvonz@google.com>
parents:
23100
diff
changeset
|
529 fname = None |
c23c03605c59
revset: don't recreate matcher for every revision
Martin von Zweigbergk <martinvonz@google.com>
parents:
23100
diff
changeset
|
530 if not m.anypats() and len(m.files()) == 1: |
c23c03605c59
revset: don't recreate matcher for every revision
Martin von Zweigbergk <martinvonz@google.com>
parents:
23100
diff
changeset
|
531 fname = m.files()[0] |
16521
592701c8eac6
revset: fix adds/modifies/removes and patterns (issue3403)
Patrick Mezard <patrick@mezard.eu>
parents:
16467
diff
changeset
|
532 if fname is not None: |
592701c8eac6
revset: fix adds/modifies/removes and patterns (issue3403)
Patrick Mezard <patrick@mezard.eu>
parents:
16467
diff
changeset
|
533 if fname not in c.files(): |
20457
ed7b674824a3
revset: added lazyset implementation to checkstatus
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20456
diff
changeset
|
534 return False |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
535 else: |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
536 for f in c.files(): |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
537 if m(f): |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
538 break |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
539 else: |
20457
ed7b674824a3
revset: added lazyset implementation to checkstatus
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20456
diff
changeset
|
540 return False |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
541 files = repo.status(c.p1().node(), c.node())[field] |
16521
592701c8eac6
revset: fix adds/modifies/removes and patterns (issue3403)
Patrick Mezard <patrick@mezard.eu>
parents:
16467
diff
changeset
|
542 if fname is not None: |
592701c8eac6
revset: fix adds/modifies/removes and patterns (issue3403)
Patrick Mezard <patrick@mezard.eu>
parents:
16467
diff
changeset
|
543 if fname in files: |
20457
ed7b674824a3
revset: added lazyset implementation to checkstatus
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20456
diff
changeset
|
544 return True |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
545 else: |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
546 for f in files: |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
547 if m(f): |
20457
ed7b674824a3
revset: added lazyset implementation to checkstatus
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20456
diff
changeset
|
548 return True |
ed7b674824a3
revset: added lazyset implementation to checkstatus
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20456
diff
changeset
|
549 |
28424
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
550 return subset.filter(matches, condrepr=('<status[%r] %r>', field, pat)) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
551 |
29406
c2193e59ef9f
revsets: passing a set to baseset() is not wrong
Martin von Zweigbergk <martinvonz@google.com>
parents:
29389
diff
changeset
|
552 def _children(repo, subset, parentset): |
25550
3e9049876ace
revset: gratuitous code move in '_children'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25549
diff
changeset
|
553 if not parentset: |
3e9049876ace
revset: gratuitous code move in '_children'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25549
diff
changeset
|
554 return baseset() |
15899
476a981fdf34
revset: optimize roots and children
Matt Mackall <mpm@selenic.com>
parents:
15898
diff
changeset
|
555 cs = set() |
476a981fdf34
revset: optimize roots and children
Matt Mackall <mpm@selenic.com>
parents:
15898
diff
changeset
|
556 pr = repo.changelog.parentrevs |
25567
f140d6207cca
revset: use parentsets.min in _children
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25566
diff
changeset
|
557 minrev = parentset.min() |
30699
5bda147c3139
revset: make children() not look at p2 if null (issue5439)
Yuya Nishihara <yuya@tcha.org>
parents:
30392
diff
changeset
|
558 nullrev = node.nullrev |
29406
c2193e59ef9f
revsets: passing a set to baseset() is not wrong
Martin von Zweigbergk <martinvonz@google.com>
parents:
29389
diff
changeset
|
559 for r in subset: |
18063
34a1a639d835
revset.children: ignore rev numbers that are too low
Siddharth Agarwal <sid0@fb.com>
parents:
17980
diff
changeset
|
560 if r <= minrev: |
34a1a639d835
revset.children: ignore rev numbers that are too low
Siddharth Agarwal <sid0@fb.com>
parents:
17980
diff
changeset
|
561 continue |
30699
5bda147c3139
revset: make children() not look at p2 if null (issue5439)
Yuya Nishihara <yuya@tcha.org>
parents:
30392
diff
changeset
|
562 p1, p2 = pr(r) |
5bda147c3139
revset: make children() not look at p2 if null (issue5439)
Yuya Nishihara <yuya@tcha.org>
parents:
30392
diff
changeset
|
563 if p1 in parentset: |
5bda147c3139
revset: make children() not look at p2 if null (issue5439)
Yuya Nishihara <yuya@tcha.org>
parents:
30392
diff
changeset
|
564 cs.add(r) |
5bda147c3139
revset: make children() not look at p2 if null (issue5439)
Yuya Nishihara <yuya@tcha.org>
parents:
30392
diff
changeset
|
565 if p2 != nullrev and p2 in parentset: |
5bda147c3139
revset: make children() not look at p2 if null (issue5439)
Yuya Nishihara <yuya@tcha.org>
parents:
30392
diff
changeset
|
566 cs.add(r) |
20709
71df845d86cf
revsets: backout d04aac468bf4 due to performance regressions
Matt Mackall <mpm@selenic.com>
parents:
20708
diff
changeset
|
567 return baseset(cs) |
15899
476a981fdf34
revset: optimize roots and children
Matt Mackall <mpm@selenic.com>
parents:
15898
diff
changeset
|
568 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
569 @predicate('children(set)', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
570 def children(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
571 """Child changesets of changesets in set. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
572 """ |
23164
7a42e5d4c418
revset-children: call 'getset' on a 'fullreposet'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23163
diff
changeset
|
573 s = getset(repo, fullreposet(repo), x) |
15899
476a981fdf34
revset: optimize roots and children
Matt Mackall <mpm@selenic.com>
parents:
15898
diff
changeset
|
574 cs = _children(repo, subset, s) |
20367
2ac278aab2b4
revset: added intersection to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20366
diff
changeset
|
575 return subset & cs |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
576 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
577 @predicate('closed()', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
578 def closed(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
579 """Changeset is closed. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
580 """ |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
581 # i18n: "closed" is a keyword |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
582 getargs(x, 0, 0, _("closed takes no arguments")) |
28424
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
583 return subset.filter(lambda r: repo[r].closesbranch(), |
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
584 condrepr='<branch closed>') |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
585 |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
586 @predicate('contains(pattern)') |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
587 def contains(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
588 """The revision's manifest contains a file matching pattern (but might not |
21199
e9c2f76be74b
help: clarify distinction among `contains`/`file`/`filelog`
Greg Hurrell <glh@fb.com>
parents:
21173
diff
changeset
|
589 modify it). See :hg:`help patterns` for information about file patterns. |
20289
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
590 |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
591 The pattern without explicit kind like ``glob:`` is expected to be |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
592 relative to the current directory and match against a file exactly |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
593 for efficiency. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
594 """ |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
595 # i18n: "contains" is a keyword |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
596 pat = getstring(x, _("contains requires a pattern")) |
20461
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
597 |
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
598 def matches(x): |
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
599 if not matchmod.patkind(pat): |
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
600 pats = pathutil.canonpath(repo.root, repo.getcwd(), pat) |
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
601 if pats in repo[x]: |
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
602 return True |
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
603 else: |
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
604 c = repo[x] |
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
605 m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c) |
15964
6e37b8282aa2
revsets: provide contexts for filesets
Matt Mackall <mpm@selenic.com>
parents:
15949
diff
changeset
|
606 for f in c.manifest(): |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
607 if m(f): |
20461
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
608 return True |
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
609 return False |
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
610 |
28424
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
611 return subset.filter(matches, condrepr=('<contains %r>', pat)) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
612 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
613 @predicate('converted([id])', safe=True) |
17002
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
614 def converted(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
615 """Changesets converted from the given identifier in the old repository if |
17002
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
616 present, or all converted changesets if no identifier is specified. |
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
617 """ |
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
618 |
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
619 # There is exactly no chance of resolving the revision, so do a simple |
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
620 # string compare and hope for the best |
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
621 |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
622 rev = None |
17002
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
623 # i18n: "converted" is a keyword |
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
624 l = getargs(x, 0, 1, _('converted takes one or no arguments')) |
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
625 if l: |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
626 # i18n: "converted" is a keyword |
17002
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
627 rev = getstring(l[0], _('converted requires a revision')) |
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
628 |
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
629 def _matchvalue(r): |
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
630 source = repo[r].extra().get('convert_revision', None) |
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
631 return source is not None and (rev is None or source.startswith(rev)) |
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
632 |
28424
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
633 return subset.filter(lambda r: _matchvalue(r), |
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
634 condrepr=('<converted %r>', rev)) |
17002
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
635 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
636 @predicate('date(interval)', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
637 def date(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
638 """Changesets within the interval, see :hg:`help dates`. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
639 """ |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
640 # i18n: "date" is a keyword |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
641 ds = getstring(x, _("date requires a string")) |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
642 dm = util.matchdate(ds) |
28424
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
643 return subset.filter(lambda x: dm(repo[x].date()[0]), |
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
644 condrepr=('<date %r>', ds)) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
645 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
646 @predicate('desc(string)', safe=True) |
14650
93731b3efd0d
revset: add desc(string) to search in commit messages
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14649
diff
changeset
|
647 def desc(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
648 """Search commit message for string. The match is case-insensitive. |
30783
931a60880df4
revset: add regular expression support to 'desc'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30782
diff
changeset
|
649 |
30784
5dd67f0993ce
help: eliminate duplicate text for revset string patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
30783
diff
changeset
|
650 Pattern matching is supported for `string`. See |
30799
0b49449a01f4
help: use :hg: role and canonical name to point to revset string patterns
Yuya Nishihara <yuya@tcha.org>
parents:
30784
diff
changeset
|
651 :hg:`help revisions.patterns`. |
14650
93731b3efd0d
revset: add desc(string) to search in commit messages
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14649
diff
changeset
|
652 """ |
93731b3efd0d
revset: add desc(string) to search in commit messages
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14649
diff
changeset
|
653 # i18n: "desc" is a keyword |
30783
931a60880df4
revset: add regular expression support to 'desc'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30782
diff
changeset
|
654 ds = getstring(x, _("desc requires a string")) |
931a60880df4
revset: add regular expression support to 'desc'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30782
diff
changeset
|
655 |
931a60880df4
revset: add regular expression support to 'desc'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30782
diff
changeset
|
656 kind, pattern, matcher = _substringmatcher(ds, casesensitive=False) |
931a60880df4
revset: add regular expression support to 'desc'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30782
diff
changeset
|
657 |
931a60880df4
revset: add regular expression support to 'desc'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30782
diff
changeset
|
658 return subset.filter(lambda r: matcher(repo[r].description()), |
931a60880df4
revset: add regular expression support to 'desc'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30782
diff
changeset
|
659 condrepr=('<desc %r>', ds)) |
14650
93731b3efd0d
revset: add desc(string) to search in commit messages
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14649
diff
changeset
|
660 |
16409
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
661 def _descendants(repo, subset, x, followfirst=False): |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
662 roots = getset(repo, fullreposet(repo), x) |
22944
5aae3dea8044
revset: better naming of variables containing the value of a single argument
Mads Kiilerich <madski@unity3d.com>
parents:
22891
diff
changeset
|
663 if not roots: |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
664 return baseset() |
22944
5aae3dea8044
revset: better naming of variables containing the value of a single argument
Mads Kiilerich <madski@unity3d.com>
parents:
22891
diff
changeset
|
665 s = _revdescendants(repo, roots, followfirst) |
20894
04e1596d5dbd
revset: improve _descendants performance
Durham Goode <durham@fb.com>
parents:
20863
diff
changeset
|
666 |
04e1596d5dbd
revset: improve _descendants performance
Durham Goode <durham@fb.com>
parents:
20863
diff
changeset
|
667 # Both sets need to be ascending in order to lazily return the union |
04e1596d5dbd
revset: improve _descendants performance
Durham Goode <durham@fb.com>
parents:
20863
diff
changeset
|
668 # in the correct order. |
22944
5aae3dea8044
revset: better naming of variables containing the value of a single argument
Mads Kiilerich <madski@unity3d.com>
parents:
22891
diff
changeset
|
669 base = subset & roots |
22860
1dd178277cf5
revset-_descendant: rework the whole sorting and combining logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22859
diff
changeset
|
670 desc = subset & s |
1dd178277cf5
revset-_descendant: rework the whole sorting and combining logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22859
diff
changeset
|
671 result = base + desc |
1dd178277cf5
revset-_descendant: rework the whole sorting and combining logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22859
diff
changeset
|
672 if subset.isascending(): |
1dd178277cf5
revset-_descendant: rework the whole sorting and combining logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22859
diff
changeset
|
673 result.sort() |
1dd178277cf5
revset-_descendant: rework the whole sorting and combining logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22859
diff
changeset
|
674 elif subset.isdescending(): |
1dd178277cf5
revset-_descendant: rework the whole sorting and combining logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22859
diff
changeset
|
675 result.sort(reverse=True) |
1dd178277cf5
revset-_descendant: rework the whole sorting and combining logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22859
diff
changeset
|
676 else: |
1dd178277cf5
revset-_descendant: rework the whole sorting and combining logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22859
diff
changeset
|
677 result = subset & result |
22830
1d1da8abe130
_descendants: directly use smartset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22829
diff
changeset
|
678 return result |
16409
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
679 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
680 @predicate('descendants(set)', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
681 def descendants(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
682 """Changesets which are descendants of changesets in set. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
683 """ |
16409
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
684 return _descendants(repo, subset, x) |
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
685 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
686 @predicate('_firstdescendants', safe=True) |
16409
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
687 def _firstdescendants(repo, subset, x): |
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
688 # ``_firstdescendants(set)`` |
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
689 # Like ``descendants(set)`` but follows only the first parents. |
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
690 return _descendants(repo, subset, x, followfirst=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
691 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
692 @predicate('destination([set])', safe=True) |
17186
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
693 def destination(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
694 """Changesets that were created by a graft, transplant or rebase operation, |
17186
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
695 with the given revisions specified as the source. Omitting the optional set |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
696 is the same as passing all(). |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
697 """ |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
698 if x is not None: |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
699 sources = getset(repo, fullreposet(repo), x) |
17186
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
700 else: |
24201
77ef059b3317
revset: drop unnecessary calls of getall() with empty argument
Yuya Nishihara <yuya@tcha.org>
parents:
24163
diff
changeset
|
701 sources = fullreposet(repo) |
17186
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
702 |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
703 dests = set() |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
704 |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
705 # subset contains all of the possible destinations that can be returned, so |
22944
5aae3dea8044
revset: better naming of variables containing the value of a single argument
Mads Kiilerich <madski@unity3d.com>
parents:
22891
diff
changeset
|
706 # iterate over them and see if their source(s) were provided in the arg set. |
5aae3dea8044
revset: better naming of variables containing the value of a single argument
Mads Kiilerich <madski@unity3d.com>
parents:
22891
diff
changeset
|
707 # Even if the immediate src of r is not in the arg set, src's source (or |
17186
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
708 # further back) may be. Scanning back further than the immediate src allows |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
709 # transitive transplants and rebases to yield the same results as transitive |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
710 # grafts. |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
711 for r in subset: |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
712 src = _getrevsource(repo, r) |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
713 lineage = None |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
714 |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
715 while src is not None: |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
716 if lineage is None: |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
717 lineage = list() |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
718 |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
719 lineage.append(r) |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
720 |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
721 # The visited lineage is a match if the current source is in the arg |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
722 # set. Since every candidate dest is visited by way of iterating |
17494 | 723 # subset, any dests further back in the lineage will be tested by a |
17186
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
724 # different iteration over subset. Likewise, if the src was already |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
725 # selected, the current lineage can be selected without going back |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
726 # further. |
22944
5aae3dea8044
revset: better naming of variables containing the value of a single argument
Mads Kiilerich <madski@unity3d.com>
parents:
22891
diff
changeset
|
727 if src in sources or src in dests: |
17186
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
728 dests.update(lineage) |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
729 break |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
730 |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
731 r = src |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
732 src = _getrevsource(repo, r) |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
733 |
28424
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
734 return subset.filter(dests.__contains__, |
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
735 condrepr=lambda: '<destination %r>' % sorted(dests)) |
17186
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
736 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
737 @predicate('divergent()', safe=True) |
18071
bea754715961
obsolete: add revset and test for divergent changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18063
diff
changeset
|
738 def divergent(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
739 """ |
18071
bea754715961
obsolete: add revset and test for divergent changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18063
diff
changeset
|
740 Final successors of changesets with an alternative set of final successors. |
bea754715961
obsolete: add revset and test for divergent changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18063
diff
changeset
|
741 """ |
bea754715961
obsolete: add revset and test for divergent changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18063
diff
changeset
|
742 # i18n: "divergent" is a keyword |
bea754715961
obsolete: add revset and test for divergent changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18063
diff
changeset
|
743 getargs(x, 0, 0, _("divergent takes no arguments")) |
bea754715961
obsolete: add revset and test for divergent changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18063
diff
changeset
|
744 divergent = obsmod.getrevs(repo, 'divergent') |
22533
5b65429721d5
revset: use `subset &` in `divergent`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22532
diff
changeset
|
745 return subset & divergent |
18071
bea754715961
obsolete: add revset and test for divergent changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18063
diff
changeset
|
746 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
747 @predicate('extinct()', safe=True) |
17173
c621f84dbb35
obsolete: compute extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17171
diff
changeset
|
748 def extinct(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
749 """Obsolete changesets with obsolete descendants only. |
17291
2d6bbf87f7b4
revset: minor doc fixes on obsolete related revsets
Patrick Mezard <patrick@mezard.eu>
parents:
17272
diff
changeset
|
750 """ |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
751 # i18n: "extinct" is a keyword |
17258
5822345e9e46
revset: use appropriate predicate name in error messages
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17244
diff
changeset
|
752 getargs(x, 0, 0, _("extinct takes no arguments")) |
17825
3cc06457f15e
obsolete: rename `getobscache` into `getrevs`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17804
diff
changeset
|
753 extincts = obsmod.getrevs(repo, 'extinct') |
20367
2ac278aab2b4
revset: added intersection to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20366
diff
changeset
|
754 return subset & extincts |
17173
c621f84dbb35
obsolete: compute extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17171
diff
changeset
|
755 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
756 @predicate('extra(label, [value])', safe=True) |
16661
de4b42daf396
revset: add function for matching extra data (issue2767)
Henrik Stuart <hg@hstuart.dk>
parents:
16657
diff
changeset
|
757 def extra(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
758 """Changesets with the given label in the extra metadata, with the given |
16824
f3b8c82a559c
revset: add pattern matching to 'extra' revset expression
Simon King <simon@simonking.org.uk>
parents:
16823
diff
changeset
|
759 optional value. |
f3b8c82a559c
revset: add pattern matching to 'extra' revset expression
Simon King <simon@simonking.org.uk>
parents:
16823
diff
changeset
|
760 |
30784
5dd67f0993ce
help: eliminate duplicate text for revset string patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
30783
diff
changeset
|
761 Pattern matching is supported for `value`. See |
30799
0b49449a01f4
help: use :hg: role and canonical name to point to revset string patterns
Yuya Nishihara <yuya@tcha.org>
parents:
30784
diff
changeset
|
762 :hg:`help revisions.patterns`. |
16824
f3b8c82a559c
revset: add pattern matching to 'extra' revset expression
Simon King <simon@simonking.org.uk>
parents:
16823
diff
changeset
|
763 """ |
25767
026105c442d7
revset: rename getkwargs() to getargsdict()
Yuya Nishihara <yuya@tcha.org>
parents:
25766
diff
changeset
|
764 args = getargsdict(x, 'extra', 'label value') |
25706
b7f53c474e2c
revset: port extra() to support keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents:
25705
diff
changeset
|
765 if 'label' not in args: |
b7f53c474e2c
revset: port extra() to support keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents:
25705
diff
changeset
|
766 # i18n: "extra" is a keyword |
b7f53c474e2c
revset: port extra() to support keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents:
25705
diff
changeset
|
767 raise error.ParseError(_('extra takes at least 1 argument')) |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
768 # i18n: "extra" is a keyword |
25706
b7f53c474e2c
revset: port extra() to support keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents:
25705
diff
changeset
|
769 label = getstring(args['label'], _('first argument to extra must be ' |
b7f53c474e2c
revset: port extra() to support keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents:
25705
diff
changeset
|
770 'a string')) |
16661
de4b42daf396
revset: add function for matching extra data (issue2767)
Henrik Stuart <hg@hstuart.dk>
parents:
16657
diff
changeset
|
771 value = None |
de4b42daf396
revset: add function for matching extra data (issue2767)
Henrik Stuart <hg@hstuart.dk>
parents:
16657
diff
changeset
|
772 |
25706
b7f53c474e2c
revset: port extra() to support keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents:
25705
diff
changeset
|
773 if 'value' in args: |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
774 # i18n: "extra" is a keyword |
25706
b7f53c474e2c
revset: port extra() to support keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents:
25705
diff
changeset
|
775 value = getstring(args['value'], _('second argument to extra must be ' |
b7f53c474e2c
revset: port extra() to support keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents:
25705
diff
changeset
|
776 'a string')) |
26481
7d132557e44a
util: extract stringmatcher() from revset
Matt Harbison <matt_harbison@yahoo.com>
parents:
26307
diff
changeset
|
777 kind, value, matcher = util.stringmatcher(value) |
16661
de4b42daf396
revset: add function for matching extra data (issue2767)
Henrik Stuart <hg@hstuart.dk>
parents:
16657
diff
changeset
|
778 |
de4b42daf396
revset: add function for matching extra data (issue2767)
Henrik Stuart <hg@hstuart.dk>
parents:
16657
diff
changeset
|
779 def _matchvalue(r): |
de4b42daf396
revset: add function for matching extra data (issue2767)
Henrik Stuart <hg@hstuart.dk>
parents:
16657
diff
changeset
|
780 extra = repo[r].extra() |
16824
f3b8c82a559c
revset: add pattern matching to 'extra' revset expression
Simon King <simon@simonking.org.uk>
parents:
16823
diff
changeset
|
781 return label in extra and (value is None or matcher(extra[label])) |
16661
de4b42daf396
revset: add function for matching extra data (issue2767)
Henrik Stuart <hg@hstuart.dk>
parents:
16657
diff
changeset
|
782 |
28424
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
783 return subset.filter(lambda r: _matchvalue(r), |
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
784 condrepr=('<extra[%r] %r>', label, value)) |
15819
33ca11b010e2
phases: implements simple revset symbol
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15791
diff
changeset
|
785 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
786 @predicate('filelog(pattern)', safe=True) |
14342
c0b6a734b4f3
revset: introduce filelog() to emulate log's fast path
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
787 def filelog(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
788 """Changesets connected to the specified filelog. |
17244
483aa765f6c4
revset: add explanation about difference between 'filelog()' and 'file()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17186
diff
changeset
|
789 |
21199
e9c2f76be74b
help: clarify distinction among `contains`/`file`/`filelog`
Greg Hurrell <glh@fb.com>
parents:
21173
diff
changeset
|
790 For performance reasons, visits only revisions mentioned in the file-level |
e9c2f76be74b
help: clarify distinction among `contains`/`file`/`filelog`
Greg Hurrell <glh@fb.com>
parents:
21173
diff
changeset
|
791 filelog, rather than filtering through all changesets (much faster, but |
e9c2f76be74b
help: clarify distinction among `contains`/`file`/`filelog`
Greg Hurrell <glh@fb.com>
parents:
21173
diff
changeset
|
792 doesn't include deletes or duplicate changes). For a slower, more accurate |
e9c2f76be74b
help: clarify distinction among `contains`/`file`/`filelog`
Greg Hurrell <glh@fb.com>
parents:
21173
diff
changeset
|
793 result, use ``file()``. |
20289
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
794 |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
795 The pattern without explicit kind like ``glob:`` is expected to be |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
796 relative to the current directory and match against a file exactly |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
797 for efficiency. |
23719
34364a4b25eb
linkrev: work around linkrev to filtered entry in 'filelog' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23704
diff
changeset
|
798 |
34364a4b25eb
linkrev: work around linkrev to filtered entry in 'filelog' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23704
diff
changeset
|
799 If some linkrev points to revisions filtered by the current repoview, we'll |
34364a4b25eb
linkrev: work around linkrev to filtered entry in 'filelog' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23704
diff
changeset
|
800 work around it to return a non-filtered value. |
14342
c0b6a734b4f3
revset: introduce filelog() to emulate log's fast path
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
801 """ |
c0b6a734b4f3
revset: introduce filelog() to emulate log's fast path
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
802 |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
803 # i18n: "filelog" is a keyword |
14342
c0b6a734b4f3
revset: introduce filelog() to emulate log's fast path
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
804 pat = getstring(x, _("filelog requires a pattern")) |
c0b6a734b4f3
revset: introduce filelog() to emulate log's fast path
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
805 s = set() |
23719
34364a4b25eb
linkrev: work around linkrev to filtered entry in 'filelog' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23704
diff
changeset
|
806 cl = repo.changelog |
14342
c0b6a734b4f3
revset: introduce filelog() to emulate log's fast path
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
807 |
15964
6e37b8282aa2
revsets: provide contexts for filesets
Matt Mackall <mpm@selenic.com>
parents:
15949
diff
changeset
|
808 if not matchmod.patkind(pat): |
20288
b61ad01c4e73
revset: use "canonpath()" for "filelog()" pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20287
diff
changeset
|
809 f = pathutil.canonpath(repo.root, repo.getcwd(), pat) |
23719
34364a4b25eb
linkrev: work around linkrev to filtered entry in 'filelog' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23704
diff
changeset
|
810 files = [f] |
14342
c0b6a734b4f3
revset: introduce filelog() to emulate log's fast path
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
811 else: |
20288
b61ad01c4e73
revset: use "canonpath()" for "filelog()" pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20287
diff
changeset
|
812 m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=repo[None]) |
23719
34364a4b25eb
linkrev: work around linkrev to filtered entry in 'filelog' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23704
diff
changeset
|
813 files = (f for f in repo[None] if m(f)) |
34364a4b25eb
linkrev: work around linkrev to filtered entry in 'filelog' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23704
diff
changeset
|
814 |
34364a4b25eb
linkrev: work around linkrev to filtered entry in 'filelog' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23704
diff
changeset
|
815 for f in files: |
34364a4b25eb
linkrev: work around linkrev to filtered entry in 'filelog' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23704
diff
changeset
|
816 fl = repo.file(f) |
27945
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
817 known = {} |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
818 scanpos = 0 |
23719
34364a4b25eb
linkrev: work around linkrev to filtered entry in 'filelog' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23704
diff
changeset
|
819 for fr in list(fl): |
27945
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
820 fn = fl.node(fr) |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
821 if fn in known: |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
822 s.add(known[fn]) |
23821
7a7f437ab63d
filelog: remove trailing "form feed" character
Martin von Zweigbergk <martinvonz@google.com>
parents:
23820
diff
changeset
|
823 continue |
27945
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
824 |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
825 lr = fl.linkrev(fr) |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
826 if lr in cl: |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
827 s.add(lr) |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
828 elif scanpos is not None: |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
829 # lowest matching changeset is filtered, scan further |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
830 # ahead in changelog |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
831 start = max(lr, scanpos) + 1 |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
832 scanpos = None |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
833 for r in cl.revs(start): |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
834 # minimize parsing of non-matching entries |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
835 if f in cl.revision(r) and f in cl.readfiles(r): |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
836 try: |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
837 # try to use manifest delta fastpath |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
838 n = repo[r].filenode(f) |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
839 if n not in known: |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
840 if n == fn: |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
841 s.add(r) |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
842 scanpos = r |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
843 break |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
844 else: |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
845 known[n] = r |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
846 except error.ManifestLookupError: |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
847 # deletion in changelog |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
848 continue |
14342
c0b6a734b4f3
revset: introduce filelog() to emulate log's fast path
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
849 |
22534
6261b9c549a2
revset: use `subset &` in `filelog`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22533
diff
changeset
|
850 return subset & s |
14342
c0b6a734b4f3
revset: introduce filelog() to emulate log's fast path
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
851 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
852 @predicate('first(set, [n])', safe=True) |
15117
0ab1c3a1f3b2
revsets: add first alias for last
Matt Mackall <mpm@selenic.com>
parents:
15116
diff
changeset
|
853 def first(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
854 """An alias for limit(). |
15117
0ab1c3a1f3b2
revsets: add first alias for last
Matt Mackall <mpm@selenic.com>
parents:
15116
diff
changeset
|
855 """ |
0ab1c3a1f3b2
revsets: add first alias for last
Matt Mackall <mpm@selenic.com>
parents:
15116
diff
changeset
|
856 return limit(repo, subset, x) |
0ab1c3a1f3b2
revsets: add first alias for last
Matt Mackall <mpm@selenic.com>
parents:
15116
diff
changeset
|
857 |
16185
352053e6cd8e
context: add followfirst arg to filectx and workingfilectx
Patrick Mezard <patrick@mezard.eu>
parents:
16181
diff
changeset
|
858 def _follow(repo, subset, x, name, followfirst=False): |
29814
cbf9984a7957
revset: support "follow(renamed.py, e22f4f3f06c3)" (issue5334)
Gábor Stefanik <gabor.stefanik@nng.com>
parents:
29780
diff
changeset
|
859 l = getargs(x, 0, 2, _("%s takes no arguments or a pattern " |
cbf9984a7957
revset: support "follow(renamed.py, e22f4f3f06c3)" (issue5334)
Gábor Stefanik <gabor.stefanik@nng.com>
parents:
29780
diff
changeset
|
860 "and an optional revset") % name) |
16185
352053e6cd8e
context: add followfirst arg to filectx and workingfilectx
Patrick Mezard <patrick@mezard.eu>
parents:
16181
diff
changeset
|
861 c = repo['.'] |
352053e6cd8e
context: add followfirst arg to filectx and workingfilectx
Patrick Mezard <patrick@mezard.eu>
parents:
16181
diff
changeset
|
862 if l: |
26102
5618858dce26
revsets: makes follow() supports file patterns (issue4757) (BC)
liscju <piotr.listkiewicz@gmail.com>
parents:
26099
diff
changeset
|
863 x = getstring(l[0], _("%s expected a pattern") % name) |
29814
cbf9984a7957
revset: support "follow(renamed.py, e22f4f3f06c3)" (issue5334)
Gábor Stefanik <gabor.stefanik@nng.com>
parents:
29780
diff
changeset
|
864 rev = None |
cbf9984a7957
revset: support "follow(renamed.py, e22f4f3f06c3)" (issue5334)
Gábor Stefanik <gabor.stefanik@nng.com>
parents:
29780
diff
changeset
|
865 if len(l) >= 2: |
30178
d61c42c1a35c
revset: make follow() reject more than one start revisions
Yuya Nishihara <yuya@tcha.org>
parents:
30071
diff
changeset
|
866 revs = getset(repo, fullreposet(repo), l[1]) |
d61c42c1a35c
revset: make follow() reject more than one start revisions
Yuya Nishihara <yuya@tcha.org>
parents:
30071
diff
changeset
|
867 if len(revs) != 1: |
29814
cbf9984a7957
revset: support "follow(renamed.py, e22f4f3f06c3)" (issue5334)
Gábor Stefanik <gabor.stefanik@nng.com>
parents:
29780
diff
changeset
|
868 raise error.RepoLookupError( |
30178
d61c42c1a35c
revset: make follow() reject more than one start revisions
Yuya Nishihara <yuya@tcha.org>
parents:
30071
diff
changeset
|
869 _("%s expected one starting revision") % name) |
d61c42c1a35c
revset: make follow() reject more than one start revisions
Yuya Nishihara <yuya@tcha.org>
parents:
30071
diff
changeset
|
870 rev = revs.last() |
29814
cbf9984a7957
revset: support "follow(renamed.py, e22f4f3f06c3)" (issue5334)
Gábor Stefanik <gabor.stefanik@nng.com>
parents:
29780
diff
changeset
|
871 c = repo[rev] |
26102
5618858dce26
revsets: makes follow() supports file patterns (issue4757) (BC)
liscju <piotr.listkiewicz@gmail.com>
parents:
26099
diff
changeset
|
872 matcher = matchmod.match(repo.root, repo.getcwd(), [x], |
29814
cbf9984a7957
revset: support "follow(renamed.py, e22f4f3f06c3)" (issue5334)
Gábor Stefanik <gabor.stefanik@nng.com>
parents:
29780
diff
changeset
|
873 ctx=repo[rev], default='path') |
26102
5618858dce26
revsets: makes follow() supports file patterns (issue4757) (BC)
liscju <piotr.listkiewicz@gmail.com>
parents:
26099
diff
changeset
|
874 |
28008
86c4cbdaffee
revset: use manifest.matches in _follow revset
Durham Goode <durham@fb.com>
parents:
27945
diff
changeset
|
875 files = c.manifest().walk(matcher) |
86c4cbdaffee
revset: use manifest.matches in _follow revset
Durham Goode <durham@fb.com>
parents:
27945
diff
changeset
|
876 |
26102
5618858dce26
revsets: makes follow() supports file patterns (issue4757) (BC)
liscju <piotr.listkiewicz@gmail.com>
parents:
26099
diff
changeset
|
877 s = set() |
28008
86c4cbdaffee
revset: use manifest.matches in _follow revset
Durham Goode <durham@fb.com>
parents:
27945
diff
changeset
|
878 for fname in files: |
86c4cbdaffee
revset: use manifest.matches in _follow revset
Durham Goode <durham@fb.com>
parents:
27945
diff
changeset
|
879 fctx = c[fname] |
86c4cbdaffee
revset: use manifest.matches in _follow revset
Durham Goode <durham@fb.com>
parents:
27945
diff
changeset
|
880 s = s.union(set(c.rev() for c in fctx.ancestors(followfirst))) |
86c4cbdaffee
revset: use manifest.matches in _follow revset
Durham Goode <durham@fb.com>
parents:
27945
diff
changeset
|
881 # include the revision responsible for the most recent version |
86c4cbdaffee
revset: use manifest.matches in _follow revset
Durham Goode <durham@fb.com>
parents:
27945
diff
changeset
|
882 s.add(fctx.introrev()) |
16185
352053e6cd8e
context: add followfirst arg to filectx and workingfilectx
Patrick Mezard <patrick@mezard.eu>
parents:
16181
diff
changeset
|
883 else: |
20690
13c0327eeb6f
revset: changed ancestors revset to return lazy generators
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20659
diff
changeset
|
884 s = _revancestors(repo, baseset([c.rev()]), followfirst) |
16185
352053e6cd8e
context: add followfirst arg to filectx and workingfilectx
Patrick Mezard <patrick@mezard.eu>
parents:
16181
diff
changeset
|
885 |
22535
44f471102f3a
revset: use `subset &` in `follow`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22534
diff
changeset
|
886 return subset & s |
16185
352053e6cd8e
context: add followfirst arg to filectx and workingfilectx
Patrick Mezard <patrick@mezard.eu>
parents:
16181
diff
changeset
|
887 |
29814
cbf9984a7957
revset: support "follow(renamed.py, e22f4f3f06c3)" (issue5334)
Gábor Stefanik <gabor.stefanik@nng.com>
parents:
29780
diff
changeset
|
888 @predicate('follow([pattern[, startrev]])', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
889 def follow(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
890 """ |
24366
e8ea31131705
revset: replace "working copy" with "working directory" in function help
Yuya Nishihara <yuya@tcha.org>
parents:
24306
diff
changeset
|
891 An alias for ``::.`` (ancestors of the working directory's first parent). |
26102
5618858dce26
revsets: makes follow() supports file patterns (issue4757) (BC)
liscju <piotr.listkiewicz@gmail.com>
parents:
26099
diff
changeset
|
892 If pattern is specified, the histories of files matching given |
29814
cbf9984a7957
revset: support "follow(renamed.py, e22f4f3f06c3)" (issue5334)
Gábor Stefanik <gabor.stefanik@nng.com>
parents:
29780
diff
changeset
|
893 pattern in the revision given by startrev are followed, including copies. |
14343
9ed227f79e47
revset: add follow(filename) to follow a filename's history across copies
Matt Mackall <mpm@selenic.com>
parents:
14342
diff
changeset
|
894 """ |
16185
352053e6cd8e
context: add followfirst arg to filectx and workingfilectx
Patrick Mezard <patrick@mezard.eu>
parents:
16181
diff
changeset
|
895 return _follow(repo, subset, x, 'follow') |
14343
9ed227f79e47
revset: add follow(filename) to follow a filename's history across copies
Matt Mackall <mpm@selenic.com>
parents:
14342
diff
changeset
|
896 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
897 @predicate('_followfirst', safe=True) |
16174
0a73c4bd9f47
graphlog: implement --follow-first
Patrick Mezard <patrick@mezard.eu>
parents:
16161
diff
changeset
|
898 def _followfirst(repo, subset, x): |
29814
cbf9984a7957
revset: support "follow(renamed.py, e22f4f3f06c3)" (issue5334)
Gábor Stefanik <gabor.stefanik@nng.com>
parents:
29780
diff
changeset
|
899 # ``followfirst([pattern[, startrev]])`` |
cbf9984a7957
revset: support "follow(renamed.py, e22f4f3f06c3)" (issue5334)
Gábor Stefanik <gabor.stefanik@nng.com>
parents:
29780
diff
changeset
|
900 # Like ``follow([pattern[, startrev]])`` but follows only the first parent |
cbf9984a7957
revset: support "follow(renamed.py, e22f4f3f06c3)" (issue5334)
Gábor Stefanik <gabor.stefanik@nng.com>
parents:
29780
diff
changeset
|
901 # of every revisions or files revisions. |
16185
352053e6cd8e
context: add followfirst arg to filectx and workingfilectx
Patrick Mezard <patrick@mezard.eu>
parents:
16181
diff
changeset
|
902 return _follow(repo, subset, x, '_followfirst', followfirst=True) |
14343
9ed227f79e47
revset: add follow(filename) to follow a filename's history across copies
Matt Mackall <mpm@selenic.com>
parents:
14342
diff
changeset
|
903 |
30804
4227f80f72b2
revset: abuse x:y syntax to specify line range of followlines()
Yuya Nishihara <yuya@tcha.org>
parents:
30803
diff
changeset
|
904 @predicate('followlines(file, fromline:toline[, startrev=.])', safe=True) |
30719
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
905 def followlines(repo, subset, x): |
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
906 """Changesets modifying `file` in line range ('fromline', 'toline'). |
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
907 |
30800
cd23879cbac7
revset: rename rev argument of followlines() to startrev
Yuya Nishihara <yuya@tcha.org>
parents:
30799
diff
changeset
|
908 Line range corresponds to 'file' content at 'startrev' and should hence be |
cd23879cbac7
revset: rename rev argument of followlines() to startrev
Yuya Nishihara <yuya@tcha.org>
parents:
30799
diff
changeset
|
909 consistent with file size. If startrev is not specified, working directory's |
30719
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
910 parent is used. |
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
911 """ |
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
912 from . import context # avoid circular import issues |
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
913 |
30800
cd23879cbac7
revset: rename rev argument of followlines() to startrev
Yuya Nishihara <yuya@tcha.org>
parents:
30799
diff
changeset
|
914 args = getargsdict(x, 'followlines', 'file *lines startrev') |
30804
4227f80f72b2
revset: abuse x:y syntax to specify line range of followlines()
Yuya Nishihara <yuya@tcha.org>
parents:
30803
diff
changeset
|
915 if len(args['lines']) != 1: |
4227f80f72b2
revset: abuse x:y syntax to specify line range of followlines()
Yuya Nishihara <yuya@tcha.org>
parents:
30803
diff
changeset
|
916 raise error.ParseError(_("followlines requires a line range")) |
30719
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
917 |
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
918 rev = '.' |
30800
cd23879cbac7
revset: rename rev argument of followlines() to startrev
Yuya Nishihara <yuya@tcha.org>
parents:
30799
diff
changeset
|
919 if 'startrev' in args: |
cd23879cbac7
revset: rename rev argument of followlines() to startrev
Yuya Nishihara <yuya@tcha.org>
parents:
30799
diff
changeset
|
920 revs = getset(repo, fullreposet(repo), args['startrev']) |
30754
26209cb7184e
revset: parse variable-length arguments of followlines() by getargsdict()
Yuya Nishihara <yuya@tcha.org>
parents:
30753
diff
changeset
|
921 if len(revs) != 1: |
26209cb7184e
revset: parse variable-length arguments of followlines() by getargsdict()
Yuya Nishihara <yuya@tcha.org>
parents:
30753
diff
changeset
|
922 raise error.ParseError( |
26209cb7184e
revset: parse variable-length arguments of followlines() by getargsdict()
Yuya Nishihara <yuya@tcha.org>
parents:
30753
diff
changeset
|
923 _("followlines expects exactly one revision")) |
26209cb7184e
revset: parse variable-length arguments of followlines() by getargsdict()
Yuya Nishihara <yuya@tcha.org>
parents:
30753
diff
changeset
|
924 rev = revs.last() |
26209cb7184e
revset: parse variable-length arguments of followlines() by getargsdict()
Yuya Nishihara <yuya@tcha.org>
parents:
30753
diff
changeset
|
925 |
26209cb7184e
revset: parse variable-length arguments of followlines() by getargsdict()
Yuya Nishihara <yuya@tcha.org>
parents:
30753
diff
changeset
|
926 pat = getstring(args['file'], _("followlines requires a pattern")) |
30719
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
927 if not matchmod.patkind(pat): |
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
928 fname = pathutil.canonpath(repo.root, repo.getcwd(), pat) |
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
929 else: |
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
930 m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=repo[rev]) |
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
931 files = [f for f in repo[rev] if m(f)] |
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
932 if len(files) != 1: |
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
933 raise error.ParseError(_("followlines expects exactly one file")) |
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
934 fname = files[0] |
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
935 |
30804
4227f80f72b2
revset: abuse x:y syntax to specify line range of followlines()
Yuya Nishihara <yuya@tcha.org>
parents:
30803
diff
changeset
|
936 lr = getrange(args['lines'][0], _("followlines expects a line range")) |
30801
67ee7874e53b
revset: factor out getinteger() helper
Yuya Nishihara <yuya@tcha.org>
parents:
30800
diff
changeset
|
937 fromline, toline = [getinteger(a, _("line range bounds must be integers")) |
30804
4227f80f72b2
revset: abuse x:y syntax to specify line range of followlines()
Yuya Nishihara <yuya@tcha.org>
parents:
30803
diff
changeset
|
938 for a in lr] |
31662
080734cd2440
revset: factor out linerange processing into a utility function
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31076
diff
changeset
|
939 fromline, toline = util.processlinerange(fromline, toline) |
30719
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
940 |
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
941 fctx = repo[rev].filectx(fname) |
31076
0e07855e6054
context: also return ancestor's line range in blockancestors
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31024
diff
changeset
|
942 revs = (c.rev() for c, _linerange |
0e07855e6054
context: also return ancestor's line range in blockancestors
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31024
diff
changeset
|
943 in context.blockancestors(fctx, fromline, toline)) |
30719
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
944 return subset & generatorset(revs, iterasc=False) |
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
945 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
946 @predicate('all()', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
947 def getall(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
948 """All changesets, the same as ``0:tip``. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
949 """ |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
950 # i18n: "all" is a keyword |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
951 getargs(x, 0, 0, _("all takes no arguments")) |
24202
2de9ee016425
revset: have all() filter out null revision
Yuya Nishihara <yuya@tcha.org>
parents:
24201
diff
changeset
|
952 return subset & spanset(repo) # drop "null" if any |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
953 |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
954 @predicate('grep(regex)') |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
955 def grep(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
956 """Like ``keyword(string)`` but accepts a regex. Use ``grep(r'...')`` |
14357 | 957 to ensure special escape characters are handled correctly. Unlike |
958 ``keyword(string)``, the match is case-sensitive. | |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
959 """ |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
960 try: |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
961 # i18n: "grep" is a keyword |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
962 gr = re.compile(getstring(x, _("grep requires a string"))) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25654
diff
changeset
|
963 except re.error as e: |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
964 raise error.ParseError(_('invalid match pattern: %s') % e) |
20453
6aa7dcae6bd8
revset: added lazyset implementation to grep revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20452
diff
changeset
|
965 |
6aa7dcae6bd8
revset: added lazyset implementation to grep revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20452
diff
changeset
|
966 def matches(x): |
6aa7dcae6bd8
revset: added lazyset implementation to grep revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20452
diff
changeset
|
967 c = repo[x] |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
968 for e in c.files() + [c.user(), c.description()]: |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
969 if gr.search(e): |
20453
6aa7dcae6bd8
revset: added lazyset implementation to grep revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20452
diff
changeset
|
970 return True |
6aa7dcae6bd8
revset: added lazyset implementation to grep revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20452
diff
changeset
|
971 return False |
6aa7dcae6bd8
revset: added lazyset implementation to grep revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20452
diff
changeset
|
972 |
28424
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
973 return subset.filter(matches, condrepr=('<grep %r>', gr.pattern)) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
974 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
975 @predicate('_matchfiles', safe=True) |
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
976 def _matchfiles(repo, subset, x): |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
977 # _matchfiles takes a revset list of prefixed arguments: |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
978 # |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
979 # [p:foo, i:bar, x:baz] |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
980 # |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
981 # builds a match object from them and filters subset. Allowed |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
982 # prefixes are 'p:' for regular patterns, 'i:' for include |
16181
1fd352aa08fc
graphlog: evaluate FILE/-I/-X filesets on the working dir
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
983 # patterns and 'x:' for exclude patterns. Use 'r:' prefix to pass |
1fd352aa08fc
graphlog: evaluate FILE/-I/-X filesets on the working dir
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
984 # a revision identifier, or the empty string to reference the |
1fd352aa08fc
graphlog: evaluate FILE/-I/-X filesets on the working dir
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
985 # working directory, from which the match object is |
16411
4c2edcd84175
graphlog: correctly handle calls in subdirectories
Patrick Mezard <patrick@mezard.eu>
parents:
16409
diff
changeset
|
986 # initialized. Use 'd:' to set the default matching mode, default |
4c2edcd84175
graphlog: correctly handle calls in subdirectories
Patrick Mezard <patrick@mezard.eu>
parents:
16409
diff
changeset
|
987 # to 'glob'. At most one 'r:' and 'd:' argument can be passed. |
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
988 |
28271
5c454ab69558
revset: drop translation markers from error messages of internal _matchfiles
Yuya Nishihara <yuya@tcha.org>
parents:
28217
diff
changeset
|
989 l = getargs(x, 1, -1, "_matchfiles requires at least one argument") |
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
990 pats, inc, exc = [], [], [] |
16411
4c2edcd84175
graphlog: correctly handle calls in subdirectories
Patrick Mezard <patrick@mezard.eu>
parents:
16409
diff
changeset
|
991 rev, default = None, None |
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
992 for arg in l: |
28271
5c454ab69558
revset: drop translation markers from error messages of internal _matchfiles
Yuya Nishihara <yuya@tcha.org>
parents:
28217
diff
changeset
|
993 s = getstring(arg, "_matchfiles requires string arguments") |
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
994 prefix, value = s[:2], s[2:] |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
995 if prefix == 'p:': |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
996 pats.append(value) |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
997 elif prefix == 'i:': |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
998 inc.append(value) |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
999 elif prefix == 'x:': |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
1000 exc.append(value) |
16181
1fd352aa08fc
graphlog: evaluate FILE/-I/-X filesets on the working dir
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
1001 elif prefix == 'r:': |
1fd352aa08fc
graphlog: evaluate FILE/-I/-X filesets on the working dir
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
1002 if rev is not None: |
28271
5c454ab69558
revset: drop translation markers from error messages of internal _matchfiles
Yuya Nishihara <yuya@tcha.org>
parents:
28217
diff
changeset
|
1003 raise error.ParseError('_matchfiles expected at most one ' |
5c454ab69558
revset: drop translation markers from error messages of internal _matchfiles
Yuya Nishihara <yuya@tcha.org>
parents:
28217
diff
changeset
|
1004 'revision') |
23950
caff3675cba5
log: evaluate filesets on working copy, not its parent
Martin von Zweigbergk <martinvonz@google.com>
parents:
23847
diff
changeset
|
1005 if value != '': # empty means working directory; leave rev as None |
caff3675cba5
log: evaluate filesets on working copy, not its parent
Martin von Zweigbergk <martinvonz@google.com>
parents:
23847
diff
changeset
|
1006 rev = value |
16411
4c2edcd84175
graphlog: correctly handle calls in subdirectories
Patrick Mezard <patrick@mezard.eu>
parents:
16409
diff
changeset
|
1007 elif prefix == 'd:': |
4c2edcd84175
graphlog: correctly handle calls in subdirectories
Patrick Mezard <patrick@mezard.eu>
parents:
16409
diff
changeset
|
1008 if default is not None: |
28271
5c454ab69558
revset: drop translation markers from error messages of internal _matchfiles
Yuya Nishihara <yuya@tcha.org>
parents:
28217
diff
changeset
|
1009 raise error.ParseError('_matchfiles expected at most one ' |
5c454ab69558
revset: drop translation markers from error messages of internal _matchfiles
Yuya Nishihara <yuya@tcha.org>
parents:
28217
diff
changeset
|
1010 'default mode') |
16411
4c2edcd84175
graphlog: correctly handle calls in subdirectories
Patrick Mezard <patrick@mezard.eu>
parents:
16409
diff
changeset
|
1011 default = value |
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
1012 else: |
28271
5c454ab69558
revset: drop translation markers from error messages of internal _matchfiles
Yuya Nishihara <yuya@tcha.org>
parents:
28217
diff
changeset
|
1013 raise error.ParseError('invalid _matchfiles prefix: %s' % prefix) |
16411
4c2edcd84175
graphlog: correctly handle calls in subdirectories
Patrick Mezard <patrick@mezard.eu>
parents:
16409
diff
changeset
|
1014 if not default: |
4c2edcd84175
graphlog: correctly handle calls in subdirectories
Patrick Mezard <patrick@mezard.eu>
parents:
16409
diff
changeset
|
1015 default = 'glob' |
20458
8dabcc889e33
revset: added lazyset implementation to _matchfiles
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20457
diff
changeset
|
1016 |
23061
f2aeff8a87b6
revset: avoid recalculating filesets
Matt Mackall <mpm@selenic.com>
parents:
23019
diff
changeset
|
1017 m = matchmod.match(repo.root, repo.getcwd(), pats, include=inc, |
f2aeff8a87b6
revset: avoid recalculating filesets
Matt Mackall <mpm@selenic.com>
parents:
23019
diff
changeset
|
1018 exclude=exc, ctx=repo[rev], default=default) |
f2aeff8a87b6
revset: avoid recalculating filesets
Matt Mackall <mpm@selenic.com>
parents:
23019
diff
changeset
|
1019 |
27028
f92053df8f0b
revset: speed up '_matchfiles'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26778
diff
changeset
|
1020 # This directly read the changelog data as creating changectx for all |
f92053df8f0b
revset: speed up '_matchfiles'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26778
diff
changeset
|
1021 # revisions is quite expensive. |
27440
ff305ab2e0d7
log: speed up hg log <file|folder>
Laurent Charignon <lcharignon@fb.com>
parents:
27293
diff
changeset
|
1022 getfiles = repo.changelog.readfiles |
27028
f92053df8f0b
revset: speed up '_matchfiles'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26778
diff
changeset
|
1023 wdirrev = node.wdirrev |
20458
8dabcc889e33
revset: added lazyset implementation to _matchfiles
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20457
diff
changeset
|
1024 def matches(x): |
27028
f92053df8f0b
revset: speed up '_matchfiles'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26778
diff
changeset
|
1025 if x == wdirrev: |
f92053df8f0b
revset: speed up '_matchfiles'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26778
diff
changeset
|
1026 files = repo[x].files() |
f92053df8f0b
revset: speed up '_matchfiles'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26778
diff
changeset
|
1027 else: |
27440
ff305ab2e0d7
log: speed up hg log <file|folder>
Laurent Charignon <lcharignon@fb.com>
parents:
27293
diff
changeset
|
1028 files = getfiles(x) |
27028
f92053df8f0b
revset: speed up '_matchfiles'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26778
diff
changeset
|
1029 for f in files: |
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
1030 if m(f): |
20458
8dabcc889e33
revset: added lazyset implementation to _matchfiles
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20457
diff
changeset
|
1031 return True |
8dabcc889e33
revset: added lazyset implementation to _matchfiles
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20457
diff
changeset
|
1032 return False |
8dabcc889e33
revset: added lazyset implementation to _matchfiles
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20457
diff
changeset
|
1033 |
28424
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
1034 return subset.filter(matches, |
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
1035 condrepr=('<matchfiles patterns=%r, include=%r ' |
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
1036 'exclude=%r, default=%r, rev=%r>', |
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
1037 pats, inc, exc, default, rev)) |
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
1038 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1039 @predicate('file(pattern)', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1040 def hasfile(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1041 """Changesets affecting files matched by pattern. |
17244
483aa765f6c4
revset: add explanation about difference between 'filelog()' and 'file()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17186
diff
changeset
|
1042 |
17265
c30307eeec4b
revset: polish explanation of the difference between file() and filelog()
Greg Ward <greg@gerg.ca>
parents:
17259
diff
changeset
|
1043 For a faster but less accurate result, consider using ``filelog()`` |
c30307eeec4b
revset: polish explanation of the difference between file() and filelog()
Greg Ward <greg@gerg.ca>
parents:
17259
diff
changeset
|
1044 instead. |
20289
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
1045 |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
1046 This predicate uses ``glob:`` as the default kind of pattern. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1047 """ |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1048 # i18n: "file" is a keyword |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1049 pat = getstring(x, _("file requires a pattern")) |
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
1050 return _matchfiles(repo, subset, ('string', 'p:' + pat)) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1051 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1052 @predicate('head()', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1053 def head(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1054 """Changeset is a named branch head. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1055 """ |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1056 # i18n: "head" is a keyword |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1057 getargs(x, 0, 0, _("head takes no arguments")) |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1058 hs = set() |
25620
5f87f2305ad0
revset: translate node directly with changelog in 'head'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25619
diff
changeset
|
1059 cl = repo.changelog |
29407
20fabe814f89
revsets: use itervalues() where only values are needed
Martin von Zweigbergk <martinvonz@google.com>
parents:
29406
diff
changeset
|
1060 for ls in repo.branchmap().itervalues(): |
25620
5f87f2305ad0
revset: translate node directly with changelog in 'head'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25619
diff
changeset
|
1061 hs.update(cl.rev(h) for h in ls) |
29408
785cadec2091
revset: make head() honor order of subset
Martin von Zweigbergk <martinvonz@google.com>
parents:
29407
diff
changeset
|
1062 return subset & baseset(hs) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1063 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1064 @predicate('heads(set)', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1065 def heads(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1066 """Members of set with no children in set. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1067 """ |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1068 s = getset(repo, subset, x) |
20366
5ec6321f49a9
revset: added substraction to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20365
diff
changeset
|
1069 ps = parents(repo, subset, x) |
5ec6321f49a9
revset: added substraction to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20365
diff
changeset
|
1070 return s - ps |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1071 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1072 @predicate('hidden()', safe=True) |
17390
74b44f25b4b1
revset: add hidden() revset
Patrick Mezard <patrick@mezard.eu>
parents:
17291
diff
changeset
|
1073 def hidden(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1074 """Hidden changesets. |
17390
74b44f25b4b1
revset: add hidden() revset
Patrick Mezard <patrick@mezard.eu>
parents:
17291
diff
changeset
|
1075 """ |
74b44f25b4b1
revset: add hidden() revset
Patrick Mezard <patrick@mezard.eu>
parents:
17291
diff
changeset
|
1076 # i18n: "hidden" is a keyword |
74b44f25b4b1
revset: add hidden() revset
Patrick Mezard <patrick@mezard.eu>
parents:
17291
diff
changeset
|
1077 getargs(x, 0, 0, _("hidden takes no arguments")) |
18382
f3b21beb9802
filtering: rename filters to their antonyms
Kevin Bullock <kbullock@ringworld.org>
parents:
18251
diff
changeset
|
1078 hiddenrevs = repoview.filterrevs(repo, 'visible') |
20367
2ac278aab2b4
revset: added intersection to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20366
diff
changeset
|
1079 return subset & hiddenrevs |
17390
74b44f25b4b1
revset: add hidden() revset
Patrick Mezard <patrick@mezard.eu>
parents:
17291
diff
changeset
|
1080 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1081 @predicate('keyword(string)', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1082 def keyword(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1083 """Search commit message, user name, and names of changed files for |
14357 | 1084 string. The match is case-insensitive. |
30772
b1012cb1bec3
revset: point to 'grep' in the 'keyword' help for regex searches
Matt Harbison <matt_harbison@yahoo.com>
parents:
30754
diff
changeset
|
1085 |
b1012cb1bec3
revset: point to 'grep' in the 'keyword' help for regex searches
Matt Harbison <matt_harbison@yahoo.com>
parents:
30754
diff
changeset
|
1086 For a regular expression or case sensitive search of these fields, use |
b1012cb1bec3
revset: point to 'grep' in the 'keyword' help for regex searches
Matt Harbison <matt_harbison@yahoo.com>
parents:
30754
diff
changeset
|
1087 ``grep(regex)``. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1088 """ |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1089 # i18n: "keyword" is a keyword |
15726
9b822edecb4c
i18n: use "encoding.lower()" to normalize specified string for revset
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15596
diff
changeset
|
1090 kw = encoding.lower(getstring(x, _("keyword requires a string"))) |
20447
abb91b74f758
revset: added lazyset implementation to keyword revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20446
diff
changeset
|
1091 |
abb91b74f758
revset: added lazyset implementation to keyword revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20446
diff
changeset
|
1092 def matches(r): |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1093 c = repo[r] |
25551
c1d163ce7394
revset: gratuitous formating fix in keyword
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25550
diff
changeset
|
1094 return any(kw in encoding.lower(t) |
c1d163ce7394
revset: gratuitous formating fix in keyword
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25550
diff
changeset
|
1095 for t in c.files() + [c.user(), c.description()]) |
20447
abb91b74f758
revset: added lazyset implementation to keyword revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20446
diff
changeset
|
1096 |
28424
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
1097 return subset.filter(matches, condrepr=('<keyword %r>', kw)) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1098 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1099 @predicate('limit(set[, n[, offset]])', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1100 def limit(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1101 """First n members of set, defaulting to 1, starting from offset. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1102 """ |
26638
7afaf2566e25
revset: add optional offset argument to limit() predicate
Yuya Nishihara <yuya@tcha.org>
parents:
26637
diff
changeset
|
1103 args = getargsdict(x, 'limit', 'set n offset') |
26637
179764469754
revset: port limit() to support keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents:
26636
diff
changeset
|
1104 if 'set' not in args: |
179764469754
revset: port limit() to support keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents:
26636
diff
changeset
|
1105 # i18n: "limit" is a keyword |
26638
7afaf2566e25
revset: add optional offset argument to limit() predicate
Yuya Nishihara <yuya@tcha.org>
parents:
26637
diff
changeset
|
1106 raise error.ParseError(_("limit requires one to three arguments")) |
30802
5eb3e4568c94
revset: add default value to getinteger() helper
Yuya Nishihara <yuya@tcha.org>
parents:
30801
diff
changeset
|
1107 # i18n: "limit" is a keyword |
5eb3e4568c94
revset: add default value to getinteger() helper
Yuya Nishihara <yuya@tcha.org>
parents:
30801
diff
changeset
|
1108 lim = getinteger(args.get('n'), _("limit expects a number"), default=1) |
5eb3e4568c94
revset: add default value to getinteger() helper
Yuya Nishihara <yuya@tcha.org>
parents:
30801
diff
changeset
|
1109 # i18n: "limit" is a keyword |
5eb3e4568c94
revset: add default value to getinteger() helper
Yuya Nishihara <yuya@tcha.org>
parents:
30801
diff
changeset
|
1110 ofs = getinteger(args.get('offset'), _("limit expects a number"), default=0) |
30801
67ee7874e53b
revset: factor out getinteger() helper
Yuya Nishihara <yuya@tcha.org>
parents:
30800
diff
changeset
|
1111 if ofs < 0: |
67ee7874e53b
revset: factor out getinteger() helper
Yuya Nishihara <yuya@tcha.org>
parents:
30800
diff
changeset
|
1112 raise error.ParseError(_("negative offset")) |
26637
179764469754
revset: port limit() to support keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents:
26636
diff
changeset
|
1113 os = getset(repo, fullreposet(repo), args['set']) |
22804
5385314e0b14
revset-limit: remove user of baseset.append
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22802
diff
changeset
|
1114 result = [] |
20446
d258486604f4
revset: changed limit revset implementation to work with lazy revsets
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20445
diff
changeset
|
1115 it = iter(os) |
26638
7afaf2566e25
revset: add optional offset argument to limit() predicate
Yuya Nishihara <yuya@tcha.org>
parents:
26637
diff
changeset
|
1116 for x in xrange(ofs): |
7afaf2566e25
revset: add optional offset argument to limit() predicate
Yuya Nishihara <yuya@tcha.org>
parents:
26637
diff
changeset
|
1117 y = next(it, None) |
7afaf2566e25
revset: add optional offset argument to limit() predicate
Yuya Nishihara <yuya@tcha.org>
parents:
26637
diff
changeset
|
1118 if y is None: |
7afaf2566e25
revset: add optional offset argument to limit() predicate
Yuya Nishihara <yuya@tcha.org>
parents:
26637
diff
changeset
|
1119 break |
20446
d258486604f4
revset: changed limit revset implementation to work with lazy revsets
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20445
diff
changeset
|
1120 for x in xrange(lim): |
25144
81a395447b34
revset: use 'next()' to detect end of iteration in 'limit'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25143
diff
changeset
|
1121 y = next(it, None) |
81a395447b34
revset: use 'next()' to detect end of iteration in 'limit'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25143
diff
changeset
|
1122 if y is None: |
20446
d258486604f4
revset: changed limit revset implementation to work with lazy revsets
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20445
diff
changeset
|
1123 break |
26636
ff6baf32b3ba
revset: eliminate temporary reference to subset in limit() and last()
Yuya Nishihara <yuya@tcha.org>
parents:
26587
diff
changeset
|
1124 elif y in subset: |
25144
81a395447b34
revset: use 'next()' to detect end of iteration in 'limit'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25143
diff
changeset
|
1125 result.append(y) |
28426
3d39ac06af9a
revset: add inspection data to limit() and last() functions
Yuya Nishihara <yuya@tcha.org>
parents:
28425
diff
changeset
|
1126 return baseset(result, datarepr=('<limit n=%d, offset=%d, %r, %r>', |
3d39ac06af9a
revset: add inspection data to limit() and last() functions
Yuya Nishihara <yuya@tcha.org>
parents:
28425
diff
changeset
|
1127 lim, ofs, subset, os)) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1128 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1129 @predicate('last(set, [n])', safe=True) |
14061
611d2f8a4ba2
revsets: add a last function
Matt Mackall <mpm@selenic.com>
parents:
14057
diff
changeset
|
1130 def last(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1131 """Last n members of set, defaulting to 1. |
14061
611d2f8a4ba2
revsets: add a last function
Matt Mackall <mpm@selenic.com>
parents:
14057
diff
changeset
|
1132 """ |
611d2f8a4ba2
revsets: add a last function
Matt Mackall <mpm@selenic.com>
parents:
14057
diff
changeset
|
1133 # i18n: "last" is a keyword |
15116
d8501bcbb221
revset: add default of 1 to limit and last functions
Matt Mackall <mpm@selenic.com>
parents:
14901
diff
changeset
|
1134 l = getargs(x, 1, 2, _("last requires one or two arguments")) |
30801
67ee7874e53b
revset: factor out getinteger() helper
Yuya Nishihara <yuya@tcha.org>
parents:
30800
diff
changeset
|
1135 lim = 1 |
67ee7874e53b
revset: factor out getinteger() helper
Yuya Nishihara <yuya@tcha.org>
parents:
30800
diff
changeset
|
1136 if len(l) == 2: |
14061
611d2f8a4ba2
revsets: add a last function
Matt Mackall <mpm@selenic.com>
parents:
14057
diff
changeset
|
1137 # i18n: "last" is a keyword |
30801
67ee7874e53b
revset: factor out getinteger() helper
Yuya Nishihara <yuya@tcha.org>
parents:
30800
diff
changeset
|
1138 lim = getinteger(l[1], _("last expects a number")) |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
1139 os = getset(repo, fullreposet(repo), l[0]) |
20534
4849f574aa24
revset: changed last implementation to use lazy classes
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20527
diff
changeset
|
1140 os.reverse() |
22805
e74245b79901
revset-last: remove user of baseset.append
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22804
diff
changeset
|
1141 result = [] |
20534
4849f574aa24
revset: changed last implementation to use lazy classes
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20527
diff
changeset
|
1142 it = iter(os) |
4849f574aa24
revset: changed last implementation to use lazy classes
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20527
diff
changeset
|
1143 for x in xrange(lim): |
25145
3553163bb736
revset: use 'next()' to detect end of iteration in 'last'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25144
diff
changeset
|
1144 y = next(it, None) |
3553163bb736
revset: use 'next()' to detect end of iteration in 'last'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25144
diff
changeset
|
1145 if y is None: |
20534
4849f574aa24
revset: changed last implementation to use lazy classes
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20527
diff
changeset
|
1146 break |
26636
ff6baf32b3ba
revset: eliminate temporary reference to subset in limit() and last()
Yuya Nishihara <yuya@tcha.org>
parents:
26587
diff
changeset
|
1147 elif y in subset: |
25145
3553163bb736
revset: use 'next()' to detect end of iteration in 'last'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25144
diff
changeset
|
1148 result.append(y) |
28426
3d39ac06af9a
revset: add inspection data to limit() and last() functions
Yuya Nishihara <yuya@tcha.org>
parents:
28425
diff
changeset
|
1149 return baseset(result, datarepr=('<last n=%d, %r, %r>', lim, subset, os)) |
14061
611d2f8a4ba2
revsets: add a last function
Matt Mackall <mpm@selenic.com>
parents:
14057
diff
changeset
|
1150 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1151 @predicate('max(set)', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1152 def maxrev(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1153 """Changeset with highest revision number in set. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1154 """ |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
1155 os = getset(repo, fullreposet(repo), x) |
26305
ade5c488d622
revset: remove existence check from min() and max()
Durham Goode <durham@fb.com>
parents:
26304
diff
changeset
|
1156 try: |
20754
f15ff553b762
revset: changed minrev and maxrev implementations to use ordered sets
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20753
diff
changeset
|
1157 m = os.max() |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1158 if m in subset: |
28427
969a4615c4c4
revset: add inspection data to max() and min() functions
Yuya Nishihara <yuya@tcha.org>
parents:
28426
diff
changeset
|
1159 return baseset([m], datarepr=('<max %r, %r>', subset, os)) |
26305
ade5c488d622
revset: remove existence check from min() and max()
Durham Goode <durham@fb.com>
parents:
26304
diff
changeset
|
1160 except ValueError: |
ade5c488d622
revset: remove existence check from min() and max()
Durham Goode <durham@fb.com>
parents:
26304
diff
changeset
|
1161 # os.max() throws a ValueError when the collection is empty. |
ade5c488d622
revset: remove existence check from min() and max()
Durham Goode <durham@fb.com>
parents:
26304
diff
changeset
|
1162 # Same as python's max(). |
ade5c488d622
revset: remove existence check from min() and max()
Durham Goode <durham@fb.com>
parents:
26304
diff
changeset
|
1163 pass |
28427
969a4615c4c4
revset: add inspection data to max() and min() functions
Yuya Nishihara <yuya@tcha.org>
parents:
28426
diff
changeset
|
1164 return baseset(datarepr=('<max %r, %r>', subset, os)) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1165 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1166 @predicate('merge()', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1167 def merge(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1168 """Changeset is a merge changeset. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1169 """ |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1170 # i18n: "merge" is a keyword |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1171 getargs(x, 0, 0, _("merge takes no arguments")) |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1172 cl = repo.changelog |
28424
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
1173 return subset.filter(lambda r: cl.parentrevs(r)[1] != -1, |
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
1174 condrepr='<merge>') |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1175 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1176 @predicate('branchpoint()', safe=True) |
17753
69d5078d760d
revsets: add branchpoint() function
Ivan Andrus <darthandrus@gmail.com>
parents:
17675
diff
changeset
|
1177 def branchpoint(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1178 """Changesets with more than one child. |
17753
69d5078d760d
revsets: add branchpoint() function
Ivan Andrus <darthandrus@gmail.com>
parents:
17675
diff
changeset
|
1179 """ |
69d5078d760d
revsets: add branchpoint() function
Ivan Andrus <darthandrus@gmail.com>
parents:
17675
diff
changeset
|
1180 # i18n: "branchpoint" is a keyword |
69d5078d760d
revsets: add branchpoint() function
Ivan Andrus <darthandrus@gmail.com>
parents:
17675
diff
changeset
|
1181 getargs(x, 0, 0, _("branchpoint takes no arguments")) |
69d5078d760d
revsets: add branchpoint() function
Ivan Andrus <darthandrus@gmail.com>
parents:
17675
diff
changeset
|
1182 cl = repo.changelog |
69d5078d760d
revsets: add branchpoint() function
Ivan Andrus <darthandrus@gmail.com>
parents:
17675
diff
changeset
|
1183 if not subset: |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
1184 return baseset() |
25549
f93ff3ab8d14
revset: mark spots that should use 'smartset.min()'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25548
diff
changeset
|
1185 # XXX this should be 'parentset.min()' assuming 'parentset' is a smartset |
f93ff3ab8d14
revset: mark spots that should use 'smartset.min()'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25548
diff
changeset
|
1186 # (and if it is not, it should.) |
17753
69d5078d760d
revsets: add branchpoint() function
Ivan Andrus <darthandrus@gmail.com>
parents:
17675
diff
changeset
|
1187 baserev = min(subset) |
69d5078d760d
revsets: add branchpoint() function
Ivan Andrus <darthandrus@gmail.com>
parents:
17675
diff
changeset
|
1188 parentscount = [0]*(len(repo) - baserev) |
17785
ac5c9c8046f7
clfilter: use changelog to iterate over the repo in branchpoint
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17753
diff
changeset
|
1189 for r in cl.revs(start=baserev + 1): |
17753
69d5078d760d
revsets: add branchpoint() function
Ivan Andrus <darthandrus@gmail.com>
parents:
17675
diff
changeset
|
1190 for p in cl.parentrevs(r): |
69d5078d760d
revsets: add branchpoint() function
Ivan Andrus <darthandrus@gmail.com>
parents:
17675
diff
changeset
|
1191 if p >= baserev: |
69d5078d760d
revsets: add branchpoint() function
Ivan Andrus <darthandrus@gmail.com>
parents:
17675
diff
changeset
|
1192 parentscount[p - baserev] += 1 |
28424
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
1193 return subset.filter(lambda r: parentscount[r - baserev] > 1, |
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
1194 condrepr='<branchpoint>') |
17753
69d5078d760d
revsets: add branchpoint() function
Ivan Andrus <darthandrus@gmail.com>
parents:
17675
diff
changeset
|
1195 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1196 @predicate('min(set)', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1197 def minrev(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1198 """Changeset with lowest revision number in set. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1199 """ |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
1200 os = getset(repo, fullreposet(repo), x) |
26305
ade5c488d622
revset: remove existence check from min() and max()
Durham Goode <durham@fb.com>
parents:
26304
diff
changeset
|
1201 try: |
20754
f15ff553b762
revset: changed minrev and maxrev implementations to use ordered sets
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20753
diff
changeset
|
1202 m = os.min() |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1203 if m in subset: |
28427
969a4615c4c4
revset: add inspection data to max() and min() functions
Yuya Nishihara <yuya@tcha.org>
parents:
28426
diff
changeset
|
1204 return baseset([m], datarepr=('<min %r, %r>', subset, os)) |
26305
ade5c488d622
revset: remove existence check from min() and max()
Durham Goode <durham@fb.com>
parents:
26304
diff
changeset
|
1205 except ValueError: |
ade5c488d622
revset: remove existence check from min() and max()
Durham Goode <durham@fb.com>
parents:
26304
diff
changeset
|
1206 # os.min() throws a ValueError when the collection is empty. |
ade5c488d622
revset: remove existence check from min() and max()
Durham Goode <durham@fb.com>
parents:
26304
diff
changeset
|
1207 # Same as python's min(). |
ade5c488d622
revset: remove existence check from min() and max()
Durham Goode <durham@fb.com>
parents:
26304
diff
changeset
|
1208 pass |
28427
969a4615c4c4
revset: add inspection data to max() and min() functions
Yuya Nishihara <yuya@tcha.org>
parents:
28426
diff
changeset
|
1209 return baseset(datarepr=('<min %r, %r>', subset, os)) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1210 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1211 @predicate('modifies(pattern)', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1212 def modifies(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1213 """Changesets modifying files matched by pattern. |
20289
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
1214 |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
1215 The pattern without explicit kind like ``glob:`` is expected to be |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
1216 relative to the current directory and match against a file or a |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
1217 directory. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1218 """ |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1219 # i18n: "modifies" is a keyword |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1220 pat = getstring(x, _("modifies requires a pattern")) |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1221 return checkstatus(repo, subset, pat, 0) |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1222 |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1223 @predicate('named(namespace)') |
23836
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1224 def named(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1225 """The changesets in a given namespace. |
23836
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1226 |
30784
5dd67f0993ce
help: eliminate duplicate text for revset string patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
30783
diff
changeset
|
1227 Pattern matching is supported for `namespace`. See |
30799
0b49449a01f4
help: use :hg: role and canonical name to point to revset string patterns
Yuya Nishihara <yuya@tcha.org>
parents:
30784
diff
changeset
|
1228 :hg:`help revisions.patterns`. |
23836
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1229 """ |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1230 # i18n: "named" is a keyword |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1231 args = getargs(x, 1, 1, _('named requires a namespace argument')) |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1232 |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1233 ns = getstring(args[0], |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1234 # i18n: "named" is a keyword |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1235 _('the argument to named must be a string')) |
26481
7d132557e44a
util: extract stringmatcher() from revset
Matt Harbison <matt_harbison@yahoo.com>
parents:
26307
diff
changeset
|
1236 kind, pattern, matcher = util.stringmatcher(ns) |
23836
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1237 namespaces = set() |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1238 if kind == 'literal': |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1239 if pattern not in repo.names: |
23978
eeb5d5ab14a6
revset: raise RepoLookupError to make present() predicate continue the query
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23956
diff
changeset
|
1240 raise error.RepoLookupError(_("namespace '%s' does not exist") |
eeb5d5ab14a6
revset: raise RepoLookupError to make present() predicate continue the query
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23956
diff
changeset
|
1241 % ns) |
23836
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1242 namespaces.add(repo.names[pattern]) |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1243 else: |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1244 for name, ns in repo.names.iteritems(): |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1245 if matcher(name): |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1246 namespaces.add(ns) |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1247 if not namespaces: |
23978
eeb5d5ab14a6
revset: raise RepoLookupError to make present() predicate continue the query
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23956
diff
changeset
|
1248 raise error.RepoLookupError(_("no namespace exists" |
eeb5d5ab14a6
revset: raise RepoLookupError to make present() predicate continue the query
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23956
diff
changeset
|
1249 " that match '%s'") % pattern) |
23836
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1250 |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1251 names = set() |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1252 for ns in namespaces: |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1253 for name in ns.listnames(repo): |
24151
38824c53c2f1
revset: mask specific names for named() predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24008
diff
changeset
|
1254 if name not in ns.deprecated: |
38824c53c2f1
revset: mask specific names for named() predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24008
diff
changeset
|
1255 names.update(repo[n].rev() for n in ns.nodes(repo, name)) |
23836
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1256 |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1257 names -= set([node.nullrev]) |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1258 return subset & names |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1259 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1260 @predicate('id(string)', safe=True) |
16417
b4b0c6931e11
revset: avoid demandimport bug
Matt Mackall <mpm@selenic.com>
parents:
16415
diff
changeset
|
1261 def node_(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1262 """Revision non-ambiguously specified by the given hex string prefix. |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
1263 """ |
12815
079a618ea89d
revset: add translator comments to i18n strings
Martin Geisler <mg@lazybytes.net>
parents:
12786
diff
changeset
|
1264 # i18n: "id" is a keyword |
12736
7e14e67e6622
revset: use 'requires' instead of 'wants' in error message
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
12733
diff
changeset
|
1265 l = getargs(x, 1, 1, _("id requires one argument")) |
12815
079a618ea89d
revset: add translator comments to i18n strings
Martin Geisler <mg@lazybytes.net>
parents:
12786
diff
changeset
|
1266 # i18n: "id" is a keyword |
12736
7e14e67e6622
revset: use 'requires' instead of 'wants' in error message
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
12733
diff
changeset
|
1267 n = getstring(l[0], _("id requires a string")) |
12716
c7e619e30ba3
revset: add id() and rev() to allow explicitly referring to changes by hash or rev
Augie Fackler <durin42@gmail.com>
parents:
12715
diff
changeset
|
1268 if len(n) == 40: |
24904
b5c227f3e461
revset: id() called with 40-byte strings should give the same results as for short strings
Alexander Drozdov <al.drozdov@gmail.com>
parents:
24777
diff
changeset
|
1269 try: |
b5c227f3e461
revset: id() called with 40-byte strings should give the same results as for short strings
Alexander Drozdov <al.drozdov@gmail.com>
parents:
24777
diff
changeset
|
1270 rn = repo.changelog.rev(node.bin(n)) |
b5c227f3e461
revset: id() called with 40-byte strings should give the same results as for short strings
Alexander Drozdov <al.drozdov@gmail.com>
parents:
24777
diff
changeset
|
1271 except (LookupError, TypeError): |
b5c227f3e461
revset: id() called with 40-byte strings should give the same results as for short strings
Alexander Drozdov <al.drozdov@gmail.com>
parents:
24777
diff
changeset
|
1272 rn = None |
12716
c7e619e30ba3
revset: add id() and rev() to allow explicitly referring to changes by hash or rev
Augie Fackler <durin42@gmail.com>
parents:
12715
diff
changeset
|
1273 else: |
16735
47b8ec0eb7fb
revset: fix traceback for bogus revisions in id(rev)
Matt Harbison <matt_harbison@yahoo.com>
parents:
16640
diff
changeset
|
1274 rn = None |
47b8ec0eb7fb
revset: fix traceback for bogus revisions in id(rev)
Matt Harbison <matt_harbison@yahoo.com>
parents:
16640
diff
changeset
|
1275 pm = repo.changelog._partialmatch(n) |
47b8ec0eb7fb
revset: fix traceback for bogus revisions in id(rev)
Matt Harbison <matt_harbison@yahoo.com>
parents:
16640
diff
changeset
|
1276 if pm is not None: |
47b8ec0eb7fb
revset: fix traceback for bogus revisions in id(rev)
Matt Harbison <matt_harbison@yahoo.com>
parents:
16640
diff
changeset
|
1277 rn = repo.changelog.rev(pm) |
47b8ec0eb7fb
revset: fix traceback for bogus revisions in id(rev)
Matt Harbison <matt_harbison@yahoo.com>
parents:
16640
diff
changeset
|
1278 |
23005
9bfe68357c01
revset-node: speedup by a few hundred fold
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23004
diff
changeset
|
1279 if rn is None: |
9bfe68357c01
revset-node: speedup by a few hundred fold
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23004
diff
changeset
|
1280 return baseset() |
9bfe68357c01
revset-node: speedup by a few hundred fold
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23004
diff
changeset
|
1281 result = baseset([rn]) |
9bfe68357c01
revset-node: speedup by a few hundred fold
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23004
diff
changeset
|
1282 return result & subset |
12716
c7e619e30ba3
revset: add id() and rev() to allow explicitly referring to changes by hash or rev
Augie Fackler <durin42@gmail.com>
parents:
12715
diff
changeset
|
1283 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1284 @predicate('obsolete()', safe=True) |
17170
63a4a3871607
revset: add an `obsolete` symbol
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17102
diff
changeset
|
1285 def obsolete(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1286 """Mutable changeset with a newer version.""" |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
1287 # i18n: "obsolete" is a keyword |
17170
63a4a3871607
revset: add an `obsolete` symbol
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17102
diff
changeset
|
1288 getargs(x, 0, 0, _("obsolete takes no arguments")) |
17825
3cc06457f15e
obsolete: rename `getobscache` into `getrevs`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17804
diff
changeset
|
1289 obsoletes = obsmod.getrevs(repo, 'obsolete') |
20367
2ac278aab2b4
revset: added intersection to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20366
diff
changeset
|
1290 return subset & obsoletes |
17170
63a4a3871607
revset: add an `obsolete` symbol
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17102
diff
changeset
|
1291 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1292 @predicate('only(set, [set])', safe=True) |
23466
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1293 def only(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1294 """Changesets that are ancestors of the first set that are not ancestors |
23466
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1295 of any other head in the repo. If a second set is specified, the result |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1296 is ancestors of the first set that are not ancestors of the second set |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1297 (i.e. ::<set1> - ::<set2>). |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1298 """ |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1299 cl = repo.changelog |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1300 # i18n: "only" is a keyword |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1301 args = getargs(x, 1, 2, _('only takes one or two arguments')) |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
1302 include = getset(repo, fullreposet(repo), args[0]) |
23466
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1303 if len(args) == 1: |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1304 if not include: |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1305 return baseset() |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1306 |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1307 descendants = set(_revdescendants(repo, include, False)) |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1308 exclude = [rev for rev in cl.headrevs() |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1309 if not rev in descendants and not rev in include] |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1310 else: |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
1311 exclude = getset(repo, fullreposet(repo), args[1]) |
23466
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1312 |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1313 results = set(cl.findmissingrevs(common=exclude, heads=include)) |
25554
94441df6206c
revset: mark spots that use 'set' instead of 'smartset'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25553
diff
changeset
|
1314 # XXX we should turn this into a baseset instead of a set, smartset may do |
30332
318a24b52eeb
spelling: fixes of non-dictionary words
Mads Kiilerich <madski@unity3d.com>
parents:
30227
diff
changeset
|
1315 # some optimizations from the fact this is a baseset. |
23466
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1316 return subset & results |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1317 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1318 @predicate('origin([set])', safe=True) |
17185
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1319 def origin(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1320 """ |
17185
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1321 Changesets that were specified as a source for the grafts, transplants or |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1322 rebases that created the given revisions. Omitting the optional set is the |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1323 same as passing all(). If a changeset created by these operations is itself |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1324 specified as a source for one of these operations, only the source changeset |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1325 for the first operation is selected. |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1326 """ |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1327 if x is not None: |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
1328 dests = getset(repo, fullreposet(repo), x) |
17185
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1329 else: |
24201
77ef059b3317
revset: drop unnecessary calls of getall() with empty argument
Yuya Nishihara <yuya@tcha.org>
parents:
24163
diff
changeset
|
1330 dests = fullreposet(repo) |
17185
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1331 |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1332 def _firstsrc(rev): |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1333 src = _getrevsource(repo, rev) |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1334 if src is None: |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1335 return None |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1336 |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1337 while True: |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1338 prev = _getrevsource(repo, src) |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1339 |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1340 if prev is None: |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1341 return src |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1342 src = prev |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1343 |
22944
5aae3dea8044
revset: better naming of variables containing the value of a single argument
Mads Kiilerich <madski@unity3d.com>
parents:
22891
diff
changeset
|
1344 o = set([_firstsrc(r) for r in dests]) |
22498
64673dc48931
revset: remove invalid value in the origin set
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22497
diff
changeset
|
1345 o -= set([None]) |
25554
94441df6206c
revset: mark spots that use 'set' instead of 'smartset'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25553
diff
changeset
|
1346 # XXX we should turn this into a baseset instead of a set, smartset may do |
30332
318a24b52eeb
spelling: fixes of non-dictionary words
Mads Kiilerich <madski@unity3d.com>
parents:
30227
diff
changeset
|
1347 # some optimizations from the fact this is a baseset. |
22536
8040a44aab1c
revset: use `subset &` in `origin`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22535
diff
changeset
|
1348 return subset & o |
17185
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1349 |
30850
41e31a6f5296
revset: prevent using outgoing() and remote() in hgweb session (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
30804
diff
changeset
|
1350 @predicate('outgoing([path])', safe=False) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1351 def outgoing(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1352 """Changesets not found in the specified destination repository, or the |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1353 default push location. |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
1354 """ |
24722
02a5618e2fbf
revset: don't import discovery at module level
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24708
diff
changeset
|
1355 # Avoid cycles. |
25971
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
1356 from . import ( |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
1357 discovery, |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
1358 hg, |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
1359 ) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1360 # i18n: "outgoing" is a keyword |
14717
c8ee2729e89f
revset and fileset: fix typos in parser error messages
Mads Kiilerich <mads@kiilerich.com>
parents:
14715
diff
changeset
|
1361 l = getargs(x, 0, 1, _("outgoing takes one or no arguments")) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1362 # i18n: "outgoing" is a keyword |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1363 dest = l and getstring(l[0], _("outgoing requires a repository path")) or '' |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1364 dest = repo.ui.expandpath(dest or 'default-push', dest or 'default') |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1365 dest, branches = hg.parseurl(dest) |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1366 revs, checkout = hg.addbranchrevs(repo, repo, branches, []) |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1367 if revs: |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1368 revs = [repo.lookup(rev) for rev in revs] |
14556
517e1d88bf7e
hg: change various repository() users to use peer() where appropriate
Matt Mackall <mpm@selenic.com>
parents:
14509
diff
changeset
|
1369 other = hg.peer(repo, {}, dest) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1370 repo.ui.pushbuffer() |
15837
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15819
diff
changeset
|
1371 outgoing = discovery.findcommonoutgoing(repo, other, onlyheads=revs) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1372 repo.ui.popbuffer() |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1373 cl = repo.changelog |
15837
cd956049fc14
discovery: introduce outgoing object for result of findcommonoutgoing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15819
diff
changeset
|
1374 o = set([cl.rev(r) for r in outgoing.missing]) |
22529
5c53d7888aef
revset: use `subset &` in `outgoing`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22528
diff
changeset
|
1375 return subset & o |
12716
c7e619e30ba3
revset: add id() and rev() to allow explicitly referring to changes by hash or rev
Augie Fackler <durin42@gmail.com>
parents:
12715
diff
changeset
|
1376 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1377 @predicate('p1([set])', safe=True) |
11275 | 1378 def p1(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1379 """First parent of changesets in set, or the working directory. |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
1380 """ |
12928
a5f7f1e9340e
revsets: let p1() and p2() return parents of working dir
Kevin Bullock <kbullock@ringworld.org>
parents:
12859
diff
changeset
|
1381 if x is None: |
13878
a8d13ee0ce68
misc: replace .parents()[0] with p1()
Matt Mackall <mpm@selenic.com>
parents:
13873
diff
changeset
|
1382 p = repo[x].p1().rev() |
22538
a428db9ab61d
revset: use `subset &` in bare `p1()`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22537
diff
changeset
|
1383 if p >= 0: |
a428db9ab61d
revset: use `subset &` in bare `p1()`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22537
diff
changeset
|
1384 return subset & baseset([p]) |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
1385 return baseset() |
12928
a5f7f1e9340e
revsets: let p1() and p2() return parents of working dir
Kevin Bullock <kbullock@ringworld.org>
parents:
12859
diff
changeset
|
1386 |
11275 | 1387 ps = set() |
1388 cl = repo.changelog | |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
1389 for r in getset(repo, fullreposet(repo), x): |
11275 | 1390 ps.add(cl.parentrevs(r)[0]) |
22495
668b26d32bf6
revset: remove nullrev from set computed in p1() and p2()
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22494
diff
changeset
|
1391 ps -= set([node.nullrev]) |
25554
94441df6206c
revset: mark spots that use 'set' instead of 'smartset'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25553
diff
changeset
|
1392 # XXX we should turn this into a baseset instead of a set, smartset may do |
30332
318a24b52eeb
spelling: fixes of non-dictionary words
Mads Kiilerich <madski@unity3d.com>
parents:
30227
diff
changeset
|
1393 # some optimizations from the fact this is a baseset. |
20367
2ac278aab2b4
revset: added intersection to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20366
diff
changeset
|
1394 return subset & ps |
11275 | 1395 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1396 @predicate('p2([set])', safe=True) |
11275 | 1397 def p2(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1398 """Second parent of changesets in set, or the working directory. |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
1399 """ |
12928
a5f7f1e9340e
revsets: let p1() and p2() return parents of working dir
Kevin Bullock <kbullock@ringworld.org>
parents:
12859
diff
changeset
|
1400 if x is None: |
a5f7f1e9340e
revsets: let p1() and p2() return parents of working dir
Kevin Bullock <kbullock@ringworld.org>
parents:
12859
diff
changeset
|
1401 ps = repo[x].parents() |
a5f7f1e9340e
revsets: let p1() and p2() return parents of working dir
Kevin Bullock <kbullock@ringworld.org>
parents:
12859
diff
changeset
|
1402 try: |
12935
98b79c892768
revset: fix p1, p2 and parents in dirstate case (a5f7f1e9340e)
Patrick Mezard <pmezard@gmail.com>
parents:
12929
diff
changeset
|
1403 p = ps[1].rev() |
22539
6f434ef54222
revset: use `subset &` in bare `p2()`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22538
diff
changeset
|
1404 if p >= 0: |
6f434ef54222
revset: use `subset &` in bare `p2()`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22538
diff
changeset
|
1405 return subset & baseset([p]) |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
1406 return baseset() |
12928
a5f7f1e9340e
revsets: let p1() and p2() return parents of working dir
Kevin Bullock <kbullock@ringworld.org>
parents:
12859
diff
changeset
|
1407 except IndexError: |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
1408 return baseset() |
12928
a5f7f1e9340e
revsets: let p1() and p2() return parents of working dir
Kevin Bullock <kbullock@ringworld.org>
parents:
12859
diff
changeset
|
1409 |
11275 | 1410 ps = set() |
1411 cl = repo.changelog | |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
1412 for r in getset(repo, fullreposet(repo), x): |
11275 | 1413 ps.add(cl.parentrevs(r)[1]) |
22495
668b26d32bf6
revset: remove nullrev from set computed in p1() and p2()
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22494
diff
changeset
|
1414 ps -= set([node.nullrev]) |
25554
94441df6206c
revset: mark spots that use 'set' instead of 'smartset'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25553
diff
changeset
|
1415 # XXX we should turn this into a baseset instead of a set, smartset may do |
30332
318a24b52eeb
spelling: fixes of non-dictionary words
Mads Kiilerich <madski@unity3d.com>
parents:
30227
diff
changeset
|
1416 # some optimizations from the fact this is a baseset. |
20367
2ac278aab2b4
revset: added intersection to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20366
diff
changeset
|
1417 return subset & ps |
11275 | 1418 |
29932
09a84e747c88
revset: pass around ordering flags to operations
Yuya Nishihara <yuya@tcha.org>
parents:
29931
diff
changeset
|
1419 def parentpost(repo, subset, x, order): |
29931
d2d1be3009ca
revset: add stub to handle parentpost operation
Yuya Nishihara <yuya@tcha.org>
parents:
29930
diff
changeset
|
1420 return p1(repo, subset, x) |
d2d1be3009ca
revset: add stub to handle parentpost operation
Yuya Nishihara <yuya@tcha.org>
parents:
29930
diff
changeset
|
1421 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1422 @predicate('parents([set])', safe=True) |
11275 | 1423 def parents(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1424 """ |
12929
515c2786e1cf
revsets: let parents() return parents of working dir
Kevin Bullock <kbullock@ringworld.org>
parents:
12928
diff
changeset
|
1425 The set of all parents for all changesets in set, or the working directory. |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
1426 """ |
12929
515c2786e1cf
revsets: let parents() return parents of working dir
Kevin Bullock <kbullock@ringworld.org>
parents:
12928
diff
changeset
|
1427 if x is None: |
22496
35af9361a049
revset: refactor parents() into a single return point
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22495
diff
changeset
|
1428 ps = set(p.rev() for p in repo[x].parents()) |
35af9361a049
revset: refactor parents() into a single return point
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22495
diff
changeset
|
1429 else: |
35af9361a049
revset: refactor parents() into a single return point
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22495
diff
changeset
|
1430 ps = set() |
35af9361a049
revset: refactor parents() into a single return point
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22495
diff
changeset
|
1431 cl = repo.changelog |
25716
d50677c3bf44
revset: prefetch method in "parents"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25706
diff
changeset
|
1432 up = ps.update |
d50677c3bf44
revset: prefetch method in "parents"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25706
diff
changeset
|
1433 parentrevs = cl.parentrevs |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
1434 for r in getset(repo, fullreposet(repo), x): |
25765
5e1b0739611c
revset: use integer representation of wdir() in revset
Yuya Nishihara <yuya@tcha.org>
parents:
25716
diff
changeset
|
1435 if r == node.wdirrev: |
25716
d50677c3bf44
revset: prefetch method in "parents"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25706
diff
changeset
|
1436 up(p.rev() for p in repo[r].parents()) |
25689
1cce81121472
revset: fix a crash in parents() when 'wdir()' is in the set
Matt Harbison <matt_harbison@yahoo.com>
parents:
25660
diff
changeset
|
1437 else: |
25716
d50677c3bf44
revset: prefetch method in "parents"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25706
diff
changeset
|
1438 up(parentrevs(r)) |
22497
8ea3f47bcaff
revset: remove nullrev from set computed in parents()
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22496
diff
changeset
|
1439 ps -= set([node.nullrev]) |
22712
093df3b77f27
revert: bring back usage of `subset & ps` in `parents`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22692
diff
changeset
|
1440 return subset & ps |
11275 | 1441 |
31017 | 1442 def _phase(repo, subset, *targets): |
1443 """helper to select all rev in <targets> phases""" | |
1444 s = repo._phasecache.getrevset(repo, targets) | |
1445 return subset & s | |
25621
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1446 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1447 @predicate('draft()', safe=True) |
25621
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1448 def draft(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1449 """Changeset in draft phase.""" |
25621
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1450 # i18n: "draft" is a keyword |
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1451 getargs(x, 0, 0, _("draft takes no arguments")) |
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1452 target = phases.draft |
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1453 return _phase(repo, subset, target) |
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1454 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1455 @predicate('secret()', safe=True) |
25621
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1456 def secret(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1457 """Changeset in secret phase.""" |
25621
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1458 # i18n: "secret" is a keyword |
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1459 getargs(x, 0, 0, _("secret takes no arguments")) |
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1460 target = phases.secret |
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1461 return _phase(repo, subset, target) |
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1462 |
29932
09a84e747c88
revset: pass around ordering flags to operations
Yuya Nishihara <yuya@tcha.org>
parents:
29931
diff
changeset
|
1463 def parentspec(repo, subset, x, n, order): |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
1464 """``set^0`` |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
1465 The set. |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
1466 ``set^1`` (or ``set^``), ``set^2`` |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
1467 First or second parent, respectively, of all changesets in set. |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
1468 """ |
12320
40c40c6f20b8
revset: handle re.compile() errors in grep()
Brodie Rao <brodie@bitheap.org>
parents:
11882
diff
changeset
|
1469 try: |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
1470 n = int(n[1]) |
14072
2e4d79dcc0a0
revset: add missing whitespace
Kevin Gessner <kevin@kevingessner.com>
parents:
14070
diff
changeset
|
1471 if n not in (0, 1, 2): |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
1472 raise ValueError |
14851
f96c354493d7
revsets: actually catch type error on tip^p1(tip) (issue2884)
Matt Mackall <mpm@selenic.com>
parents:
14842
diff
changeset
|
1473 except (TypeError, ValueError): |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
1474 raise error.ParseError(_("^ expects a number 0, 1, or 2")) |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
1475 ps = set() |
11275 | 1476 cl = repo.changelog |
23165
7e8737e6ab08
revset-parentspec: call 'getset' on a 'fullreposet'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23164
diff
changeset
|
1477 for r in getset(repo, fullreposet(repo), x): |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
1478 if n == 0: |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
1479 ps.add(r) |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
1480 elif n == 1: |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
1481 ps.add(cl.parentrevs(r)[0]) |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
1482 elif n == 2: |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
1483 parents = cl.parentrevs(r) |
30179
cdef35b38026
revset: for x^2, do not take null as a valid p2 revision
Yuya Nishihara <yuya@tcha.org>
parents:
30178
diff
changeset
|
1484 if parents[1] != node.nullrev: |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
1485 ps.add(parents[1]) |
20367
2ac278aab2b4
revset: added intersection to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20366
diff
changeset
|
1486 return subset & ps |
11275 | 1487 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1488 @predicate('present(set)', safe=True) |
11944
df52ff0980fe
revset: predicate to avoid lookup errors
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
11886
diff
changeset
|
1489 def present(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1490 """An empty set, if any revision in set isn't found; otherwise, |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
1491 all revisions in set. |
16748
0a730d3c5aae
doc: add detail explanation for 'present()' predicate of revsets
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16735
diff
changeset
|
1492 |
0a730d3c5aae
doc: add detail explanation for 'present()' predicate of revsets
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16735
diff
changeset
|
1493 If any of specified revisions is not present in the local repository, |
0a730d3c5aae
doc: add detail explanation for 'present()' predicate of revsets
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16735
diff
changeset
|
1494 the query is normally aborted. But this predicate allows the query |
0a730d3c5aae
doc: add detail explanation for 'present()' predicate of revsets
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16735
diff
changeset
|
1495 to continue even in such cases. |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
1496 """ |
11944
df52ff0980fe
revset: predicate to avoid lookup errors
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
11886
diff
changeset
|
1497 try: |
df52ff0980fe
revset: predicate to avoid lookup errors
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
11886
diff
changeset
|
1498 return getset(repo, subset, x) |
df52ff0980fe
revset: predicate to avoid lookup errors
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
11886
diff
changeset
|
1499 except error.RepoLookupError: |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
1500 return baseset() |
11944
df52ff0980fe
revset: predicate to avoid lookup errors
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
11886
diff
changeset
|
1501 |
25224
d032f57936f5
revset: drop docstring from internal _notpublic() function
Yuya Nishihara <yuya@tcha.org>
parents:
25191
diff
changeset
|
1502 # for internal use |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1503 @predicate('_notpublic', safe=True) |
25191
08d1ef09ed37
revset: optimize not public revset
Laurent Charignon <lcharignon@fb.com>
parents:
25149
diff
changeset
|
1504 def _notpublic(repo, subset, x): |
25225
57fae767c52b
revset: drop translation marker from error message of _notpublic()
Yuya Nishihara <yuya@tcha.org>
parents:
25224
diff
changeset
|
1505 getargs(x, 0, 0, "_notpublic takes no arguments") |
31017 | 1506 return _phase(repo, subset, phases.draft, phases.secret) |
25191
08d1ef09ed37
revset: optimize not public revset
Laurent Charignon <lcharignon@fb.com>
parents:
25149
diff
changeset
|
1507 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1508 @predicate('public()', safe=True) |
15819
33ca11b010e2
phases: implements simple revset symbol
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15791
diff
changeset
|
1509 def public(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1510 """Changeset in public phase.""" |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
1511 # i18n: "public" is a keyword |
15819
33ca11b010e2
phases: implements simple revset symbol
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15791
diff
changeset
|
1512 getargs(x, 0, 0, _("public takes no arguments")) |
23019
c8f32accd00a
revset-phases: prefetch attributes in phasesrelated revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23018
diff
changeset
|
1513 phase = repo._phasecache.phase |
c8f32accd00a
revset-phases: prefetch attributes in phasesrelated revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23018
diff
changeset
|
1514 target = phases.public |
c8f32accd00a
revset-phases: prefetch attributes in phasesrelated revsets
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23018
diff
changeset
|
1515 condition = lambda r: phase(repo, r) == target |
28424
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
1516 return subset.filter(condition, condrepr=('<phase %r>', target), |
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
1517 cache=False) |
15819
33ca11b010e2
phases: implements simple revset symbol
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15791
diff
changeset
|
1518 |
30850
41e31a6f5296
revset: prevent using outgoing() and remote() in hgweb session (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
30804
diff
changeset
|
1519 @predicate('remote([id [,path]])', safe=False) |
15936
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1520 def remote(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1521 """Local revision that corresponds to the given identifier in a |
15936
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1522 remote repository, if present. Here, the '.' identifier is a |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1523 synonym for the current local branch. |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1524 """ |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1525 |
25971
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
1526 from . import hg # avoid start-up nasties |
15936
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1527 # i18n: "remote" is a keyword |
27293
9e06e7fb037d
grammar: favor zero, one, two over ... or no
timeless <timeless@mozdev.org>
parents:
27028
diff
changeset
|
1528 l = getargs(x, 0, 2, _("remote takes zero, one, or two arguments")) |
15936
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1529 |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1530 q = '.' |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1531 if len(l) > 0: |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1532 # i18n: "remote" is a keyword |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1533 q = getstring(l[0], _("remote requires a string id")) |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1534 if q == '.': |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1535 q = repo['.'].branch() |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1536 |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1537 dest = '' |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1538 if len(l) > 1: |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1539 # i18n: "remote" is a keyword |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1540 dest = getstring(l[1], _("remote requires a repository path")) |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1541 dest = repo.ui.expandpath(dest or 'default') |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1542 dest, branches = hg.parseurl(dest) |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1543 revs, checkout = hg.addbranchrevs(repo, repo, branches, []) |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1544 if revs: |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1545 revs = [repo.lookup(rev) for rev in revs] |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1546 other = hg.peer(repo, {}, dest) |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1547 n = other.lookup(q) |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1548 if n in repo: |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1549 r = repo[n].rev() |
16006
39e60576ac98
revset: fix 'remote()' failure when remote repo has more revs than local
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15966
diff
changeset
|
1550 if r in subset: |
20364
a6cf48b2880d
revset: added baseset class (still empty) to improve revset performance
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20289
diff
changeset
|
1551 return baseset([r]) |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
1552 return baseset() |
15936
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
1553 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1554 @predicate('removes(pattern)', safe=True) |
11275 | 1555 def removes(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1556 """Changesets which remove files matching pattern. |
20289
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
1557 |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
1558 The pattern without explicit kind like ``glob:`` is expected to be |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
1559 relative to the current directory and match against a file or a |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
1560 directory. |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
1561 """ |
12815
079a618ea89d
revset: add translator comments to i18n strings
Martin Geisler <mg@lazybytes.net>
parents:
12786
diff
changeset
|
1562 # i18n: "removes" is a keyword |
12736
7e14e67e6622
revset: use 'requires' instead of 'wants' in error message
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
12733
diff
changeset
|
1563 pat = getstring(x, _("removes requires a pattern")) |
11275 | 1564 return checkstatus(repo, subset, pat, 2) |
1565 | |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1566 @predicate('rev(number)', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1567 def rev(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1568 """Revision with the given numeric identifier. |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
1569 """ |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1570 # i18n: "rev" is a keyword |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1571 l = getargs(x, 1, 1, _("rev requires one argument")) |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1572 try: |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1573 # i18n: "rev" is a keyword |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1574 l = int(getstring(l[0], _("rev requires a number"))) |
14851
f96c354493d7
revsets: actually catch type error on tip^p1(tip) (issue2884)
Matt Mackall <mpm@selenic.com>
parents:
14842
diff
changeset
|
1575 except (TypeError, ValueError): |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1576 # i18n: "rev" is a keyword |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1577 raise error.ParseError(_("rev expects a number")) |
24031
fe1abb5d92f6
revset: have rev() validate input by repo.changelog.__contains__()
Yuya Nishihara <yuya@tcha.org>
parents:
24012
diff
changeset
|
1578 if l not in repo.changelog and l != node.nullrev: |
23062
ba89f7b542c9
revset: have rev() drop out-of-range or filtered rev explicitly (issue4396)
Yuya Nishihara <yuya@tcha.org>
parents:
23061
diff
changeset
|
1579 return baseset() |
22537
bbf4f3dfd700
revset: use `subset &` in `rev`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22536
diff
changeset
|
1580 return subset & baseset([l]) |
11275 | 1581 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1582 @predicate('matching(revision [, field])', safe=True) |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1583 def matching(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1584 """Changesets in which a given set of fields match the set of fields in the |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1585 selected revision or set. |
16528
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
1586 |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1587 To match more than one field pass the list of fields to match separated |
16528
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
1588 by spaces (e.g. ``author description``). |
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
1589 |
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
1590 Valid fields are most regular revision fields and some special fields. |
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
1591 |
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
1592 Regular revision fields are ``description``, ``author``, ``branch``, |
17102
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
1593 ``date``, ``files``, ``phase``, ``parents``, ``substate``, ``user`` |
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
1594 and ``diff``. |
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
1595 Note that ``author`` and ``user`` are synonyms. ``diff`` refers to the |
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
1596 contents of the revision. Two revisions matching their ``diff`` will |
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
1597 also match their ``files``. |
16528
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
1598 |
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
1599 Special fields are ``summary`` and ``metadata``: |
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
1600 ``summary`` matches the first line of the description. |
16639
00290bd359fe
revset: documentation typo "metatadata"
Jesse Glick <jesse.glick@oracle.com>
parents:
16528
diff
changeset
|
1601 ``metadata`` is equivalent to matching ``description user date`` |
16528
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
1602 (i.e. it matches the main metadata fields). |
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
1603 |
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
1604 ``metadata`` is the default field which is used when no fields are |
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
1605 specified. You can match more than one field at a time. |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1606 """ |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
1607 # i18n: "matching" is a keyword |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1608 l = getargs(x, 1, 2, _("matching takes 1 or 2 arguments")) |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1609 |
23166
30e0dcd7c5ff
revset-matching: call 'getset' on a 'fullreposet'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23165
diff
changeset
|
1610 revs = getset(repo, fullreposet(repo), l[0]) |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1611 |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1612 fieldlist = ['metadata'] |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1613 if len(l) > 1: |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1614 fieldlist = getstring(l[1], |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
1615 # i18n: "matching" is a keyword |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1616 _("matching requires a string " |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1617 "as its second argument")).split() |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1618 |
17102
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
1619 # Make sure that there are no repeated fields, |
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
1620 # expand the 'special' 'metadata' field type |
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
1621 # and check the 'files' whenever we check the 'diff' |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1622 fields = [] |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1623 for field in fieldlist: |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1624 if field == 'metadata': |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1625 fields += ['user', 'description', 'date'] |
17102
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
1626 elif field == 'diff': |
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
1627 # a revision matching the diff must also match the files |
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
1628 # since matching the diff is very costly, make sure to |
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
1629 # also match the files first |
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
1630 fields += ['files', 'diff'] |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1631 else: |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1632 if field == 'author': |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1633 field = 'user' |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1634 fields.append(field) |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1635 fields = set(fields) |
16444
432f198600c6
revset: make matching keyword not match summary when matching for description
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16417
diff
changeset
|
1636 if 'summary' in fields and 'description' in fields: |
432f198600c6
revset: make matching keyword not match summary when matching for description
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16417
diff
changeset
|
1637 # If a revision matches its description it also matches its summary |
432f198600c6
revset: make matching keyword not match summary when matching for description
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16417
diff
changeset
|
1638 fields.discard('summary') |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1639 |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1640 # We may want to match more than one field |
16446
984e0412e82b
revset: speedup matching() by first matching fields that take less time to
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16445
diff
changeset
|
1641 # Not all fields take the same amount of time to be matched |
984e0412e82b
revset: speedup matching() by first matching fields that take less time to
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16445
diff
changeset
|
1642 # Sort the selected fields in order of increasing matching cost |
16453
d2a865d4b963
revset: make matching() work on python 2.4
Patrick Mezard <patrick@mezard.eu>
parents:
16452
diff
changeset
|
1643 fieldorder = ['phase', 'parents', 'user', 'date', 'branch', 'summary', |
17102
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
1644 'files', 'description', 'substate', 'diff'] |
16446
984e0412e82b
revset: speedup matching() by first matching fields that take less time to
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16445
diff
changeset
|
1645 def fieldkeyfunc(f): |
984e0412e82b
revset: speedup matching() by first matching fields that take less time to
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16445
diff
changeset
|
1646 try: |
984e0412e82b
revset: speedup matching() by first matching fields that take less time to
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16445
diff
changeset
|
1647 return fieldorder.index(f) |
984e0412e82b
revset: speedup matching() by first matching fields that take less time to
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16445
diff
changeset
|
1648 except ValueError: |
984e0412e82b
revset: speedup matching() by first matching fields that take less time to
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16445
diff
changeset
|
1649 # assume an unknown field is very costly |
984e0412e82b
revset: speedup matching() by first matching fields that take less time to
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16445
diff
changeset
|
1650 return len(fieldorder) |
984e0412e82b
revset: speedup matching() by first matching fields that take less time to
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16445
diff
changeset
|
1651 fields = list(fields) |
984e0412e82b
revset: speedup matching() by first matching fields that take less time to
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16445
diff
changeset
|
1652 fields.sort(key=fieldkeyfunc) |
984e0412e82b
revset: speedup matching() by first matching fields that take less time to
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16445
diff
changeset
|
1653 |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1654 # Each field will be matched with its own "getfield" function |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1655 # which will be added to the getfieldfuncs array of functions |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1656 getfieldfuncs = [] |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1657 _funcs = { |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1658 'user': lambda r: repo[r].user(), |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1659 'branch': lambda r: repo[r].branch(), |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1660 'date': lambda r: repo[r].date(), |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1661 'description': lambda r: repo[r].description(), |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1662 'files': lambda r: repo[r].files(), |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1663 'parents': lambda r: repo[r].parents(), |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1664 'phase': lambda r: repo[r].phase(), |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1665 'substate': lambda r: repo[r].substate, |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1666 'summary': lambda r: repo[r].description().splitlines()[0], |
17102
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
1667 'diff': lambda r: list(repo[r].diff(git=True),) |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1668 } |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1669 for info in fields: |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1670 getfield = _funcs.get(info, None) |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1671 if getfield is None: |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1672 raise error.ParseError( |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
1673 # i18n: "matching" is a keyword |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1674 _("unexpected field name passed to matching: %s") % info) |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1675 getfieldfuncs.append(getfield) |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1676 # convert the getfield array of functions into a "getinfo" function |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1677 # which returns an array of field values (or a single value if there |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1678 # is only one field to match) |
16445
453c8670566c
revset: speedup matching() by stopping the match early if a field does not match
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16444
diff
changeset
|
1679 getinfo = lambda r: [f(r) for f in getfieldfuncs] |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1680 |
20459
51890507c6b3
revset: added lazyset implementation to matching revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20458
diff
changeset
|
1681 def matches(x): |
51890507c6b3
revset: added lazyset implementation to matching revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20458
diff
changeset
|
1682 for rev in revs: |
51890507c6b3
revset: added lazyset implementation to matching revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20458
diff
changeset
|
1683 target = getinfo(rev) |
16445
453c8670566c
revset: speedup matching() by stopping the match early if a field does not match
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16444
diff
changeset
|
1684 match = True |
453c8670566c
revset: speedup matching() by stopping the match early if a field does not match
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16444
diff
changeset
|
1685 for n, f in enumerate(getfieldfuncs): |
20459
51890507c6b3
revset: added lazyset implementation to matching revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20458
diff
changeset
|
1686 if target[n] != f(x): |
16445
453c8670566c
revset: speedup matching() by stopping the match early if a field does not match
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16444
diff
changeset
|
1687 match = False |
453c8670566c
revset: speedup matching() by stopping the match early if a field does not match
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16444
diff
changeset
|
1688 if match: |
20459
51890507c6b3
revset: added lazyset implementation to matching revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20458
diff
changeset
|
1689 return True |
51890507c6b3
revset: added lazyset implementation to matching revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20458
diff
changeset
|
1690 return False |
51890507c6b3
revset: added lazyset implementation to matching revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20458
diff
changeset
|
1691 |
28424
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
1692 return subset.filter(matches, condrepr=('<matching%r %r>', fields, revs)) |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
1693 |
29945
89dbae952ec1
revset: make reverse() noop depending on ordering requirement (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29944
diff
changeset
|
1694 @predicate('reverse(set)', safe=True, takeorder=True) |
89dbae952ec1
revset: make reverse() noop depending on ordering requirement (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29944
diff
changeset
|
1695 def reverse(repo, subset, x, order): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1696 """Reverse order of set. |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
1697 """ |
11275 | 1698 l = getset(repo, subset, x) |
29945
89dbae952ec1
revset: make reverse() noop depending on ordering requirement (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29944
diff
changeset
|
1699 if order == defineorder: |
89dbae952ec1
revset: make reverse() noop depending on ordering requirement (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29944
diff
changeset
|
1700 l.reverse() |
11275 | 1701 return l |
1702 | |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
1703 @predicate('roots(set)', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1704 def roots(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1705 """Changesets in set with no parent changeset in set. |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
1706 """ |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
1707 s = getset(repo, fullreposet(repo), x) |
25647
46a96dd4d976
revset: improves time complexity of 'roots(xxx)'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25634
diff
changeset
|
1708 parents = repo.changelog.parentrevs |
46a96dd4d976
revset: improves time complexity of 'roots(xxx)'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25634
diff
changeset
|
1709 def filter(r): |
46a96dd4d976
revset: improves time complexity of 'roots(xxx)'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25634
diff
changeset
|
1710 for p in parents(r): |
46a96dd4d976
revset: improves time complexity of 'roots(xxx)'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25634
diff
changeset
|
1711 if 0 <= p and p in s: |
46a96dd4d976
revset: improves time complexity of 'roots(xxx)'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25634
diff
changeset
|
1712 return False |
46a96dd4d976
revset: improves time complexity of 'roots(xxx)'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25634
diff
changeset
|
1713 return True |
28424
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
1714 return subset & s.filter(filter, condrepr='<roots>') |
11944
df52ff0980fe
revset: predicate to avoid lookup errors
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
11886
diff
changeset
|
1715 |
29265
3f9e68864ccc
revset: define table of sort() key functions
Yuya Nishihara <yuya@tcha.org>
parents:
29264
diff
changeset
|
1716 _sortkeyfuncs = { |
3f9e68864ccc
revset: define table of sort() key functions
Yuya Nishihara <yuya@tcha.org>
parents:
29264
diff
changeset
|
1717 'rev': lambda c: c.rev(), |
3f9e68864ccc
revset: define table of sort() key functions
Yuya Nishihara <yuya@tcha.org>
parents:
29264
diff
changeset
|
1718 'branch': lambda c: c.branch(), |
3f9e68864ccc
revset: define table of sort() key functions
Yuya Nishihara <yuya@tcha.org>
parents:
29264
diff
changeset
|
1719 'desc': lambda c: c.description(), |
3f9e68864ccc
revset: define table of sort() key functions
Yuya Nishihara <yuya@tcha.org>
parents:
29264
diff
changeset
|
1720 'user': lambda c: c.user(), |
3f9e68864ccc
revset: define table of sort() key functions
Yuya Nishihara <yuya@tcha.org>
parents:
29264
diff
changeset
|
1721 'author': lambda c: c.user(), |
3f9e68864ccc
revset: define table of sort() key functions
Yuya Nishihara <yuya@tcha.org>
parents:
29264
diff
changeset
|
1722 'date': lambda c: c.date()[0], |
3f9e68864ccc
revset: define table of sort() key functions
Yuya Nishihara <yuya@tcha.org>
parents:
29264
diff
changeset
|
1723 } |
3f9e68864ccc
revset: define table of sort() key functions
Yuya Nishihara <yuya@tcha.org>
parents:
29264
diff
changeset
|
1724 |
29365
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
1725 def _getsortargs(x): |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
1726 """Parse sort options into (set, [(key, reverse)], opts)""" |
29348
2188f170f5b6
revset: add new topographical sort
Martijn Pieters <mjpieters@fb.com>
parents:
29347
diff
changeset
|
1727 args = getargsdict(x, 'sort', 'set keys topo.firstbranch') |
29238
e150c1d5f262
revset: use getargsdict for sort()
Martijn Pieters <mjpieters@fb.com>
parents:
29216
diff
changeset
|
1728 if 'set' not in args: |
e150c1d5f262
revset: use getargsdict for sort()
Martijn Pieters <mjpieters@fb.com>
parents:
29216
diff
changeset
|
1729 # i18n: "sort" is a keyword |
e150c1d5f262
revset: use getargsdict for sort()
Martijn Pieters <mjpieters@fb.com>
parents:
29216
diff
changeset
|
1730 raise error.ParseError(_('sort requires one or two arguments')) |
11275 | 1731 keys = "rev" |
29238
e150c1d5f262
revset: use getargsdict for sort()
Martijn Pieters <mjpieters@fb.com>
parents:
29216
diff
changeset
|
1732 if 'keys' in args: |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
1733 # i18n: "sort" is a keyword |
29238
e150c1d5f262
revset: use getargsdict for sort()
Martijn Pieters <mjpieters@fb.com>
parents:
29216
diff
changeset
|
1734 keys = getstring(args['keys'], _("sort spec must be a string")) |
e150c1d5f262
revset: use getargsdict for sort()
Martijn Pieters <mjpieters@fb.com>
parents:
29216
diff
changeset
|
1735 |
29363
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
1736 keyflags = [] |
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
1737 for k in keys.split(): |
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
1738 fk = k |
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
1739 reverse = (k[0] == '-') |
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
1740 if reverse: |
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
1741 k = k[1:] |
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
1742 if k not in _sortkeyfuncs and k != 'topo': |
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
1743 raise error.ParseError(_("unknown sort key %r") % fk) |
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
1744 keyflags.append((k, reverse)) |
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
1745 |
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
1746 if len(keyflags) > 1 and any(k == 'topo' for k, reverse in keyflags): |
29348
2188f170f5b6
revset: add new topographical sort
Martijn Pieters <mjpieters@fb.com>
parents:
29347
diff
changeset
|
1747 # i18n: "topo" is a keyword |
29646
a8a5dd8986f0
revset: refactor to make xgettext put i18n comments into hg.pot file
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29441
diff
changeset
|
1748 raise error.ParseError(_('topo sort order cannot be combined ' |
a8a5dd8986f0
revset: refactor to make xgettext put i18n comments into hg.pot file
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29441
diff
changeset
|
1749 'with other sort keys')) |
29348
2188f170f5b6
revset: add new topographical sort
Martijn Pieters <mjpieters@fb.com>
parents:
29347
diff
changeset
|
1750 |
29364
76a1a703e23d
revset: build dict of extra sort options before evaluating set
Yuya Nishihara <yuya@tcha.org>
parents:
29363
diff
changeset
|
1751 opts = {} |
29348
2188f170f5b6
revset: add new topographical sort
Martijn Pieters <mjpieters@fb.com>
parents:
29347
diff
changeset
|
1752 if 'topo.firstbranch' in args: |
29363
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
1753 if any(k == 'topo' for k, reverse in keyflags): |
29364
76a1a703e23d
revset: build dict of extra sort options before evaluating set
Yuya Nishihara <yuya@tcha.org>
parents:
29363
diff
changeset
|
1754 opts['topo.firstbranch'] = args['topo.firstbranch'] |
29348
2188f170f5b6
revset: add new topographical sort
Martijn Pieters <mjpieters@fb.com>
parents:
29347
diff
changeset
|
1755 else: |
2188f170f5b6
revset: add new topographical sort
Martijn Pieters <mjpieters@fb.com>
parents:
29347
diff
changeset
|
1756 # i18n: "topo" and "topo.firstbranch" are keywords |
29646
a8a5dd8986f0
revset: refactor to make xgettext put i18n comments into hg.pot file
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29441
diff
changeset
|
1757 raise error.ParseError(_('topo.firstbranch can only be used ' |
a8a5dd8986f0
revset: refactor to make xgettext put i18n comments into hg.pot file
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29441
diff
changeset
|
1758 'when using the topo sort key')) |
29348
2188f170f5b6
revset: add new topographical sort
Martijn Pieters <mjpieters@fb.com>
parents:
29347
diff
changeset
|
1759 |
29365
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
1760 return args['set'], keyflags, opts |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
1761 |
29946
285a8c3e53f2
revset: make sort() noop depending on ordering requirement (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29945
diff
changeset
|
1762 @predicate('sort(set[, [-]key... [, ...]])', safe=True, takeorder=True) |
285a8c3e53f2
revset: make sort() noop depending on ordering requirement (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29945
diff
changeset
|
1763 def sort(repo, subset, x, order): |
29365
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
1764 """Sort set by keys. The default sort order is ascending, specify a key |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
1765 as ``-key`` to sort in descending order. |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
1766 |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
1767 The keys can be: |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
1768 |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
1769 - ``rev`` for the revision number, |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
1770 - ``branch`` for the branch name, |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
1771 - ``desc`` for the commit message (description), |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
1772 - ``user`` for user name (``author`` can be used as an alias), |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
1773 - ``date`` for the commit date |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
1774 - ``topo`` for a reverse topographical sort |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
1775 |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
1776 The ``topo`` sort order cannot be combined with other sort keys. This sort |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
1777 takes one optional argument, ``topo.firstbranch``, which takes a revset that |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
1778 specifies what topographical branches to prioritize in the sort. |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
1779 |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
1780 """ |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
1781 s, keyflags, opts = _getsortargs(x) |
29364
76a1a703e23d
revset: build dict of extra sort options before evaluating set
Yuya Nishihara <yuya@tcha.org>
parents:
29363
diff
changeset
|
1782 revs = getset(repo, subset, s) |
76a1a703e23d
revset: build dict of extra sort options before evaluating set
Yuya Nishihara <yuya@tcha.org>
parents:
29363
diff
changeset
|
1783 |
29946
285a8c3e53f2
revset: make sort() noop depending on ordering requirement (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29945
diff
changeset
|
1784 if not keyflags or order != defineorder: |
20719
cce8fbedc82a
revset: changed sort method to use native sort implementation of smartsets
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20718
diff
changeset
|
1785 return revs |
29363
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
1786 if len(keyflags) == 1 and keyflags[0][0] == "rev": |
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
1787 revs.sort(reverse=keyflags[0][1]) |
20719
cce8fbedc82a
revset: changed sort method to use native sort implementation of smartsets
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20718
diff
changeset
|
1788 return revs |
29363
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
1789 elif keyflags[0][0] == "topo": |
29364
76a1a703e23d
revset: build dict of extra sort options before evaluating set
Yuya Nishihara <yuya@tcha.org>
parents:
29363
diff
changeset
|
1790 firstbranch = () |
76a1a703e23d
revset: build dict of extra sort options before evaluating set
Yuya Nishihara <yuya@tcha.org>
parents:
29363
diff
changeset
|
1791 if 'topo.firstbranch' in opts: |
76a1a703e23d
revset: build dict of extra sort options before evaluating set
Yuya Nishihara <yuya@tcha.org>
parents:
29363
diff
changeset
|
1792 firstbranch = getset(repo, subset, opts['topo.firstbranch']) |
29348
2188f170f5b6
revset: add new topographical sort
Martijn Pieters <mjpieters@fb.com>
parents:
29347
diff
changeset
|
1793 revs = baseset(_toposort(revs, repo.changelog.parentrevs, firstbranch), |
2188f170f5b6
revset: add new topographical sort
Martijn Pieters <mjpieters@fb.com>
parents:
29347
diff
changeset
|
1794 istopo=True) |
29363
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
1795 if keyflags[0][1]: |
29348
2188f170f5b6
revset: add new topographical sort
Martijn Pieters <mjpieters@fb.com>
parents:
29347
diff
changeset
|
1796 revs.reverse() |
2188f170f5b6
revset: add new topographical sort
Martijn Pieters <mjpieters@fb.com>
parents:
29347
diff
changeset
|
1797 return revs |
2188f170f5b6
revset: add new topographical sort
Martijn Pieters <mjpieters@fb.com>
parents:
29347
diff
changeset
|
1798 |
29001
923fa9e06ea0
revset: make sort() do dumb multi-pass sorting for multiple keys (issue5218)
Yuya Nishihara <yuya@tcha.org>
parents:
28910
diff
changeset
|
1799 # sort() is guaranteed to be stable |
923fa9e06ea0
revset: make sort() do dumb multi-pass sorting for multiple keys (issue5218)
Yuya Nishihara <yuya@tcha.org>
parents:
28910
diff
changeset
|
1800 ctxs = [repo[r] for r in revs] |
29363
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
1801 for k, reverse in reversed(keyflags): |
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
1802 ctxs.sort(key=_sortkeyfuncs[k], reverse=reverse) |
29001
923fa9e06ea0
revset: make sort() do dumb multi-pass sorting for multiple keys (issue5218)
Yuya Nishihara <yuya@tcha.org>
parents:
28910
diff
changeset
|
1803 return baseset([c.rev() for c in ctxs]) |
11275 | 1804 |
29348
2188f170f5b6
revset: add new topographical sort
Martijn Pieters <mjpieters@fb.com>
parents:
29347
diff
changeset
|
1805 def _toposort(revs, parentsfunc, firstbranch=()): |
29347
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1806 """Yield revisions from heads to roots one (topo) branch at a time. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1807 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1808 This function aims to be used by a graph generator that wishes to minimize |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1809 the number of parallel branches and their interleaving. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1810 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1811 Example iteration order (numbers show the "true" order in a changelog): |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1812 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1813 o 4 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1814 | |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1815 o 1 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1816 | |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1817 | o 3 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1818 | | |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1819 | o 2 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1820 |/ |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1821 o 0 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1822 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1823 Note that the ancestors of merges are understood by the current |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1824 algorithm to be on the same branch. This means no reordering will |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1825 occur behind a merge. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1826 """ |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1827 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1828 ### Quick summary of the algorithm |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1829 # |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1830 # This function is based around a "retention" principle. We keep revisions |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1831 # in memory until we are ready to emit a whole branch that immediately |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1832 # "merges" into an existing one. This reduces the number of parallel |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1833 # branches with interleaved revisions. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1834 # |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1835 # During iteration revs are split into two groups: |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1836 # A) revision already emitted |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1837 # B) revision in "retention". They are stored as different subgroups. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1838 # |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1839 # for each REV, we do the following logic: |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1840 # |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1841 # 1) if REV is a parent of (A), we will emit it. If there is a |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1842 # retention group ((B) above) that is blocked on REV being |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1843 # available, we emit all the revisions out of that retention |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1844 # group first. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1845 # |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1846 # 2) else, we'll search for a subgroup in (B) awaiting for REV to be |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1847 # available, if such subgroup exist, we add REV to it and the subgroup is |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1848 # now awaiting for REV.parents() to be available. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1849 # |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1850 # 3) finally if no such group existed in (B), we create a new subgroup. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1851 # |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1852 # |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1853 # To bootstrap the algorithm, we emit the tipmost revision (which |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1854 # puts it in group (A) from above). |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1855 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1856 revs.sort(reverse=True) |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1857 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1858 # Set of parents of revision that have been emitted. They can be considered |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1859 # unblocked as the graph generator is already aware of them so there is no |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1860 # need to delay the revisions that reference them. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1861 # |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1862 # If someone wants to prioritize a branch over the others, pre-filling this |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1863 # set will force all other branches to wait until this branch is ready to be |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1864 # emitted. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1865 unblocked = set(firstbranch) |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1866 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1867 # list of groups waiting to be displayed, each group is defined by: |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1868 # |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1869 # (revs: lists of revs waiting to be displayed, |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1870 # blocked: set of that cannot be displayed before those in 'revs') |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1871 # |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1872 # The second value ('blocked') correspond to parents of any revision in the |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1873 # group ('revs') that is not itself contained in the group. The main idea |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1874 # of this algorithm is to delay as much as possible the emission of any |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1875 # revision. This means waiting for the moment we are about to display |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1876 # these parents to display the revs in a group. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1877 # |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1878 # This first implementation is smart until it encounters a merge: it will |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1879 # emit revs as soon as any parent is about to be emitted and can grow an |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1880 # arbitrary number of revs in 'blocked'. In practice this mean we properly |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1881 # retains new branches but gives up on any special ordering for ancestors |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1882 # of merges. The implementation can be improved to handle this better. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1883 # |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1884 # The first subgroup is special. It corresponds to all the revision that |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1885 # were already emitted. The 'revs' lists is expected to be empty and the |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1886 # 'blocked' set contains the parents revisions of already emitted revision. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1887 # |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1888 # You could pre-seed the <parents> set of groups[0] to a specific |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1889 # changesets to select what the first emitted branch should be. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1890 groups = [([], unblocked)] |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1891 pendingheap = [] |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1892 pendingset = set() |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1893 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1894 heapq.heapify(pendingheap) |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1895 heappop = heapq.heappop |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1896 heappush = heapq.heappush |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1897 for currentrev in revs: |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1898 # Heap works with smallest element, we want highest so we invert |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1899 if currentrev not in pendingset: |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1900 heappush(pendingheap, -currentrev) |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1901 pendingset.add(currentrev) |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1902 # iterates on pending rev until after the current rev have been |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1903 # processed. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1904 rev = None |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1905 while rev != currentrev: |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1906 rev = -heappop(pendingheap) |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1907 pendingset.remove(rev) |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1908 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1909 # Seek for a subgroup blocked, waiting for the current revision. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1910 matching = [i for i, g in enumerate(groups) if rev in g[1]] |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1911 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1912 if matching: |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1913 # The main idea is to gather together all sets that are blocked |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1914 # on the same revision. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1915 # |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1916 # Groups are merged when a common blocking ancestor is |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1917 # observed. For example, given two groups: |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1918 # |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1919 # revs [5, 4] waiting for 1 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1920 # revs [3, 2] waiting for 1 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1921 # |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1922 # These two groups will be merged when we process |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1923 # 1. In theory, we could have merged the groups when |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1924 # we added 2 to the group it is now in (we could have |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1925 # noticed the groups were both blocked on 1 then), but |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1926 # the way it works now makes the algorithm simpler. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1927 # |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1928 # We also always keep the oldest subgroup first. We can |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1929 # probably improve the behavior by having the longest set |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1930 # first. That way, graph algorithms could minimise the length |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1931 # of parallel lines their drawing. This is currently not done. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1932 targetidx = matching.pop(0) |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1933 trevs, tparents = groups[targetidx] |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1934 for i in matching: |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1935 gr = groups[i] |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1936 trevs.extend(gr[0]) |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1937 tparents |= gr[1] |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1938 # delete all merged subgroups (except the one we kept) |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1939 # (starting from the last subgroup for performance and |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1940 # sanity reasons) |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1941 for i in reversed(matching): |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1942 del groups[i] |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1943 else: |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1944 # This is a new head. We create a new subgroup for it. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1945 targetidx = len(groups) |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1946 groups.append(([], set([rev]))) |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1947 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1948 gr = groups[targetidx] |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1949 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1950 # We now add the current nodes to this subgroups. This is done |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1951 # after the subgroup merging because all elements from a subgroup |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1952 # that relied on this rev must precede it. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1953 # |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1954 # we also update the <parents> set to include the parents of the |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1955 # new nodes. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1956 if rev == currentrev: # only display stuff in rev |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1957 gr[0].append(rev) |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1958 gr[1].remove(rev) |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1959 parents = [p for p in parentsfunc(rev) if p > node.nullrev] |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1960 gr[1].update(parents) |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1961 for p in parents: |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1962 if p not in pendingset: |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1963 pendingset.add(p) |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1964 heappush(pendingheap, -p) |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1965 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1966 # Look for a subgroup to display |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1967 # |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1968 # When unblocked is empty (if clause), we were not waiting for any |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1969 # revisions during the first iteration (if no priority was given) or |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1970 # if we emitted a whole disconnected set of the graph (reached a |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1971 # root). In that case we arbitrarily take the oldest known |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1972 # subgroup. The heuristic could probably be better. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1973 # |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1974 # Otherwise (elif clause) if the subgroup is blocked on |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1975 # a revision we just emitted, we can safely emit it as |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1976 # well. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1977 if not unblocked: |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1978 if len(groups) > 1: # display other subset |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1979 targetidx = 1 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1980 gr = groups[1] |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1981 elif not gr[1] & unblocked: |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1982 gr = None |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1983 |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1984 if gr is not None: |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1985 # update the set of awaited revisions with the one from the |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1986 # subgroup |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1987 unblocked |= gr[1] |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1988 # output all revisions in the subgroup |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1989 for r in gr[0]: |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1990 yield r |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1991 # delete the subgroup that you just output |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1992 # unless it is groups[0] in which case you just empty it. |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1993 if targetidx: |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1994 del groups[targetidx] |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1995 else: |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1996 gr[0][:] = [] |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1997 # Check if we have some subgroup waiting for revisions we are not going to |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1998 # iterate over |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
1999 for g in groups: |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
2000 for r in g[0]: |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
2001 yield r |
98535ad46fc0
revset: move groupbranchiter over from graphmod
Martijn Pieters <mjpieters@fb.com>
parents:
29346
diff
changeset
|
2002 |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
2003 @predicate('subrepo([pattern])') |
24446
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2004 def subrepo(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
2005 """Changesets that add, modify or remove the given subrepo. If no subrepo |
24446
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2006 pattern is named, any subrepo changes are returned. |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2007 """ |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2008 # i18n: "subrepo" is a keyword |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2009 args = getargs(x, 0, 1, _('subrepo takes at most one argument')) |
28272
760f9d04842a
revset: define "pat" variable unconditionally in subrepo()
Yuya Nishihara <yuya@tcha.org>
parents:
28271
diff
changeset
|
2010 pat = None |
24446
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2011 if len(args) != 0: |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2012 pat = getstring(args[0], _("subrepo requires a pattern")) |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2013 |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2014 m = matchmod.exact(repo.root, repo.root, ['.hgsubstate']) |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2015 |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2016 def submatches(names): |
26481
7d132557e44a
util: extract stringmatcher() from revset
Matt Harbison <matt_harbison@yahoo.com>
parents:
26307
diff
changeset
|
2017 k, p, m = util.stringmatcher(pat) |
24446
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2018 for name in names: |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2019 if m(name): |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2020 yield name |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2021 |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2022 def matches(x): |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2023 c = repo[x] |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2024 s = repo.status(c.p1().node(), c.node(), match=m) |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2025 |
28272
760f9d04842a
revset: define "pat" variable unconditionally in subrepo()
Yuya Nishihara <yuya@tcha.org>
parents:
28271
diff
changeset
|
2026 if pat is None: |
24446
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2027 return s.added or s.modified or s.removed |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2028 |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2029 if s.added: |
25149
3f0744eeaeaf
cleanup: use __builtins__.any instead of util.any
Augie Fackler <augie@google.com>
parents:
25146
diff
changeset
|
2030 return any(submatches(c.substate.keys())) |
24446
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2031 |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2032 if s.modified: |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2033 subs = set(c.p1().substate.keys()) |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2034 subs.update(c.substate.keys()) |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2035 |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2036 for path in submatches(subs): |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2037 if c.p1().substate.get(path) != c.substate.get(path): |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2038 return True |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2039 |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2040 if s.removed: |
25149
3f0744eeaeaf
cleanup: use __builtins__.any instead of util.any
Augie Fackler <augie@google.com>
parents:
25146
diff
changeset
|
2041 return any(submatches(c.p1().substate.keys())) |
24446
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2042 |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2043 return False |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2044 |
28424
534f968d33e5
revset: add inspection data to all filter() calls
Yuya Nishihara <yuya@tcha.org>
parents:
28423
diff
changeset
|
2045 return subset.filter(matches, condrepr=('<subrepo %r>', pat)) |
24446
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2046 |
30782
db38cfc7c29d
revset: stop lowercasing the regex pattern for 'author'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30772
diff
changeset
|
2047 def _substringmatcher(pattern, casesensitive=True): |
db38cfc7c29d
revset: stop lowercasing the regex pattern for 'author'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30772
diff
changeset
|
2048 kind, pattern, matcher = util.stringmatcher(pattern, |
db38cfc7c29d
revset: stop lowercasing the regex pattern for 'author'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30772
diff
changeset
|
2049 casesensitive=casesensitive) |
16823
b23bacb230c9
revset: add pattern matching to the 'user' revset expression
Simon King <simon@simonking.org.uk>
parents:
16822
diff
changeset
|
2050 if kind == 'literal': |
30782
db38cfc7c29d
revset: stop lowercasing the regex pattern for 'author'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30772
diff
changeset
|
2051 if not casesensitive: |
db38cfc7c29d
revset: stop lowercasing the regex pattern for 'author'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30772
diff
changeset
|
2052 pattern = encoding.lower(pattern) |
db38cfc7c29d
revset: stop lowercasing the regex pattern for 'author'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30772
diff
changeset
|
2053 matcher = lambda s: pattern in encoding.lower(s) |
db38cfc7c29d
revset: stop lowercasing the regex pattern for 'author'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30772
diff
changeset
|
2054 else: |
db38cfc7c29d
revset: stop lowercasing the regex pattern for 'author'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30772
diff
changeset
|
2055 matcher = lambda s: pattern in s |
16823
b23bacb230c9
revset: add pattern matching to the 'user' revset expression
Simon King <simon@simonking.org.uk>
parents:
16822
diff
changeset
|
2056 return kind, pattern, matcher |
16819
5260a9e93113
revset: add helper function for matching strings to patterns
Simon King <simon@simonking.org.uk>
parents:
16803
diff
changeset
|
2057 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
2058 @predicate('tag([name])', safe=True) |
12715
33820dccbea4
revset: rename tagged() to tag() and allow it to take an optional tag name
Augie Fackler <durin42@gmail.com>
parents:
12616
diff
changeset
|
2059 def tag(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
2060 """The specified tag by name, or all tagged revisions if no name is given. |
20824
c57c9cece645
revset: document the regular expression support for tag(name)
Matt Harbison <matt_harbison@yahoo.com>
parents:
20289
diff
changeset
|
2061 |
30784
5dd67f0993ce
help: eliminate duplicate text for revset string patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
30783
diff
changeset
|
2062 Pattern matching is supported for `name`. See |
30799
0b49449a01f4
help: use :hg: role and canonical name to point to revset string patterns
Yuya Nishihara <yuya@tcha.org>
parents:
30784
diff
changeset
|
2063 :hg:`help revisions.patterns`. |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
2064 """ |
12815
079a618ea89d
revset: add translator comments to i18n strings
Martin Geisler <mg@lazybytes.net>
parents:
12786
diff
changeset
|
2065 # i18n: "tag" is a keyword |
12715
33820dccbea4
revset: rename tagged() to tag() and allow it to take an optional tag name
Augie Fackler <durin42@gmail.com>
parents:
12616
diff
changeset
|
2066 args = getargs(x, 0, 1, _("tag takes one or no arguments")) |
11280
a5eb0bf7e158
revset: add tagged predicate
Matt Mackall <mpm@selenic.com>
parents:
11279
diff
changeset
|
2067 cl = repo.changelog |
12715
33820dccbea4
revset: rename tagged() to tag() and allow it to take an optional tag name
Augie Fackler <durin42@gmail.com>
parents:
12616
diff
changeset
|
2068 if args: |
16820
20f55613fb2a
revset: add pattern matching to 'tag' revset expression
Simon King <simon@simonking.org.uk>
parents:
16819
diff
changeset
|
2069 pattern = getstring(args[0], |
20f55613fb2a
revset: add pattern matching to 'tag' revset expression
Simon King <simon@simonking.org.uk>
parents:
16819
diff
changeset
|
2070 # i18n: "tag" is a keyword |
20f55613fb2a
revset: add pattern matching to 'tag' revset expression
Simon King <simon@simonking.org.uk>
parents:
16819
diff
changeset
|
2071 _('the argument to tag must be a string')) |
26481
7d132557e44a
util: extract stringmatcher() from revset
Matt Harbison <matt_harbison@yahoo.com>
parents:
26307
diff
changeset
|
2072 kind, pattern, matcher = util.stringmatcher(pattern) |
16820
20f55613fb2a
revset: add pattern matching to 'tag' revset expression
Simon King <simon@simonking.org.uk>
parents:
16819
diff
changeset
|
2073 if kind == 'literal': |
16825
b6ef1395d77f
revset: avoid validating all tag nodes for tag(x)
Matt Mackall <mpm@selenic.com>
parents:
16824
diff
changeset
|
2074 # avoid resolving all tags |
b6ef1395d77f
revset: avoid validating all tag nodes for tag(x)
Matt Mackall <mpm@selenic.com>
parents:
16824
diff
changeset
|
2075 tn = repo._tagscache.tags.get(pattern, None) |
b6ef1395d77f
revset: avoid validating all tag nodes for tag(x)
Matt Mackall <mpm@selenic.com>
parents:
16824
diff
changeset
|
2076 if tn is None: |
23978
eeb5d5ab14a6
revset: raise RepoLookupError to make present() predicate continue the query
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23956
diff
changeset
|
2077 raise error.RepoLookupError(_("tag '%s' does not exist") |
eeb5d5ab14a6
revset: raise RepoLookupError to make present() predicate continue the query
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23956
diff
changeset
|
2078 % pattern) |
16825
b6ef1395d77f
revset: avoid validating all tag nodes for tag(x)
Matt Mackall <mpm@selenic.com>
parents:
16824
diff
changeset
|
2079 s = set([repo[tn].rev()]) |
16820
20f55613fb2a
revset: add pattern matching to 'tag' revset expression
Simon King <simon@simonking.org.uk>
parents:
16819
diff
changeset
|
2080 else: |
20f55613fb2a
revset: add pattern matching to 'tag' revset expression
Simon King <simon@simonking.org.uk>
parents:
16819
diff
changeset
|
2081 s = set([cl.rev(n) for t, n in repo.tagslist() if matcher(t)]) |
12715
33820dccbea4
revset: rename tagged() to tag() and allow it to take an optional tag name
Augie Fackler <durin42@gmail.com>
parents:
12616
diff
changeset
|
2082 else: |
33820dccbea4
revset: rename tagged() to tag() and allow it to take an optional tag name
Augie Fackler <durin42@gmail.com>
parents:
12616
diff
changeset
|
2083 s = set([cl.rev(n) for t, n in repo.tagslist() if t != 'tip']) |
20367
2ac278aab2b4
revset: added intersection to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20366
diff
changeset
|
2084 return subset & s |
11280
a5eb0bf7e158
revset: add tagged predicate
Matt Mackall <mpm@selenic.com>
parents:
11279
diff
changeset
|
2085 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
2086 @predicate('tagged', safe=True) |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
2087 def tagged(repo, subset, x): |
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
2088 return tag(repo, subset, x) |
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
2089 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
2090 @predicate('unstable()', safe=True) |
17171
9c750c3e4fac
obsolete: compute unstable changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17170
diff
changeset
|
2091 def unstable(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
2092 """Non-obsolete changesets with obsolete ancestors. |
17291
2d6bbf87f7b4
revset: minor doc fixes on obsolete related revsets
Patrick Mezard <patrick@mezard.eu>
parents:
17272
diff
changeset
|
2093 """ |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
2094 # i18n: "unstable" is a keyword |
17258
5822345e9e46
revset: use appropriate predicate name in error messages
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17244
diff
changeset
|
2095 getargs(x, 0, 0, _("unstable takes no arguments")) |
17825
3cc06457f15e
obsolete: rename `getobscache` into `getrevs`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17804
diff
changeset
|
2096 unstables = obsmod.getrevs(repo, 'unstable') |
20367
2ac278aab2b4
revset: added intersection to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20366
diff
changeset
|
2097 return subset & unstables |
17171
9c750c3e4fac
obsolete: compute unstable changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17170
diff
changeset
|
2098 |
9c750c3e4fac
obsolete: compute unstable changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17170
diff
changeset
|
2099 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
2100 @predicate('user(string)', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
2101 def user(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
2102 """User name contains string. The match is case-insensitive. |
16823
b23bacb230c9
revset: add pattern matching to the 'user' revset expression
Simon King <simon@simonking.org.uk>
parents:
16822
diff
changeset
|
2103 |
30784
5dd67f0993ce
help: eliminate duplicate text for revset string patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
30783
diff
changeset
|
2104 Pattern matching is supported for `string`. See |
30799
0b49449a01f4
help: use :hg: role and canonical name to point to revset string patterns
Yuya Nishihara <yuya@tcha.org>
parents:
30784
diff
changeset
|
2105 :hg:`help revisions.patterns`. |
13359
87f248e78173
bookmarks: move revset support to core
Matt Mackall <mpm@selenic.com>
parents:
13031
diff
changeset
|
2106 """ |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
2107 return author(repo, subset, x) |
13359
87f248e78173
bookmarks: move revset support to core
Matt Mackall <mpm@selenic.com>
parents:
13031
diff
changeset
|
2108 |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
2109 @predicate('wdir', safe=True) |
24419
0e41f110e69e
revset: add wdir() function to specify workingctx revision by command
Yuya Nishihara <yuya@tcha.org>
parents:
24374
diff
changeset
|
2110 def wdir(repo, subset, x): |
30701
8b1d87243710
revset: document wdir() as an experimental function
Yuya Nishihara <yuya@tcha.org>
parents:
30700
diff
changeset
|
2111 """Working directory. (EXPERIMENTAL)""" |
24419
0e41f110e69e
revset: add wdir() function to specify workingctx revision by command
Yuya Nishihara <yuya@tcha.org>
parents:
24374
diff
changeset
|
2112 # i18n: "wdir" is a keyword |
0e41f110e69e
revset: add wdir() function to specify workingctx revision by command
Yuya Nishihara <yuya@tcha.org>
parents:
24374
diff
changeset
|
2113 getargs(x, 0, 0, _("wdir takes no arguments")) |
25765
5e1b0739611c
revset: use integer representation of wdir() in revset
Yuya Nishihara <yuya@tcha.org>
parents:
25716
diff
changeset
|
2114 if node.wdirrev in subset or isinstance(subset, fullreposet): |
5e1b0739611c
revset: use integer representation of wdir() in revset
Yuya Nishihara <yuya@tcha.org>
parents:
25716
diff
changeset
|
2115 return baseset([node.wdirrev]) |
24419
0e41f110e69e
revset: add wdir() function to specify workingctx revision by command
Yuya Nishihara <yuya@tcha.org>
parents:
24374
diff
changeset
|
2116 return baseset() |
0e41f110e69e
revset: add wdir() function to specify workingctx revision by command
Yuya Nishihara <yuya@tcha.org>
parents:
24374
diff
changeset
|
2117 |
29935
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2118 def _orderedlist(repo, subset, x): |
15898
6902e13ddd03
revset: optimize building large lists in formatrevspec
Matt Mackall <mpm@selenic.com>
parents:
15837
diff
changeset
|
2119 s = getstring(x, "internal error") |
6902e13ddd03
revset: optimize building large lists in formatrevspec
Matt Mackall <mpm@selenic.com>
parents:
15837
diff
changeset
|
2120 if not s: |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
2121 return baseset() |
25341
9d6cc87bd507
revset: make internal _list() expression remove duplicated revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25309
diff
changeset
|
2122 # remove duplicates here. it's difficult for caller to deduplicate sets |
9d6cc87bd507
revset: make internal _list() expression remove duplicated revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25309
diff
changeset
|
2123 # because different symbols can point to the same rev. |
25344
ceaf04bb14ff
revset: add fast path for _list() of integer revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25343
diff
changeset
|
2124 cl = repo.changelog |
25341
9d6cc87bd507
revset: make internal _list() expression remove duplicated revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25309
diff
changeset
|
2125 ls = [] |
9d6cc87bd507
revset: make internal _list() expression remove duplicated revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25309
diff
changeset
|
2126 seen = set() |
9d6cc87bd507
revset: make internal _list() expression remove duplicated revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25309
diff
changeset
|
2127 for t in s.split('\0'): |
25344
ceaf04bb14ff
revset: add fast path for _list() of integer revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25343
diff
changeset
|
2128 try: |
ceaf04bb14ff
revset: add fast path for _list() of integer revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25343
diff
changeset
|
2129 # fast path for integer revision |
ceaf04bb14ff
revset: add fast path for _list() of integer revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25343
diff
changeset
|
2130 r = int(t) |
ceaf04bb14ff
revset: add fast path for _list() of integer revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25343
diff
changeset
|
2131 if str(r) != t or r not in cl: |
ceaf04bb14ff
revset: add fast path for _list() of integer revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25343
diff
changeset
|
2132 raise ValueError |
26143
42bb1812686f
revset: fix resolving strings from a list
Durham Goode <durham@fb.com>
parents:
26102
diff
changeset
|
2133 revs = [r] |
25344
ceaf04bb14ff
revset: add fast path for _list() of integer revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25343
diff
changeset
|
2134 except ValueError: |
26143
42bb1812686f
revset: fix resolving strings from a list
Durham Goode <durham@fb.com>
parents:
26102
diff
changeset
|
2135 revs = stringset(repo, subset, t) |
42bb1812686f
revset: fix resolving strings from a list
Durham Goode <durham@fb.com>
parents:
26102
diff
changeset
|
2136 |
42bb1812686f
revset: fix resolving strings from a list
Durham Goode <durham@fb.com>
parents:
26102
diff
changeset
|
2137 for r in revs: |
42bb1812686f
revset: fix resolving strings from a list
Durham Goode <durham@fb.com>
parents:
26102
diff
changeset
|
2138 if r in seen: |
42bb1812686f
revset: fix resolving strings from a list
Durham Goode <durham@fb.com>
parents:
26102
diff
changeset
|
2139 continue |
42bb1812686f
revset: fix resolving strings from a list
Durham Goode <durham@fb.com>
parents:
26102
diff
changeset
|
2140 if (r in subset |
42bb1812686f
revset: fix resolving strings from a list
Durham Goode <durham@fb.com>
parents:
26102
diff
changeset
|
2141 or r == node.nullrev and isinstance(subset, fullreposet)): |
42bb1812686f
revset: fix resolving strings from a list
Durham Goode <durham@fb.com>
parents:
26102
diff
changeset
|
2142 ls.append(r) |
42bb1812686f
revset: fix resolving strings from a list
Durham Goode <durham@fb.com>
parents:
26102
diff
changeset
|
2143 seen.add(r) |
25341
9d6cc87bd507
revset: make internal _list() expression remove duplicated revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25309
diff
changeset
|
2144 return baseset(ls) |
15898
6902e13ddd03
revset: optimize building large lists in formatrevspec
Matt Mackall <mpm@selenic.com>
parents:
15837
diff
changeset
|
2145 |
20566
98024950ade0
revset: added _intlist method to replace _list for %ld
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20552
diff
changeset
|
2146 # for internal use |
29935
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2147 @predicate('_list', safe=True, takeorder=True) |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2148 def _list(repo, subset, x, order): |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2149 if order == followorder: |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2150 # slow path to take the subset order |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2151 return subset & _orderedlist(repo, fullreposet(repo), x) |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2152 else: |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2153 return _orderedlist(repo, subset, x) |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2154 |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2155 def _orderedintlist(repo, subset, x): |
20566
98024950ade0
revset: added _intlist method to replace _list for %ld
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20552
diff
changeset
|
2156 s = getstring(x, "internal error") |
98024950ade0
revset: added _intlist method to replace _list for %ld
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20552
diff
changeset
|
2157 if not s: |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
2158 return baseset() |
20566
98024950ade0
revset: added _intlist method to replace _list for %ld
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20552
diff
changeset
|
2159 ls = [int(r) for r in s.split('\0')] |
22876
d52ca940c665
revset-_intlist: remove usage of `set()`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22875
diff
changeset
|
2160 s = subset |
20566
98024950ade0
revset: added _intlist method to replace _list for %ld
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20552
diff
changeset
|
2161 return baseset([r for r in ls if r in s]) |
98024950ade0
revset: added _intlist method to replace _list for %ld
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20552
diff
changeset
|
2162 |
20569
0d4be103c734
revset: added _hexlist method to replace _list for %ln
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20566
diff
changeset
|
2163 # for internal use |
29935
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2164 @predicate('_intlist', safe=True, takeorder=True) |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2165 def _intlist(repo, subset, x, order): |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2166 if order == followorder: |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2167 # slow path to take the subset order |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2168 return subset & _orderedintlist(repo, fullreposet(repo), x) |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2169 else: |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2170 return _orderedintlist(repo, subset, x) |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2171 |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2172 def _orderedhexlist(repo, subset, x): |
20569
0d4be103c734
revset: added _hexlist method to replace _list for %ln
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20566
diff
changeset
|
2173 s = getstring(x, "internal error") |
0d4be103c734
revset: added _hexlist method to replace _list for %ln
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20566
diff
changeset
|
2174 if not s: |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
2175 return baseset() |
20569
0d4be103c734
revset: added _hexlist method to replace _list for %ln
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20566
diff
changeset
|
2176 cl = repo.changelog |
0d4be103c734
revset: added _hexlist method to replace _list for %ln
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20566
diff
changeset
|
2177 ls = [cl.rev(node.bin(r)) for r in s.split('\0')] |
22877
489d2f3688c9
revset-_hexlist: remove usage of `set()`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22876
diff
changeset
|
2178 s = subset |
20569
0d4be103c734
revset: added _hexlist method to replace _list for %ln
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20566
diff
changeset
|
2179 return baseset([r for r in ls if r in s]) |
15898
6902e13ddd03
revset: optimize building large lists in formatrevspec
Matt Mackall <mpm@selenic.com>
parents:
15837
diff
changeset
|
2180 |
29935
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2181 # for internal use |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2182 @predicate('_hexlist', safe=True, takeorder=True) |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2183 def _hexlist(repo, subset, x, order): |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2184 if order == followorder: |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2185 # slow path to take the subset order |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2186 return subset & _orderedhexlist(repo, fullreposet(repo), x) |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2187 else: |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2188 return _orderedhexlist(repo, subset, x) |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2189 |
11275 | 2190 methods = { |
2191 "range": rangeset, | |
30803
d389f19f14aa
revset: do not transform range* operators in parsed tree
Yuya Nishihara <yuya@tcha.org>
parents:
30802
diff
changeset
|
2192 "rangeall": rangeall, |
30044
69b61d0bb008
revset: do not rewrite ':y' to '0:y' (issue5385)
Yuya Nishihara <yuya@tcha.org>
parents:
30043
diff
changeset
|
2193 "rangepre": rangepre, |
30803
d389f19f14aa
revset: do not transform range* operators in parsed tree
Yuya Nishihara <yuya@tcha.org>
parents:
30802
diff
changeset
|
2194 "rangepost": rangepost, |
16860
e1aa1ed30030
revset: turn dagrange into a function
Bryan O'Sullivan <bryano@fb.com>
parents:
16859
diff
changeset
|
2195 "dagrange": dagrange, |
11275 | 2196 "string": stringset, |
24932
022282152632
revset: don't error out if tokens parse as existing symbols
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
24923
diff
changeset
|
2197 "symbol": stringset, |
11275 | 2198 "and": andset, |
2199 "or": orset, | |
2200 "not": notset, | |
28217
d2ac8b57a75d
revset: use smartset minus operator
Durham Goode <durham@fb.com>
parents:
28139
diff
changeset
|
2201 "difference": differenceset, |
11275 | 2202 "list": listset, |
25704
70a2082f855a
revset: add parsing rule for key=value pair
Yuya Nishihara <yuya@tcha.org>
parents:
25689
diff
changeset
|
2203 "keyvalue": keyvaluepair, |
11275 | 2204 "func": func, |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
2205 "ancestor": ancestorspec, |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
2206 "parent": parentspec, |
29931
d2d1be3009ca
revset: add stub to handle parentpost operation
Yuya Nishihara <yuya@tcha.org>
parents:
29930
diff
changeset
|
2207 "parentpost": parentpost, |
11275 | 2208 } |
2209 | |
24518
dd5e56f08d13
revset: add hook after tree parsing
Laurent Charignon <lcharignon@fb.com>
parents:
24459
diff
changeset
|
2210 def posttreebuilthook(tree, repo): |
dd5e56f08d13
revset: add hook after tree parsing
Laurent Charignon <lcharignon@fb.com>
parents:
24459
diff
changeset
|
2211 # hook for extensions to execute code on the optimized tree |
dd5e56f08d13
revset: add hook after tree parsing
Laurent Charignon <lcharignon@fb.com>
parents:
24459
diff
changeset
|
2212 pass |
dd5e56f08d13
revset: add hook after tree parsing
Laurent Charignon <lcharignon@fb.com>
parents:
24459
diff
changeset
|
2213 |
29955
1b5931604a5a
revset: add option to make matcher takes the ordering of the input set
Yuya Nishihara <yuya@tcha.org>
parents:
29946
diff
changeset
|
2214 def match(ui, spec, repo=None, order=defineorder): |
1b5931604a5a
revset: add option to make matcher takes the ordering of the input set
Yuya Nishihara <yuya@tcha.org>
parents:
29946
diff
changeset
|
2215 """Create a matcher for a single revision spec |
1b5931604a5a
revset: add option to make matcher takes the ordering of the input set
Yuya Nishihara <yuya@tcha.org>
parents:
29946
diff
changeset
|
2216 |
1b5931604a5a
revset: add option to make matcher takes the ordering of the input set
Yuya Nishihara <yuya@tcha.org>
parents:
29946
diff
changeset
|
2217 If order=followorder, a matcher takes the ordering specified by the input |
1b5931604a5a
revset: add option to make matcher takes the ordering of the input set
Yuya Nishihara <yuya@tcha.org>
parents:
29946
diff
changeset
|
2218 set. |
1b5931604a5a
revset: add option to make matcher takes the ordering of the input set
Yuya Nishihara <yuya@tcha.org>
parents:
29946
diff
changeset
|
2219 """ |
1b5931604a5a
revset: add option to make matcher takes the ordering of the input set
Yuya Nishihara <yuya@tcha.org>
parents:
29946
diff
changeset
|
2220 return matchany(ui, [spec], repo=repo, order=order) |
1b5931604a5a
revset: add option to make matcher takes the ordering of the input set
Yuya Nishihara <yuya@tcha.org>
parents:
29946
diff
changeset
|
2221 |
1b5931604a5a
revset: add option to make matcher takes the ordering of the input set
Yuya Nishihara <yuya@tcha.org>
parents:
29946
diff
changeset
|
2222 def matchany(ui, specs, repo=None, order=defineorder): |
25927
44da63623fca
revset: add matchany() to construct OR expression from a list of specs
Yuya Nishihara <yuya@tcha.org>
parents:
25926
diff
changeset
|
2223 """Create a matcher that will include any revisions matching one of the |
29955
1b5931604a5a
revset: add option to make matcher takes the ordering of the input set
Yuya Nishihara <yuya@tcha.org>
parents:
29946
diff
changeset
|
2224 given specs |
1b5931604a5a
revset: add option to make matcher takes the ordering of the input set
Yuya Nishihara <yuya@tcha.org>
parents:
29946
diff
changeset
|
2225 |
1b5931604a5a
revset: add option to make matcher takes the ordering of the input set
Yuya Nishihara <yuya@tcha.org>
parents:
29946
diff
changeset
|
2226 If order=followorder, a matcher takes the ordering specified by the input |
1b5931604a5a
revset: add option to make matcher takes the ordering of the input set
Yuya Nishihara <yuya@tcha.org>
parents:
29946
diff
changeset
|
2227 set. |
1b5931604a5a
revset: add option to make matcher takes the ordering of the input set
Yuya Nishihara <yuya@tcha.org>
parents:
29946
diff
changeset
|
2228 """ |
25927
44da63623fca
revset: add matchany() to construct OR expression from a list of specs
Yuya Nishihara <yuya@tcha.org>
parents:
25926
diff
changeset
|
2229 if not specs: |
44da63623fca
revset: add matchany() to construct OR expression from a list of specs
Yuya Nishihara <yuya@tcha.org>
parents:
25926
diff
changeset
|
2230 def mfunc(repo, subset=None): |
44da63623fca
revset: add matchany() to construct OR expression from a list of specs
Yuya Nishihara <yuya@tcha.org>
parents:
25926
diff
changeset
|
2231 return baseset() |
44da63623fca
revset: add matchany() to construct OR expression from a list of specs
Yuya Nishihara <yuya@tcha.org>
parents:
25926
diff
changeset
|
2232 return mfunc |
44da63623fca
revset: add matchany() to construct OR expression from a list of specs
Yuya Nishihara <yuya@tcha.org>
parents:
25926
diff
changeset
|
2233 if not all(specs): |
44da63623fca
revset: add matchany() to construct OR expression from a list of specs
Yuya Nishihara <yuya@tcha.org>
parents:
25926
diff
changeset
|
2234 raise error.ParseError(_("empty query")) |
44da63623fca
revset: add matchany() to construct OR expression from a list of specs
Yuya Nishihara <yuya@tcha.org>
parents:
25926
diff
changeset
|
2235 lookup = None |
44da63623fca
revset: add matchany() to construct OR expression from a list of specs
Yuya Nishihara <yuya@tcha.org>
parents:
25926
diff
changeset
|
2236 if repo: |
44da63623fca
revset: add matchany() to construct OR expression from a list of specs
Yuya Nishihara <yuya@tcha.org>
parents:
25926
diff
changeset
|
2237 lookup = repo.__contains__ |
44da63623fca
revset: add matchany() to construct OR expression from a list of specs
Yuya Nishihara <yuya@tcha.org>
parents:
25926
diff
changeset
|
2238 if len(specs) == 1: |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
2239 tree = revsetlang.parse(specs[0], lookup) |
25927
44da63623fca
revset: add matchany() to construct OR expression from a list of specs
Yuya Nishihara <yuya@tcha.org>
parents:
25926
diff
changeset
|
2240 else: |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
2241 tree = ('or', |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
2242 ('list',) + tuple(revsetlang.parse(s, lookup) for s in specs)) |
29906
41491cf936f2
revset: add public function to create matcher from evaluatable tree
Yuya Nishihara <yuya@tcha.org>
parents:
29905
diff
changeset
|
2243 |
14900
fc3d6f300d7d
revset: allow bypassing alias expansion
Matt Mackall <mpm@selenic.com>
parents:
14851
diff
changeset
|
2244 if ui: |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
2245 tree = revsetlang.expandaliases(ui, tree) |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
2246 tree = revsetlang.foldconcat(tree) |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
2247 tree = revsetlang.analyze(tree, order) |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
2248 tree = revsetlang.optimize(tree) |
24518
dd5e56f08d13
revset: add hook after tree parsing
Laurent Charignon <lcharignon@fb.com>
parents:
24459
diff
changeset
|
2249 posttreebuilthook(tree, repo) |
29906
41491cf936f2
revset: add public function to create matcher from evaluatable tree
Yuya Nishihara <yuya@tcha.org>
parents:
29905
diff
changeset
|
2250 return makematcher(tree) |
41491cf936f2
revset: add public function to create matcher from evaluatable tree
Yuya Nishihara <yuya@tcha.org>
parents:
29905
diff
changeset
|
2251 |
41491cf936f2
revset: add public function to create matcher from evaluatable tree
Yuya Nishihara <yuya@tcha.org>
parents:
29905
diff
changeset
|
2252 def makematcher(tree): |
41491cf936f2
revset: add public function to create matcher from evaluatable tree
Yuya Nishihara <yuya@tcha.org>
parents:
29905
diff
changeset
|
2253 """Create a matcher from an evaluatable tree""" |
24114
fafd9a1284cf
revset: make match function initiate query from full set by default
Yuya Nishihara <yuya@tcha.org>
parents:
24031
diff
changeset
|
2254 def mfunc(repo, subset=None): |
fafd9a1284cf
revset: make match function initiate query from full set by default
Yuya Nishihara <yuya@tcha.org>
parents:
24031
diff
changeset
|
2255 if subset is None: |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
2256 subset = fullreposet(repo) |
31810
81abd0d12c86
revset: stop supporting plain list as input set (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31809
diff
changeset
|
2257 return getset(repo, subset, tree) |
11275 | 2258 return mfunc |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
2259 |
28393
ac11ba7c2e56
registrar: define revsetpredicate to decorate revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28272
diff
changeset
|
2260 def loadpredicate(ui, extname, registrarobj): |
ac11ba7c2e56
registrar: define revsetpredicate to decorate revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28272
diff
changeset
|
2261 """Load revset predicates from specified registrarobj |
ac11ba7c2e56
registrar: define revsetpredicate to decorate revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28272
diff
changeset
|
2262 """ |
ac11ba7c2e56
registrar: define revsetpredicate to decorate revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28272
diff
changeset
|
2263 for name, func in registrarobj._table.iteritems(): |
ac11ba7c2e56
registrar: define revsetpredicate to decorate revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28272
diff
changeset
|
2264 symbols[name] = func |
ac11ba7c2e56
registrar: define revsetpredicate to decorate revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28272
diff
changeset
|
2265 if func._safe: |
ac11ba7c2e56
registrar: define revsetpredicate to decorate revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28272
diff
changeset
|
2266 safesymbols.add(name) |
ac11ba7c2e56
registrar: define revsetpredicate to decorate revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28272
diff
changeset
|
2267 |
28395
0383f7a5e86c
revset: replace predicate by revsetpredicate of registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28393
diff
changeset
|
2268 # load built-in predicates explicitly to setup safesymbols |
0383f7a5e86c
revset: replace predicate by revsetpredicate of registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28393
diff
changeset
|
2269 loadpredicate(None, None, predicate) |
0383f7a5e86c
revset: replace predicate by revsetpredicate of registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28393
diff
changeset
|
2270 |
12823
80deae3bc5ea
hggettext: handle i18nfunctions declaration for docstrings translations
Patrick Mezard <pmezard@gmail.com>
parents:
12821
diff
changeset
|
2271 # tell hggettext to extract docstrings from these functions: |
80deae3bc5ea
hggettext: handle i18nfunctions declaration for docstrings translations
Patrick Mezard <pmezard@gmail.com>
parents:
12821
diff
changeset
|
2272 i18nfunctions = symbols.values() |