Show More
@@ -1,2968 +1,2970 b'' | |||||
1 | # revset.py - revision set queries for mercurial |
|
1 | # revset.py - revision set queries for mercurial | |
2 | # |
|
2 | # | |
3 | # Copyright 2010 Matt Mackall <mpm@selenic.com> |
|
3 | # Copyright 2010 Matt Mackall <mpm@selenic.com> | |
4 | # |
|
4 | # | |
5 | # This software may be used and distributed according to the terms of the |
|
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. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | import re |
|
8 | import re | |
9 | import parser, util, error, discovery, hbisect, phases |
|
9 | import parser, util, error, discovery, hbisect, phases | |
10 | import node |
|
10 | import node | |
11 | import heapq |
|
11 | import heapq | |
12 | import match as matchmod |
|
12 | import match as matchmod | |
13 | import ancestor as ancestormod |
|
13 | import ancestor as ancestormod | |
14 | from i18n import _ |
|
14 | from i18n import _ | |
15 | import encoding |
|
15 | import encoding | |
16 | import obsolete as obsmod |
|
16 | import obsolete as obsmod | |
17 | import pathutil |
|
17 | import pathutil | |
18 | import repoview |
|
18 | import repoview | |
19 |
|
19 | |||
20 | def _revancestors(repo, revs, followfirst): |
|
20 | def _revancestors(repo, revs, followfirst): | |
21 | """Like revlog.ancestors(), but supports followfirst.""" |
|
21 | """Like revlog.ancestors(), but supports followfirst.""" | |
22 | cut = followfirst and 1 or None |
|
22 | cut = followfirst and 1 or None | |
23 | cl = repo.changelog |
|
23 | cl = repo.changelog | |
24 |
|
24 | |||
25 | def iterate(): |
|
25 | def iterate(): | |
26 | revqueue, revsnode = None, None |
|
26 | revqueue, revsnode = None, None | |
27 | h = [] |
|
27 | h = [] | |
28 |
|
28 | |||
29 | revs.sort(reverse=True) |
|
29 | revs.sort(reverse=True) | |
30 | revqueue = util.deque(revs) |
|
30 | revqueue = util.deque(revs) | |
31 | if revqueue: |
|
31 | if revqueue: | |
32 | revsnode = revqueue.popleft() |
|
32 | revsnode = revqueue.popleft() | |
33 | heapq.heappush(h, -revsnode) |
|
33 | heapq.heappush(h, -revsnode) | |
34 |
|
34 | |||
35 | seen = set([node.nullrev]) |
|
35 | seen = set([node.nullrev]) | |
36 | while h: |
|
36 | while h: | |
37 | current = -heapq.heappop(h) |
|
37 | current = -heapq.heappop(h) | |
38 | if current not in seen: |
|
38 | if current not in seen: | |
39 | if revsnode and current == revsnode: |
|
39 | if revsnode and current == revsnode: | |
40 | if revqueue: |
|
40 | if revqueue: | |
41 | revsnode = revqueue.popleft() |
|
41 | revsnode = revqueue.popleft() | |
42 | heapq.heappush(h, -revsnode) |
|
42 | heapq.heappush(h, -revsnode) | |
43 | seen.add(current) |
|
43 | seen.add(current) | |
44 | yield current |
|
44 | yield current | |
45 | for parent in cl.parentrevs(current)[:cut]: |
|
45 | for parent in cl.parentrevs(current)[:cut]: | |
46 | if parent != node.nullrev: |
|
46 | if parent != node.nullrev: | |
47 | heapq.heappush(h, -parent) |
|
47 | heapq.heappush(h, -parent) | |
48 |
|
48 | |||
49 | return generatorset(iterate(), iterasc=False) |
|
49 | return generatorset(iterate(), iterasc=False) | |
50 |
|
50 | |||
51 | def _revdescendants(repo, revs, followfirst): |
|
51 | def _revdescendants(repo, revs, followfirst): | |
52 | """Like revlog.descendants() but supports followfirst.""" |
|
52 | """Like revlog.descendants() but supports followfirst.""" | |
53 | cut = followfirst and 1 or None |
|
53 | cut = followfirst and 1 or None | |
54 |
|
54 | |||
55 | def iterate(): |
|
55 | def iterate(): | |
56 | cl = repo.changelog |
|
56 | cl = repo.changelog | |
57 | first = min(revs) |
|
57 | first = min(revs) | |
58 | nullrev = node.nullrev |
|
58 | nullrev = node.nullrev | |
59 | if first == nullrev: |
|
59 | if first == nullrev: | |
60 | # Are there nodes with a null first parent and a non-null |
|
60 | # Are there nodes with a null first parent and a non-null | |
61 | # second one? Maybe. Do we care? Probably not. |
|
61 | # second one? Maybe. Do we care? Probably not. | |
62 | for i in cl: |
|
62 | for i in cl: | |
63 | yield i |
|
63 | yield i | |
64 | else: |
|
64 | else: | |
65 | seen = set(revs) |
|
65 | seen = set(revs) | |
66 | for i in cl.revs(first + 1): |
|
66 | for i in cl.revs(first + 1): | |
67 | for x in cl.parentrevs(i)[:cut]: |
|
67 | for x in cl.parentrevs(i)[:cut]: | |
68 | if x != nullrev and x in seen: |
|
68 | if x != nullrev and x in seen: | |
69 | seen.add(i) |
|
69 | seen.add(i) | |
70 | yield i |
|
70 | yield i | |
71 | break |
|
71 | break | |
72 |
|
72 | |||
73 | return generatorset(iterate(), iterasc=True) |
|
73 | return generatorset(iterate(), iterasc=True) | |
74 |
|
74 | |||
75 | def _revsbetween(repo, roots, heads): |
|
75 | def _revsbetween(repo, roots, heads): | |
76 | """Return all paths between roots and heads, inclusive of both endpoint |
|
76 | """Return all paths between roots and heads, inclusive of both endpoint | |
77 | sets.""" |
|
77 | sets.""" | |
78 | if not roots: |
|
78 | if not roots: | |
79 | return baseset() |
|
79 | return baseset() | |
80 | parentrevs = repo.changelog.parentrevs |
|
80 | parentrevs = repo.changelog.parentrevs | |
81 | visit = list(heads) |
|
81 | visit = list(heads) | |
82 | reachable = set() |
|
82 | reachable = set() | |
83 | seen = {} |
|
83 | seen = {} | |
84 | minroot = min(roots) |
|
84 | minroot = min(roots) | |
85 | roots = set(roots) |
|
85 | roots = set(roots) | |
86 | # open-code the post-order traversal due to the tiny size of |
|
86 | # open-code the post-order traversal due to the tiny size of | |
87 | # sys.getrecursionlimit() |
|
87 | # sys.getrecursionlimit() | |
88 | while visit: |
|
88 | while visit: | |
89 | rev = visit.pop() |
|
89 | rev = visit.pop() | |
90 | if rev in roots: |
|
90 | if rev in roots: | |
91 | reachable.add(rev) |
|
91 | reachable.add(rev) | |
92 | parents = parentrevs(rev) |
|
92 | parents = parentrevs(rev) | |
93 | seen[rev] = parents |
|
93 | seen[rev] = parents | |
94 | for parent in parents: |
|
94 | for parent in parents: | |
95 | if parent >= minroot and parent not in seen: |
|
95 | if parent >= minroot and parent not in seen: | |
96 | visit.append(parent) |
|
96 | visit.append(parent) | |
97 | if not reachable: |
|
97 | if not reachable: | |
98 | return baseset() |
|
98 | return baseset() | |
99 | for rev in sorted(seen): |
|
99 | for rev in sorted(seen): | |
100 | for parent in seen[rev]: |
|
100 | for parent in seen[rev]: | |
101 | if parent in reachable: |
|
101 | if parent in reachable: | |
102 | reachable.add(rev) |
|
102 | reachable.add(rev) | |
103 | return baseset(sorted(reachable)) |
|
103 | return baseset(sorted(reachable)) | |
104 |
|
104 | |||
105 | elements = { |
|
105 | elements = { | |
106 | "(": (20, ("group", 1, ")"), ("func", 1, ")")), |
|
106 | "(": (20, ("group", 1, ")"), ("func", 1, ")")), | |
107 | "~": (18, None, ("ancestor", 18)), |
|
107 | "~": (18, None, ("ancestor", 18)), | |
108 | "^": (18, None, ("parent", 18), ("parentpost", 18)), |
|
108 | "^": (18, None, ("parent", 18), ("parentpost", 18)), | |
109 | "-": (5, ("negate", 19), ("minus", 5)), |
|
109 | "-": (5, ("negate", 19), ("minus", 5)), | |
110 | "::": (17, ("dagrangepre", 17), ("dagrange", 17), |
|
110 | "::": (17, ("dagrangepre", 17), ("dagrange", 17), | |
111 | ("dagrangepost", 17)), |
|
111 | ("dagrangepost", 17)), | |
112 | "..": (17, ("dagrangepre", 17), ("dagrange", 17), |
|
112 | "..": (17, ("dagrangepre", 17), ("dagrange", 17), | |
113 | ("dagrangepost", 17)), |
|
113 | ("dagrangepost", 17)), | |
114 | ":": (15, ("rangepre", 15), ("range", 15), ("rangepost", 15)), |
|
114 | ":": (15, ("rangepre", 15), ("range", 15), ("rangepost", 15)), | |
115 | "not": (10, ("not", 10)), |
|
115 | "not": (10, ("not", 10)), | |
116 | "!": (10, ("not", 10)), |
|
116 | "!": (10, ("not", 10)), | |
117 | "and": (5, None, ("and", 5)), |
|
117 | "and": (5, None, ("and", 5)), | |
118 | "&": (5, None, ("and", 5)), |
|
118 | "&": (5, None, ("and", 5)), | |
119 | "or": (4, None, ("or", 4)), |
|
119 | "or": (4, None, ("or", 4)), | |
120 | "|": (4, None, ("or", 4)), |
|
120 | "|": (4, None, ("or", 4)), | |
121 | "+": (4, None, ("or", 4)), |
|
121 | "+": (4, None, ("or", 4)), | |
122 | ",": (2, None, ("list", 2)), |
|
122 | ",": (2, None, ("list", 2)), | |
123 | ")": (0, None, None), |
|
123 | ")": (0, None, None), | |
124 | "symbol": (0, ("symbol",), None), |
|
124 | "symbol": (0, ("symbol",), None), | |
125 | "string": (0, ("string",), None), |
|
125 | "string": (0, ("string",), None), | |
126 | "end": (0, None, None), |
|
126 | "end": (0, None, None), | |
127 | } |
|
127 | } | |
128 |
|
128 | |||
129 | keywords = set(['and', 'or', 'not']) |
|
129 | keywords = set(['and', 'or', 'not']) | |
130 |
|
130 | |||
131 | def tokenize(program, lookup=None): |
|
131 | def tokenize(program, lookup=None): | |
132 | ''' |
|
132 | ''' | |
133 | Parse a revset statement into a stream of tokens |
|
133 | Parse a revset statement into a stream of tokens | |
134 |
|
134 | |||
135 | Check that @ is a valid unquoted token character (issue3686): |
|
135 | Check that @ is a valid unquoted token character (issue3686): | |
136 | >>> list(tokenize("@::")) |
|
136 | >>> list(tokenize("@::")) | |
137 | [('symbol', '@', 0), ('::', None, 1), ('end', None, 3)] |
|
137 | [('symbol', '@', 0), ('::', None, 1), ('end', None, 3)] | |
138 |
|
138 | |||
139 | ''' |
|
139 | ''' | |
140 |
|
140 | |||
141 | pos, l = 0, len(program) |
|
141 | pos, l = 0, len(program) | |
142 | while pos < l: |
|
142 | while pos < l: | |
143 | c = program[pos] |
|
143 | c = program[pos] | |
144 | if c.isspace(): # skip inter-token whitespace |
|
144 | if c.isspace(): # skip inter-token whitespace | |
145 | pass |
|
145 | pass | |
146 | elif c == ':' and program[pos:pos + 2] == '::': # look ahead carefully |
|
146 | elif c == ':' and program[pos:pos + 2] == '::': # look ahead carefully | |
147 | yield ('::', None, pos) |
|
147 | yield ('::', None, pos) | |
148 | pos += 1 # skip ahead |
|
148 | pos += 1 # skip ahead | |
149 | elif c == '.' and program[pos:pos + 2] == '..': # look ahead carefully |
|
149 | elif c == '.' and program[pos:pos + 2] == '..': # look ahead carefully | |
150 | yield ('..', None, pos) |
|
150 | yield ('..', None, pos) | |
151 | pos += 1 # skip ahead |
|
151 | pos += 1 # skip ahead | |
152 | elif c in "():,-|&+!~^": # handle simple operators |
|
152 | elif c in "():,-|&+!~^": # handle simple operators | |
153 | yield (c, None, pos) |
|
153 | yield (c, None, pos) | |
154 | elif (c in '"\'' or c == 'r' and |
|
154 | elif (c in '"\'' or c == 'r' and | |
155 | program[pos:pos + 2] in ("r'", 'r"')): # handle quoted strings |
|
155 | program[pos:pos + 2] in ("r'", 'r"')): # handle quoted strings | |
156 | if c == 'r': |
|
156 | if c == 'r': | |
157 | pos += 1 |
|
157 | pos += 1 | |
158 | c = program[pos] |
|
158 | c = program[pos] | |
159 | decode = lambda x: x |
|
159 | decode = lambda x: x | |
160 | else: |
|
160 | else: | |
161 | decode = lambda x: x.decode('string-escape') |
|
161 | decode = lambda x: x.decode('string-escape') | |
162 | pos += 1 |
|
162 | pos += 1 | |
163 | s = pos |
|
163 | s = pos | |
164 | while pos < l: # find closing quote |
|
164 | while pos < l: # find closing quote | |
165 | d = program[pos] |
|
165 | d = program[pos] | |
166 | if d == '\\': # skip over escaped characters |
|
166 | if d == '\\': # skip over escaped characters | |
167 | pos += 2 |
|
167 | pos += 2 | |
168 | continue |
|
168 | continue | |
169 | if d == c: |
|
169 | if d == c: | |
170 | yield ('string', decode(program[s:pos]), s) |
|
170 | yield ('string', decode(program[s:pos]), s) | |
171 | break |
|
171 | break | |
172 | pos += 1 |
|
172 | pos += 1 | |
173 | else: |
|
173 | else: | |
174 | raise error.ParseError(_("unterminated string"), s) |
|
174 | raise error.ParseError(_("unterminated string"), s) | |
175 | # gather up a symbol/keyword |
|
175 | # gather up a symbol/keyword | |
176 | elif c.isalnum() or c in '._@' or ord(c) > 127: |
|
176 | elif c.isalnum() or c in '._@' or ord(c) > 127: | |
177 | s = pos |
|
177 | s = pos | |
178 | pos += 1 |
|
178 | pos += 1 | |
179 | while pos < l: # find end of symbol |
|
179 | while pos < l: # find end of symbol | |
180 | d = program[pos] |
|
180 | d = program[pos] | |
181 | if not (d.isalnum() or d in "-._/@" or ord(d) > 127): |
|
181 | if not (d.isalnum() or d in "-._/@" or ord(d) > 127): | |
182 | break |
|
182 | break | |
183 | if d == '.' and program[pos - 1] == '.': # special case for .. |
|
183 | if d == '.' and program[pos - 1] == '.': # special case for .. | |
184 | pos -= 1 |
|
184 | pos -= 1 | |
185 | break |
|
185 | break | |
186 | pos += 1 |
|
186 | pos += 1 | |
187 | sym = program[s:pos] |
|
187 | sym = program[s:pos] | |
188 | if sym in keywords: # operator keywords |
|
188 | if sym in keywords: # operator keywords | |
189 | yield (sym, None, s) |
|
189 | yield (sym, None, s) | |
190 | elif '-' in sym: |
|
190 | elif '-' in sym: | |
191 | # some jerk gave us foo-bar-baz, try to check if it's a symbol |
|
191 | # some jerk gave us foo-bar-baz, try to check if it's a symbol | |
192 | if lookup and lookup(sym): |
|
192 | if lookup and lookup(sym): | |
193 | # looks like a real symbol |
|
193 | # looks like a real symbol | |
194 | yield ('symbol', sym, s) |
|
194 | yield ('symbol', sym, s) | |
195 | else: |
|
195 | else: | |
196 | # looks like an expression |
|
196 | # looks like an expression | |
197 | parts = sym.split('-') |
|
197 | parts = sym.split('-') | |
198 | for p in parts[:-1]: |
|
198 | for p in parts[:-1]: | |
199 | if p: # possible consecutive - |
|
199 | if p: # possible consecutive - | |
200 | yield ('symbol', p, s) |
|
200 | yield ('symbol', p, s) | |
201 | s += len(p) |
|
201 | s += len(p) | |
202 | yield ('-', None, pos) |
|
202 | yield ('-', None, pos) | |
203 | s += 1 |
|
203 | s += 1 | |
204 | if parts[-1]: # possible trailing - |
|
204 | if parts[-1]: # possible trailing - | |
205 | yield ('symbol', parts[-1], s) |
|
205 | yield ('symbol', parts[-1], s) | |
206 | else: |
|
206 | else: | |
207 | yield ('symbol', sym, s) |
|
207 | yield ('symbol', sym, s) | |
208 | pos -= 1 |
|
208 | pos -= 1 | |
209 | else: |
|
209 | else: | |
210 | raise error.ParseError(_("syntax error"), pos) |
|
210 | raise error.ParseError(_("syntax error"), pos) | |
211 | pos += 1 |
|
211 | pos += 1 | |
212 | yield ('end', None, pos) |
|
212 | yield ('end', None, pos) | |
213 |
|
213 | |||
214 | # helpers |
|
214 | # helpers | |
215 |
|
215 | |||
216 | def getstring(x, err): |
|
216 | def getstring(x, err): | |
217 | if x and (x[0] == 'string' or x[0] == 'symbol'): |
|
217 | if x and (x[0] == 'string' or x[0] == 'symbol'): | |
218 | return x[1] |
|
218 | return x[1] | |
219 | raise error.ParseError(err) |
|
219 | raise error.ParseError(err) | |
220 |
|
220 | |||
221 | def getlist(x): |
|
221 | def getlist(x): | |
222 | if not x: |
|
222 | if not x: | |
223 | return [] |
|
223 | return [] | |
224 | if x[0] == 'list': |
|
224 | if x[0] == 'list': | |
225 | return getlist(x[1]) + [x[2]] |
|
225 | return getlist(x[1]) + [x[2]] | |
226 | return [x] |
|
226 | return [x] | |
227 |
|
227 | |||
228 | def getargs(x, min, max, err): |
|
228 | def getargs(x, min, max, err): | |
229 | l = getlist(x) |
|
229 | l = getlist(x) | |
230 | if len(l) < min or (max >= 0 and len(l) > max): |
|
230 | if len(l) < min or (max >= 0 and len(l) > max): | |
231 | raise error.ParseError(err) |
|
231 | raise error.ParseError(err) | |
232 | return l |
|
232 | return l | |
233 |
|
233 | |||
234 | def getset(repo, subset, x): |
|
234 | def getset(repo, subset, x): | |
235 | if not x: |
|
235 | if not x: | |
236 | raise error.ParseError(_("missing argument")) |
|
236 | raise error.ParseError(_("missing argument")) | |
237 | s = methods[x[0]](repo, subset, *x[1:]) |
|
237 | s = methods[x[0]](repo, subset, *x[1:]) | |
238 | if util.safehasattr(s, 'isascending'): |
|
238 | if util.safehasattr(s, 'isascending'): | |
239 | return s |
|
239 | return s | |
240 | return baseset(s) |
|
240 | return baseset(s) | |
241 |
|
241 | |||
242 | def _getrevsource(repo, r): |
|
242 | def _getrevsource(repo, r): | |
243 | extra = repo[r].extra() |
|
243 | extra = repo[r].extra() | |
244 | for label in ('source', 'transplant_source', 'rebase_source'): |
|
244 | for label in ('source', 'transplant_source', 'rebase_source'): | |
245 | if label in extra: |
|
245 | if label in extra: | |
246 | try: |
|
246 | try: | |
247 | return repo[extra[label]].rev() |
|
247 | return repo[extra[label]].rev() | |
248 | except error.RepoLookupError: |
|
248 | except error.RepoLookupError: | |
249 | pass |
|
249 | pass | |
250 | return None |
|
250 | return None | |
251 |
|
251 | |||
252 | # operator methods |
|
252 | # operator methods | |
253 |
|
253 | |||
254 | def stringset(repo, subset, x): |
|
254 | def stringset(repo, subset, x): | |
255 | x = repo[x].rev() |
|
255 | x = repo[x].rev() | |
256 | if x == -1 and len(subset) == len(repo): |
|
256 | if x == -1 and len(subset) == len(repo): | |
257 | return baseset([-1]) |
|
257 | return baseset([-1]) | |
258 | if len(subset) == len(repo) or x in subset: |
|
258 | if len(subset) == len(repo) or x in subset: | |
259 | return baseset([x]) |
|
259 | return baseset([x]) | |
260 | return baseset() |
|
260 | return baseset() | |
261 |
|
261 | |||
262 | def symbolset(repo, subset, x): |
|
262 | def symbolset(repo, subset, x): | |
263 | if x in symbols: |
|
263 | if x in symbols: | |
264 | raise error.ParseError(_("can't use %s here") % x) |
|
264 | raise error.ParseError(_("can't use %s here") % x) | |
265 | return stringset(repo, subset, x) |
|
265 | return stringset(repo, subset, x) | |
266 |
|
266 | |||
267 | def rangeset(repo, subset, x, y): |
|
267 | def rangeset(repo, subset, x, y): | |
268 | cl = baseset(repo.changelog) |
|
268 | cl = baseset(repo.changelog) | |
269 | m = getset(repo, cl, x) |
|
269 | m = getset(repo, cl, x) | |
270 | n = getset(repo, cl, y) |
|
270 | n = getset(repo, cl, y) | |
271 |
|
271 | |||
272 | if not m or not n: |
|
272 | if not m or not n: | |
273 | return baseset() |
|
273 | return baseset() | |
274 | m, n = m.first(), n.last() |
|
274 | m, n = m.first(), n.last() | |
275 |
|
275 | |||
276 | if m < n: |
|
276 | if m < n: | |
277 | r = spanset(repo, m, n + 1) |
|
277 | r = spanset(repo, m, n + 1) | |
278 | else: |
|
278 | else: | |
279 | r = spanset(repo, m, n - 1) |
|
279 | r = spanset(repo, m, n - 1) | |
280 | return r & subset |
|
280 | return r & subset | |
281 |
|
281 | |||
282 | def dagrange(repo, subset, x, y): |
|
282 | def dagrange(repo, subset, x, y): | |
283 | r = spanset(repo) |
|
283 | r = spanset(repo) | |
284 | xs = _revsbetween(repo, getset(repo, r, x), getset(repo, r, y)) |
|
284 | xs = _revsbetween(repo, getset(repo, r, x), getset(repo, r, y)) | |
285 | return xs & subset |
|
285 | return xs & subset | |
286 |
|
286 | |||
287 | def andset(repo, subset, x, y): |
|
287 | def andset(repo, subset, x, y): | |
288 | return getset(repo, getset(repo, subset, x), y) |
|
288 | return getset(repo, getset(repo, subset, x), y) | |
289 |
|
289 | |||
290 | def orset(repo, subset, x, y): |
|
290 | def orset(repo, subset, x, y): | |
291 | xl = getset(repo, subset, x) |
|
291 | xl = getset(repo, subset, x) | |
292 | yl = getset(repo, subset - xl, y) |
|
292 | yl = getset(repo, subset - xl, y) | |
293 | return xl + yl |
|
293 | return xl + yl | |
294 |
|
294 | |||
295 | def notset(repo, subset, x): |
|
295 | def notset(repo, subset, x): | |
296 | return subset - getset(repo, subset, x) |
|
296 | return subset - getset(repo, subset, x) | |
297 |
|
297 | |||
298 | def listset(repo, subset, a, b): |
|
298 | def listset(repo, subset, a, b): | |
299 | raise error.ParseError(_("can't use a list in this context")) |
|
299 | raise error.ParseError(_("can't use a list in this context")) | |
300 |
|
300 | |||
301 | def func(repo, subset, a, b): |
|
301 | def func(repo, subset, a, b): | |
302 | if a[0] == 'symbol' and a[1] in symbols: |
|
302 | if a[0] == 'symbol' and a[1] in symbols: | |
303 | return symbols[a[1]](repo, subset, b) |
|
303 | return symbols[a[1]](repo, subset, b) | |
304 | raise error.ParseError(_("not a function: %s") % a[1]) |
|
304 | raise error.ParseError(_("not a function: %s") % a[1]) | |
305 |
|
305 | |||
306 | # functions |
|
306 | # functions | |
307 |
|
307 | |||
308 | def adds(repo, subset, x): |
|
308 | def adds(repo, subset, x): | |
309 | """``adds(pattern)`` |
|
309 | """``adds(pattern)`` | |
310 | Changesets that add a file matching pattern. |
|
310 | Changesets that add a file matching pattern. | |
311 |
|
311 | |||
312 | The pattern without explicit kind like ``glob:`` is expected to be |
|
312 | The pattern without explicit kind like ``glob:`` is expected to be | |
313 | relative to the current directory and match against a file or a |
|
313 | relative to the current directory and match against a file or a | |
314 | directory. |
|
314 | directory. | |
315 | """ |
|
315 | """ | |
316 | # i18n: "adds" is a keyword |
|
316 | # i18n: "adds" is a keyword | |
317 | pat = getstring(x, _("adds requires a pattern")) |
|
317 | pat = getstring(x, _("adds requires a pattern")) | |
318 | return checkstatus(repo, subset, pat, 1) |
|
318 | return checkstatus(repo, subset, pat, 1) | |
319 |
|
319 | |||
320 | def ancestor(repo, subset, x): |
|
320 | def ancestor(repo, subset, x): | |
321 | """``ancestor(*changeset)`` |
|
321 | """``ancestor(*changeset)`` | |
322 | A greatest common ancestor of the changesets. |
|
322 | A greatest common ancestor of the changesets. | |
323 |
|
323 | |||
324 | Accepts 0 or more changesets. |
|
324 | Accepts 0 or more changesets. | |
325 | Will return empty list when passed no args. |
|
325 | Will return empty list when passed no args. | |
326 | Greatest common ancestor of a single changeset is that changeset. |
|
326 | Greatest common ancestor of a single changeset is that changeset. | |
327 | """ |
|
327 | """ | |
328 | # i18n: "ancestor" is a keyword |
|
328 | # i18n: "ancestor" is a keyword | |
329 | l = getlist(x) |
|
329 | l = getlist(x) | |
330 | rl = spanset(repo) |
|
330 | rl = spanset(repo) | |
331 | anc = None |
|
331 | anc = None | |
332 |
|
332 | |||
333 | # (getset(repo, rl, i) for i in l) generates a list of lists |
|
333 | # (getset(repo, rl, i) for i in l) generates a list of lists | |
334 | for revs in (getset(repo, rl, i) for i in l): |
|
334 | for revs in (getset(repo, rl, i) for i in l): | |
335 | for r in revs: |
|
335 | for r in revs: | |
336 | if anc is None: |
|
336 | if anc is None: | |
337 | anc = repo[r] |
|
337 | anc = repo[r] | |
338 | else: |
|
338 | else: | |
339 | anc = anc.ancestor(repo[r]) |
|
339 | anc = anc.ancestor(repo[r]) | |
340 |
|
340 | |||
341 | if anc is not None and anc.rev() in subset: |
|
341 | if anc is not None and anc.rev() in subset: | |
342 | return baseset([anc.rev()]) |
|
342 | return baseset([anc.rev()]) | |
343 | return baseset() |
|
343 | return baseset() | |
344 |
|
344 | |||
345 | def _ancestors(repo, subset, x, followfirst=False): |
|
345 | def _ancestors(repo, subset, x, followfirst=False): | |
346 | heads = getset(repo, spanset(repo), x) |
|
346 | heads = getset(repo, spanset(repo), x) | |
347 | if not heads: |
|
347 | if not heads: | |
348 | return baseset() |
|
348 | return baseset() | |
349 | s = _revancestors(repo, heads, followfirst) |
|
349 | s = _revancestors(repo, heads, followfirst) | |
350 | return subset & s |
|
350 | return subset & s | |
351 |
|
351 | |||
352 | def ancestors(repo, subset, x): |
|
352 | def ancestors(repo, subset, x): | |
353 | """``ancestors(set)`` |
|
353 | """``ancestors(set)`` | |
354 | Changesets that are ancestors of a changeset in set. |
|
354 | Changesets that are ancestors of a changeset in set. | |
355 | """ |
|
355 | """ | |
356 | return _ancestors(repo, subset, x) |
|
356 | return _ancestors(repo, subset, x) | |
357 |
|
357 | |||
358 | def _firstancestors(repo, subset, x): |
|
358 | def _firstancestors(repo, subset, x): | |
359 | # ``_firstancestors(set)`` |
|
359 | # ``_firstancestors(set)`` | |
360 | # Like ``ancestors(set)`` but follows only the first parents. |
|
360 | # Like ``ancestors(set)`` but follows only the first parents. | |
361 | return _ancestors(repo, subset, x, followfirst=True) |
|
361 | return _ancestors(repo, subset, x, followfirst=True) | |
362 |
|
362 | |||
363 | def ancestorspec(repo, subset, x, n): |
|
363 | def ancestorspec(repo, subset, x, n): | |
364 | """``set~n`` |
|
364 | """``set~n`` | |
365 | Changesets that are the Nth ancestor (first parents only) of a changeset |
|
365 | Changesets that are the Nth ancestor (first parents only) of a changeset | |
366 | in set. |
|
366 | in set. | |
367 | """ |
|
367 | """ | |
368 | try: |
|
368 | try: | |
369 | n = int(n[1]) |
|
369 | n = int(n[1]) | |
370 | except (TypeError, ValueError): |
|
370 | except (TypeError, ValueError): | |
371 | raise error.ParseError(_("~ expects a number")) |
|
371 | raise error.ParseError(_("~ expects a number")) | |
372 | ps = set() |
|
372 | ps = set() | |
373 | cl = repo.changelog |
|
373 | cl = repo.changelog | |
374 | for r in getset(repo, baseset(cl), x): |
|
374 | for r in getset(repo, baseset(cl), x): | |
375 | for i in range(n): |
|
375 | for i in range(n): | |
376 | r = cl.parentrevs(r)[0] |
|
376 | r = cl.parentrevs(r)[0] | |
377 | ps.add(r) |
|
377 | ps.add(r) | |
378 | return subset & ps |
|
378 | return subset & ps | |
379 |
|
379 | |||
380 | def author(repo, subset, x): |
|
380 | def author(repo, subset, x): | |
381 | """``author(string)`` |
|
381 | """``author(string)`` | |
382 | Alias for ``user(string)``. |
|
382 | Alias for ``user(string)``. | |
383 | """ |
|
383 | """ | |
384 | # i18n: "author" is a keyword |
|
384 | # i18n: "author" is a keyword | |
385 | n = encoding.lower(getstring(x, _("author requires a string"))) |
|
385 | n = encoding.lower(getstring(x, _("author requires a string"))) | |
386 | kind, pattern, matcher = _substringmatcher(n) |
|
386 | kind, pattern, matcher = _substringmatcher(n) | |
387 | return subset.filter(lambda x: matcher(encoding.lower(repo[x].user()))) |
|
387 | return subset.filter(lambda x: matcher(encoding.lower(repo[x].user()))) | |
388 |
|
388 | |||
389 | def only(repo, subset, x): |
|
389 | def only(repo, subset, x): | |
390 | """``only(set, [set])`` |
|
390 | """``only(set, [set])`` | |
391 | Changesets that are ancestors of the first set that are not ancestors |
|
391 | Changesets that are ancestors of the first set that are not ancestors | |
392 | of any other head in the repo. If a second set is specified, the result |
|
392 | of any other head in the repo. If a second set is specified, the result | |
393 | is ancestors of the first set that are not ancestors of the second set |
|
393 | is ancestors of the first set that are not ancestors of the second set | |
394 | (i.e. ::<set1> - ::<set2>). |
|
394 | (i.e. ::<set1> - ::<set2>). | |
395 | """ |
|
395 | """ | |
396 | cl = repo.changelog |
|
396 | cl = repo.changelog | |
397 | # i18n: "only" is a keyword |
|
397 | # i18n: "only" is a keyword | |
398 | args = getargs(x, 1, 2, _('only takes one or two arguments')) |
|
398 | args = getargs(x, 1, 2, _('only takes one or two arguments')) | |
399 | include = getset(repo, spanset(repo), args[0]) |
|
399 | include = getset(repo, spanset(repo), args[0]) | |
400 | if len(args) == 1: |
|
400 | if len(args) == 1: | |
401 | if not include: |
|
401 | if not include: | |
402 | return baseset() |
|
402 | return baseset() | |
403 |
|
403 | |||
404 | descendants = set(_revdescendants(repo, include, False)) |
|
404 | descendants = set(_revdescendants(repo, include, False)) | |
405 | exclude = [rev for rev in cl.headrevs() |
|
405 | exclude = [rev for rev in cl.headrevs() | |
406 | if not rev in descendants and not rev in include] |
|
406 | if not rev in descendants and not rev in include] | |
407 | else: |
|
407 | else: | |
408 | exclude = getset(repo, spanset(repo), args[1]) |
|
408 | exclude = getset(repo, spanset(repo), args[1]) | |
409 |
|
409 | |||
410 | results = set(ancestormod.missingancestors(include, exclude, cl.parentrevs)) |
|
410 | results = set(ancestormod.missingancestors(include, exclude, cl.parentrevs)) | |
411 | return subset & results |
|
411 | return subset & results | |
412 |
|
412 | |||
413 | def bisect(repo, subset, x): |
|
413 | def bisect(repo, subset, x): | |
414 | """``bisect(string)`` |
|
414 | """``bisect(string)`` | |
415 | Changesets marked in the specified bisect status: |
|
415 | Changesets marked in the specified bisect status: | |
416 |
|
416 | |||
417 | - ``good``, ``bad``, ``skip``: csets explicitly marked as good/bad/skip |
|
417 | - ``good``, ``bad``, ``skip``: csets explicitly marked as good/bad/skip | |
418 | - ``goods``, ``bads`` : csets topologically good/bad |
|
418 | - ``goods``, ``bads`` : csets topologically good/bad | |
419 | - ``range`` : csets taking part in the bisection |
|
419 | - ``range`` : csets taking part in the bisection | |
420 | - ``pruned`` : csets that are goods, bads or skipped |
|
420 | - ``pruned`` : csets that are goods, bads or skipped | |
421 | - ``untested`` : csets whose fate is yet unknown |
|
421 | - ``untested`` : csets whose fate is yet unknown | |
422 | - ``ignored`` : csets ignored due to DAG topology |
|
422 | - ``ignored`` : csets ignored due to DAG topology | |
423 | - ``current`` : the cset currently being bisected |
|
423 | - ``current`` : the cset currently being bisected | |
424 | """ |
|
424 | """ | |
425 | # i18n: "bisect" is a keyword |
|
425 | # i18n: "bisect" is a keyword | |
426 | status = getstring(x, _("bisect requires a string")).lower() |
|
426 | status = getstring(x, _("bisect requires a string")).lower() | |
427 | state = set(hbisect.get(repo, status)) |
|
427 | state = set(hbisect.get(repo, status)) | |
428 | return subset & state |
|
428 | return subset & state | |
429 |
|
429 | |||
430 | # Backward-compatibility |
|
430 | # Backward-compatibility | |
431 | # - no help entry so that we do not advertise it any more |
|
431 | # - no help entry so that we do not advertise it any more | |
432 | def bisected(repo, subset, x): |
|
432 | def bisected(repo, subset, x): | |
433 | return bisect(repo, subset, x) |
|
433 | return bisect(repo, subset, x) | |
434 |
|
434 | |||
435 | def bookmark(repo, subset, x): |
|
435 | def bookmark(repo, subset, x): | |
436 | """``bookmark([name])`` |
|
436 | """``bookmark([name])`` | |
437 | The named bookmark or all bookmarks. |
|
437 | The named bookmark or all bookmarks. | |
438 |
|
438 | |||
439 | If `name` starts with `re:`, the remainder of the name is treated as |
|
439 | If `name` starts with `re:`, the remainder of the name is treated as | |
440 | a regular expression. To match a bookmark that actually starts with `re:`, |
|
440 | a regular expression. To match a bookmark that actually starts with `re:`, | |
441 | use the prefix `literal:`. |
|
441 | use the prefix `literal:`. | |
442 | """ |
|
442 | """ | |
443 | # i18n: "bookmark" is a keyword |
|
443 | # i18n: "bookmark" is a keyword | |
444 | args = getargs(x, 0, 1, _('bookmark takes one or no arguments')) |
|
444 | args = getargs(x, 0, 1, _('bookmark takes one or no arguments')) | |
445 | if args: |
|
445 | if args: | |
446 | bm = getstring(args[0], |
|
446 | bm = getstring(args[0], | |
447 | # i18n: "bookmark" is a keyword |
|
447 | # i18n: "bookmark" is a keyword | |
448 | _('the argument to bookmark must be a string')) |
|
448 | _('the argument to bookmark must be a string')) | |
449 | kind, pattern, matcher = _stringmatcher(bm) |
|
449 | kind, pattern, matcher = _stringmatcher(bm) | |
450 | bms = set() |
|
450 | bms = set() | |
451 | if kind == 'literal': |
|
451 | if kind == 'literal': | |
452 | bmrev = repo._bookmarks.get(pattern, None) |
|
452 | bmrev = repo._bookmarks.get(pattern, None) | |
453 | if not bmrev: |
|
453 | if not bmrev: | |
454 | raise util.Abort(_("bookmark '%s' does not exist") % bm) |
|
454 | raise util.Abort(_("bookmark '%s' does not exist") % bm) | |
455 | bms.add(repo[bmrev].rev()) |
|
455 | bms.add(repo[bmrev].rev()) | |
456 | else: |
|
456 | else: | |
457 | matchrevs = set() |
|
457 | matchrevs = set() | |
458 | for name, bmrev in repo._bookmarks.iteritems(): |
|
458 | for name, bmrev in repo._bookmarks.iteritems(): | |
459 | if matcher(name): |
|
459 | if matcher(name): | |
460 | matchrevs.add(bmrev) |
|
460 | matchrevs.add(bmrev) | |
461 | if not matchrevs: |
|
461 | if not matchrevs: | |
462 | raise util.Abort(_("no bookmarks exist that match '%s'") |
|
462 | raise util.Abort(_("no bookmarks exist that match '%s'") | |
463 | % pattern) |
|
463 | % pattern) | |
464 | for bmrev in matchrevs: |
|
464 | for bmrev in matchrevs: | |
465 | bms.add(repo[bmrev].rev()) |
|
465 | bms.add(repo[bmrev].rev()) | |
466 | else: |
|
466 | else: | |
467 | bms = set([repo[r].rev() |
|
467 | bms = set([repo[r].rev() | |
468 | for r in repo._bookmarks.values()]) |
|
468 | for r in repo._bookmarks.values()]) | |
469 | bms -= set([node.nullrev]) |
|
469 | bms -= set([node.nullrev]) | |
470 | return subset & bms |
|
470 | return subset & bms | |
471 |
|
471 | |||
472 | def branch(repo, subset, x): |
|
472 | def branch(repo, subset, x): | |
473 | """``branch(string or set)`` |
|
473 | """``branch(string or set)`` | |
474 | All changesets belonging to the given branch or the branches of the given |
|
474 | All changesets belonging to the given branch or the branches of the given | |
475 | changesets. |
|
475 | changesets. | |
476 |
|
476 | |||
477 | If `string` starts with `re:`, the remainder of the name is treated as |
|
477 | If `string` starts with `re:`, the remainder of the name is treated as | |
478 | a regular expression. To match a branch that actually starts with `re:`, |
|
478 | a regular expression. To match a branch that actually starts with `re:`, | |
479 | use the prefix `literal:`. |
|
479 | use the prefix `literal:`. | |
480 | """ |
|
480 | """ | |
481 | try: |
|
481 | try: | |
482 | b = getstring(x, '') |
|
482 | b = getstring(x, '') | |
483 | except error.ParseError: |
|
483 | except error.ParseError: | |
484 | # not a string, but another revspec, e.g. tip() |
|
484 | # not a string, but another revspec, e.g. tip() | |
485 | pass |
|
485 | pass | |
486 | else: |
|
486 | else: | |
487 | kind, pattern, matcher = _stringmatcher(b) |
|
487 | kind, pattern, matcher = _stringmatcher(b) | |
488 | if kind == 'literal': |
|
488 | if kind == 'literal': | |
489 | # note: falls through to the revspec case if no branch with |
|
489 | # note: falls through to the revspec case if no branch with | |
490 | # this name exists |
|
490 | # this name exists | |
491 | if pattern in repo.branchmap(): |
|
491 | if pattern in repo.branchmap(): | |
492 | return subset.filter(lambda r: matcher(repo[r].branch())) |
|
492 | return subset.filter(lambda r: matcher(repo[r].branch())) | |
493 | else: |
|
493 | else: | |
494 | return subset.filter(lambda r: matcher(repo[r].branch())) |
|
494 | return subset.filter(lambda r: matcher(repo[r].branch())) | |
495 |
|
495 | |||
496 | s = getset(repo, spanset(repo), x) |
|
496 | s = getset(repo, spanset(repo), x) | |
497 | b = set() |
|
497 | b = set() | |
498 | for r in s: |
|
498 | for r in s: | |
499 | b.add(repo[r].branch()) |
|
499 | b.add(repo[r].branch()) | |
500 | c = s.__contains__ |
|
500 | c = s.__contains__ | |
501 | return subset.filter(lambda r: c(r) or repo[r].branch() in b) |
|
501 | return subset.filter(lambda r: c(r) or repo[r].branch() in b) | |
502 |
|
502 | |||
503 | def bumped(repo, subset, x): |
|
503 | def bumped(repo, subset, x): | |
504 | """``bumped()`` |
|
504 | """``bumped()`` | |
505 | Mutable changesets marked as successors of public changesets. |
|
505 | Mutable changesets marked as successors of public changesets. | |
506 |
|
506 | |||
507 | Only non-public and non-obsolete changesets can be `bumped`. |
|
507 | Only non-public and non-obsolete changesets can be `bumped`. | |
508 | """ |
|
508 | """ | |
509 | # i18n: "bumped" is a keyword |
|
509 | # i18n: "bumped" is a keyword | |
510 | getargs(x, 0, 0, _("bumped takes no arguments")) |
|
510 | getargs(x, 0, 0, _("bumped takes no arguments")) | |
511 | bumped = obsmod.getrevs(repo, 'bumped') |
|
511 | bumped = obsmod.getrevs(repo, 'bumped') | |
512 | return subset & bumped |
|
512 | return subset & bumped | |
513 |
|
513 | |||
514 | def bundle(repo, subset, x): |
|
514 | def bundle(repo, subset, x): | |
515 | """``bundle()`` |
|
515 | """``bundle()`` | |
516 | Changesets in the bundle. |
|
516 | Changesets in the bundle. | |
517 |
|
517 | |||
518 | Bundle must be specified by the -R option.""" |
|
518 | Bundle must be specified by the -R option.""" | |
519 |
|
519 | |||
520 | try: |
|
520 | try: | |
521 | bundlerevs = repo.changelog.bundlerevs |
|
521 | bundlerevs = repo.changelog.bundlerevs | |
522 | except AttributeError: |
|
522 | except AttributeError: | |
523 | raise util.Abort(_("no bundle provided - specify with -R")) |
|
523 | raise util.Abort(_("no bundle provided - specify with -R")) | |
524 | return subset & bundlerevs |
|
524 | return subset & bundlerevs | |
525 |
|
525 | |||
526 | def checkstatus(repo, subset, pat, field): |
|
526 | def checkstatus(repo, subset, pat, field): | |
527 | hasset = matchmod.patkind(pat) == 'set' |
|
527 | hasset = matchmod.patkind(pat) == 'set' | |
528 |
|
528 | |||
529 | def matches(x): |
|
529 | def matches(x): | |
530 | m = None |
|
530 | m = None | |
531 | fname = None |
|
531 | fname = None | |
532 | c = repo[x] |
|
532 | c = repo[x] | |
533 | if not m or hasset: |
|
533 | if not m or hasset: | |
534 | m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c) |
|
534 | m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c) | |
535 | if not m.anypats() and len(m.files()) == 1: |
|
535 | if not m.anypats() and len(m.files()) == 1: | |
536 | fname = m.files()[0] |
|
536 | fname = m.files()[0] | |
537 | if fname is not None: |
|
537 | if fname is not None: | |
538 | if fname not in c.files(): |
|
538 | if fname not in c.files(): | |
539 | return False |
|
539 | return False | |
540 | else: |
|
540 | else: | |
541 | for f in c.files(): |
|
541 | for f in c.files(): | |
542 | if m(f): |
|
542 | if m(f): | |
543 | break |
|
543 | break | |
544 | else: |
|
544 | else: | |
545 | return False |
|
545 | return False | |
546 | files = repo.status(c.p1().node(), c.node())[field] |
|
546 | files = repo.status(c.p1().node(), c.node())[field] | |
547 | if fname is not None: |
|
547 | if fname is not None: | |
548 | if fname in files: |
|
548 | if fname in files: | |
549 | return True |
|
549 | return True | |
550 | else: |
|
550 | else: | |
551 | for f in files: |
|
551 | for f in files: | |
552 | if m(f): |
|
552 | if m(f): | |
553 | return True |
|
553 | return True | |
554 |
|
554 | |||
555 | return subset.filter(matches) |
|
555 | return subset.filter(matches) | |
556 |
|
556 | |||
557 | def _children(repo, narrow, parentset): |
|
557 | def _children(repo, narrow, parentset): | |
558 | cs = set() |
|
558 | cs = set() | |
559 | if not parentset: |
|
559 | if not parentset: | |
560 | return baseset(cs) |
|
560 | return baseset(cs) | |
561 | pr = repo.changelog.parentrevs |
|
561 | pr = repo.changelog.parentrevs | |
562 | minrev = min(parentset) |
|
562 | minrev = min(parentset) | |
563 | for r in narrow: |
|
563 | for r in narrow: | |
564 | if r <= minrev: |
|
564 | if r <= minrev: | |
565 | continue |
|
565 | continue | |
566 | for p in pr(r): |
|
566 | for p in pr(r): | |
567 | if p in parentset: |
|
567 | if p in parentset: | |
568 | cs.add(r) |
|
568 | cs.add(r) | |
569 | return baseset(cs) |
|
569 | return baseset(cs) | |
570 |
|
570 | |||
571 | def children(repo, subset, x): |
|
571 | def children(repo, subset, x): | |
572 | """``children(set)`` |
|
572 | """``children(set)`` | |
573 | Child changesets of changesets in set. |
|
573 | Child changesets of changesets in set. | |
574 | """ |
|
574 | """ | |
575 | s = getset(repo, baseset(repo), x) |
|
575 | s = getset(repo, baseset(repo), x) | |
576 | cs = _children(repo, subset, s) |
|
576 | cs = _children(repo, subset, s) | |
577 | return subset & cs |
|
577 | return subset & cs | |
578 |
|
578 | |||
579 | def closed(repo, subset, x): |
|
579 | def closed(repo, subset, x): | |
580 | """``closed()`` |
|
580 | """``closed()`` | |
581 | Changeset is closed. |
|
581 | Changeset is closed. | |
582 | """ |
|
582 | """ | |
583 | # i18n: "closed" is a keyword |
|
583 | # i18n: "closed" is a keyword | |
584 | getargs(x, 0, 0, _("closed takes no arguments")) |
|
584 | getargs(x, 0, 0, _("closed takes no arguments")) | |
585 | return subset.filter(lambda r: repo[r].closesbranch()) |
|
585 | return subset.filter(lambda r: repo[r].closesbranch()) | |
586 |
|
586 | |||
587 | def contains(repo, subset, x): |
|
587 | def contains(repo, subset, x): | |
588 | """``contains(pattern)`` |
|
588 | """``contains(pattern)`` | |
589 | The revision's manifest contains a file matching pattern (but might not |
|
589 | The revision's manifest contains a file matching pattern (but might not | |
590 | modify it). See :hg:`help patterns` for information about file patterns. |
|
590 | modify it). See :hg:`help patterns` for information about file patterns. | |
591 |
|
591 | |||
592 | The pattern without explicit kind like ``glob:`` is expected to be |
|
592 | The pattern without explicit kind like ``glob:`` is expected to be | |
593 | relative to the current directory and match against a file exactly |
|
593 | relative to the current directory and match against a file exactly | |
594 | for efficiency. |
|
594 | for efficiency. | |
595 | """ |
|
595 | """ | |
596 | # i18n: "contains" is a keyword |
|
596 | # i18n: "contains" is a keyword | |
597 | pat = getstring(x, _("contains requires a pattern")) |
|
597 | pat = getstring(x, _("contains requires a pattern")) | |
598 |
|
598 | |||
599 | def matches(x): |
|
599 | def matches(x): | |
600 | if not matchmod.patkind(pat): |
|
600 | if not matchmod.patkind(pat): | |
601 | pats = pathutil.canonpath(repo.root, repo.getcwd(), pat) |
|
601 | pats = pathutil.canonpath(repo.root, repo.getcwd(), pat) | |
602 | if pats in repo[x]: |
|
602 | if pats in repo[x]: | |
603 | return True |
|
603 | return True | |
604 | else: |
|
604 | else: | |
605 | c = repo[x] |
|
605 | c = repo[x] | |
606 | m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c) |
|
606 | m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c) | |
607 | for f in c.manifest(): |
|
607 | for f in c.manifest(): | |
608 | if m(f): |
|
608 | if m(f): | |
609 | return True |
|
609 | return True | |
610 | return False |
|
610 | return False | |
611 |
|
611 | |||
612 | return subset.filter(matches) |
|
612 | return subset.filter(matches) | |
613 |
|
613 | |||
614 | def converted(repo, subset, x): |
|
614 | def converted(repo, subset, x): | |
615 | """``converted([id])`` |
|
615 | """``converted([id])`` | |
616 | Changesets converted from the given identifier in the old repository if |
|
616 | Changesets converted from the given identifier in the old repository if | |
617 | present, or all converted changesets if no identifier is specified. |
|
617 | present, or all converted changesets if no identifier is specified. | |
618 | """ |
|
618 | """ | |
619 |
|
619 | |||
620 | # There is exactly no chance of resolving the revision, so do a simple |
|
620 | # There is exactly no chance of resolving the revision, so do a simple | |
621 | # string compare and hope for the best |
|
621 | # string compare and hope for the best | |
622 |
|
622 | |||
623 | rev = None |
|
623 | rev = None | |
624 | # i18n: "converted" is a keyword |
|
624 | # i18n: "converted" is a keyword | |
625 | l = getargs(x, 0, 1, _('converted takes one or no arguments')) |
|
625 | l = getargs(x, 0, 1, _('converted takes one or no arguments')) | |
626 | if l: |
|
626 | if l: | |
627 | # i18n: "converted" is a keyword |
|
627 | # i18n: "converted" is a keyword | |
628 | rev = getstring(l[0], _('converted requires a revision')) |
|
628 | rev = getstring(l[0], _('converted requires a revision')) | |
629 |
|
629 | |||
630 | def _matchvalue(r): |
|
630 | def _matchvalue(r): | |
631 | source = repo[r].extra().get('convert_revision', None) |
|
631 | source = repo[r].extra().get('convert_revision', None) | |
632 | return source is not None and (rev is None or source.startswith(rev)) |
|
632 | return source is not None and (rev is None or source.startswith(rev)) | |
633 |
|
633 | |||
634 | return subset.filter(lambda r: _matchvalue(r)) |
|
634 | return subset.filter(lambda r: _matchvalue(r)) | |
635 |
|
635 | |||
636 | def date(repo, subset, x): |
|
636 | def date(repo, subset, x): | |
637 | """``date(interval)`` |
|
637 | """``date(interval)`` | |
638 | Changesets within the interval, see :hg:`help dates`. |
|
638 | Changesets within the interval, see :hg:`help dates`. | |
639 | """ |
|
639 | """ | |
640 | # i18n: "date" is a keyword |
|
640 | # i18n: "date" is a keyword | |
641 | ds = getstring(x, _("date requires a string")) |
|
641 | ds = getstring(x, _("date requires a string")) | |
642 | dm = util.matchdate(ds) |
|
642 | dm = util.matchdate(ds) | |
643 | return subset.filter(lambda x: dm(repo[x].date()[0])) |
|
643 | return subset.filter(lambda x: dm(repo[x].date()[0])) | |
644 |
|
644 | |||
645 | def desc(repo, subset, x): |
|
645 | def desc(repo, subset, x): | |
646 | """``desc(string)`` |
|
646 | """``desc(string)`` | |
647 | Search commit message for string. The match is case-insensitive. |
|
647 | Search commit message for string. The match is case-insensitive. | |
648 | """ |
|
648 | """ | |
649 | # i18n: "desc" is a keyword |
|
649 | # i18n: "desc" is a keyword | |
650 | ds = encoding.lower(getstring(x, _("desc requires a string"))) |
|
650 | ds = encoding.lower(getstring(x, _("desc requires a string"))) | |
651 |
|
651 | |||
652 | def matches(x): |
|
652 | def matches(x): | |
653 | c = repo[x] |
|
653 | c = repo[x] | |
654 | return ds in encoding.lower(c.description()) |
|
654 | return ds in encoding.lower(c.description()) | |
655 |
|
655 | |||
656 | return subset.filter(matches) |
|
656 | return subset.filter(matches) | |
657 |
|
657 | |||
658 | def _descendants(repo, subset, x, followfirst=False): |
|
658 | def _descendants(repo, subset, x, followfirst=False): | |
659 | roots = getset(repo, spanset(repo), x) |
|
659 | roots = getset(repo, spanset(repo), x) | |
660 | if not roots: |
|
660 | if not roots: | |
661 | return baseset() |
|
661 | return baseset() | |
662 | s = _revdescendants(repo, roots, followfirst) |
|
662 | s = _revdescendants(repo, roots, followfirst) | |
663 |
|
663 | |||
664 | # Both sets need to be ascending in order to lazily return the union |
|
664 | # Both sets need to be ascending in order to lazily return the union | |
665 | # in the correct order. |
|
665 | # in the correct order. | |
666 | base = subset & roots |
|
666 | base = subset & roots | |
667 | desc = subset & s |
|
667 | desc = subset & s | |
668 | result = base + desc |
|
668 | result = base + desc | |
669 | if subset.isascending(): |
|
669 | if subset.isascending(): | |
670 | result.sort() |
|
670 | result.sort() | |
671 | elif subset.isdescending(): |
|
671 | elif subset.isdescending(): | |
672 | result.sort(reverse=True) |
|
672 | result.sort(reverse=True) | |
673 | else: |
|
673 | else: | |
674 | result = subset & result |
|
674 | result = subset & result | |
675 | return result |
|
675 | return result | |
676 |
|
676 | |||
677 | def descendants(repo, subset, x): |
|
677 | def descendants(repo, subset, x): | |
678 | """``descendants(set)`` |
|
678 | """``descendants(set)`` | |
679 | Changesets which are descendants of changesets in set. |
|
679 | Changesets which are descendants of changesets in set. | |
680 | """ |
|
680 | """ | |
681 | return _descendants(repo, subset, x) |
|
681 | return _descendants(repo, subset, x) | |
682 |
|
682 | |||
683 | def _firstdescendants(repo, subset, x): |
|
683 | def _firstdescendants(repo, subset, x): | |
684 | # ``_firstdescendants(set)`` |
|
684 | # ``_firstdescendants(set)`` | |
685 | # Like ``descendants(set)`` but follows only the first parents. |
|
685 | # Like ``descendants(set)`` but follows only the first parents. | |
686 | return _descendants(repo, subset, x, followfirst=True) |
|
686 | return _descendants(repo, subset, x, followfirst=True) | |
687 |
|
687 | |||
688 | def destination(repo, subset, x): |
|
688 | def destination(repo, subset, x): | |
689 | """``destination([set])`` |
|
689 | """``destination([set])`` | |
690 | Changesets that were created by a graft, transplant or rebase operation, |
|
690 | Changesets that were created by a graft, transplant or rebase operation, | |
691 | with the given revisions specified as the source. Omitting the optional set |
|
691 | with the given revisions specified as the source. Omitting the optional set | |
692 | is the same as passing all(). |
|
692 | is the same as passing all(). | |
693 | """ |
|
693 | """ | |
694 | if x is not None: |
|
694 | if x is not None: | |
695 | sources = getset(repo, spanset(repo), x) |
|
695 | sources = getset(repo, spanset(repo), x) | |
696 | else: |
|
696 | else: | |
697 | sources = getall(repo, spanset(repo), x) |
|
697 | sources = getall(repo, spanset(repo), x) | |
698 |
|
698 | |||
699 | dests = set() |
|
699 | dests = set() | |
700 |
|
700 | |||
701 | # subset contains all of the possible destinations that can be returned, so |
|
701 | # subset contains all of the possible destinations that can be returned, so | |
702 | # iterate over them and see if their source(s) were provided in the arg set. |
|
702 | # iterate over them and see if their source(s) were provided in the arg set. | |
703 | # Even if the immediate src of r is not in the arg set, src's source (or |
|
703 | # Even if the immediate src of r is not in the arg set, src's source (or | |
704 | # further back) may be. Scanning back further than the immediate src allows |
|
704 | # further back) may be. Scanning back further than the immediate src allows | |
705 | # transitive transplants and rebases to yield the same results as transitive |
|
705 | # transitive transplants and rebases to yield the same results as transitive | |
706 | # grafts. |
|
706 | # grafts. | |
707 | for r in subset: |
|
707 | for r in subset: | |
708 | src = _getrevsource(repo, r) |
|
708 | src = _getrevsource(repo, r) | |
709 | lineage = None |
|
709 | lineage = None | |
710 |
|
710 | |||
711 | while src is not None: |
|
711 | while src is not None: | |
712 | if lineage is None: |
|
712 | if lineage is None: | |
713 | lineage = list() |
|
713 | lineage = list() | |
714 |
|
714 | |||
715 | lineage.append(r) |
|
715 | lineage.append(r) | |
716 |
|
716 | |||
717 | # The visited lineage is a match if the current source is in the arg |
|
717 | # The visited lineage is a match if the current source is in the arg | |
718 | # set. Since every candidate dest is visited by way of iterating |
|
718 | # set. Since every candidate dest is visited by way of iterating | |
719 | # subset, any dests further back in the lineage will be tested by a |
|
719 | # subset, any dests further back in the lineage will be tested by a | |
720 | # different iteration over subset. Likewise, if the src was already |
|
720 | # different iteration over subset. Likewise, if the src was already | |
721 | # selected, the current lineage can be selected without going back |
|
721 | # selected, the current lineage can be selected without going back | |
722 | # further. |
|
722 | # further. | |
723 | if src in sources or src in dests: |
|
723 | if src in sources or src in dests: | |
724 | dests.update(lineage) |
|
724 | dests.update(lineage) | |
725 | break |
|
725 | break | |
726 |
|
726 | |||
727 | r = src |
|
727 | r = src | |
728 | src = _getrevsource(repo, r) |
|
728 | src = _getrevsource(repo, r) | |
729 |
|
729 | |||
730 | return subset.filter(dests.__contains__) |
|
730 | return subset.filter(dests.__contains__) | |
731 |
|
731 | |||
732 | def divergent(repo, subset, x): |
|
732 | def divergent(repo, subset, x): | |
733 | """``divergent()`` |
|
733 | """``divergent()`` | |
734 | Final successors of changesets with an alternative set of final successors. |
|
734 | Final successors of changesets with an alternative set of final successors. | |
735 | """ |
|
735 | """ | |
736 | # i18n: "divergent" is a keyword |
|
736 | # i18n: "divergent" is a keyword | |
737 | getargs(x, 0, 0, _("divergent takes no arguments")) |
|
737 | getargs(x, 0, 0, _("divergent takes no arguments")) | |
738 | divergent = obsmod.getrevs(repo, 'divergent') |
|
738 | divergent = obsmod.getrevs(repo, 'divergent') | |
739 | return subset & divergent |
|
739 | return subset & divergent | |
740 |
|
740 | |||
741 | def draft(repo, subset, x): |
|
741 | def draft(repo, subset, x): | |
742 | """``draft()`` |
|
742 | """``draft()`` | |
743 | Changeset in draft phase.""" |
|
743 | Changeset in draft phase.""" | |
744 | # i18n: "draft" is a keyword |
|
744 | # i18n: "draft" is a keyword | |
745 | getargs(x, 0, 0, _("draft takes no arguments")) |
|
745 | getargs(x, 0, 0, _("draft takes no arguments")) | |
746 | phase = repo._phasecache.phase |
|
746 | phase = repo._phasecache.phase | |
747 | target = phases.draft |
|
747 | target = phases.draft | |
748 | condition = lambda r: phase(repo, r) == target |
|
748 | condition = lambda r: phase(repo, r) == target | |
749 | return subset.filter(condition, cache=False) |
|
749 | return subset.filter(condition, cache=False) | |
750 |
|
750 | |||
751 | def extinct(repo, subset, x): |
|
751 | def extinct(repo, subset, x): | |
752 | """``extinct()`` |
|
752 | """``extinct()`` | |
753 | Obsolete changesets with obsolete descendants only. |
|
753 | Obsolete changesets with obsolete descendants only. | |
754 | """ |
|
754 | """ | |
755 | # i18n: "extinct" is a keyword |
|
755 | # i18n: "extinct" is a keyword | |
756 | getargs(x, 0, 0, _("extinct takes no arguments")) |
|
756 | getargs(x, 0, 0, _("extinct takes no arguments")) | |
757 | extincts = obsmod.getrevs(repo, 'extinct') |
|
757 | extincts = obsmod.getrevs(repo, 'extinct') | |
758 | return subset & extincts |
|
758 | return subset & extincts | |
759 |
|
759 | |||
760 | def extra(repo, subset, x): |
|
760 | def extra(repo, subset, x): | |
761 | """``extra(label, [value])`` |
|
761 | """``extra(label, [value])`` | |
762 | Changesets with the given label in the extra metadata, with the given |
|
762 | Changesets with the given label in the extra metadata, with the given | |
763 | optional value. |
|
763 | optional value. | |
764 |
|
764 | |||
765 | If `value` starts with `re:`, the remainder of the value is treated as |
|
765 | If `value` starts with `re:`, the remainder of the value is treated as | |
766 | a regular expression. To match a value that actually starts with `re:`, |
|
766 | a regular expression. To match a value that actually starts with `re:`, | |
767 | use the prefix `literal:`. |
|
767 | use the prefix `literal:`. | |
768 | """ |
|
768 | """ | |
769 |
|
769 | |||
770 | # i18n: "extra" is a keyword |
|
770 | # i18n: "extra" is a keyword | |
771 | l = getargs(x, 1, 2, _('extra takes at least 1 and at most 2 arguments')) |
|
771 | l = getargs(x, 1, 2, _('extra takes at least 1 and at most 2 arguments')) | |
772 | # i18n: "extra" is a keyword |
|
772 | # i18n: "extra" is a keyword | |
773 | label = getstring(l[0], _('first argument to extra must be a string')) |
|
773 | label = getstring(l[0], _('first argument to extra must be a string')) | |
774 | value = None |
|
774 | value = None | |
775 |
|
775 | |||
776 | if len(l) > 1: |
|
776 | if len(l) > 1: | |
777 | # i18n: "extra" is a keyword |
|
777 | # i18n: "extra" is a keyword | |
778 | value = getstring(l[1], _('second argument to extra must be a string')) |
|
778 | value = getstring(l[1], _('second argument to extra must be a string')) | |
779 | kind, value, matcher = _stringmatcher(value) |
|
779 | kind, value, matcher = _stringmatcher(value) | |
780 |
|
780 | |||
781 | def _matchvalue(r): |
|
781 | def _matchvalue(r): | |
782 | extra = repo[r].extra() |
|
782 | extra = repo[r].extra() | |
783 | return label in extra and (value is None or matcher(extra[label])) |
|
783 | return label in extra and (value is None or matcher(extra[label])) | |
784 |
|
784 | |||
785 | return subset.filter(lambda r: _matchvalue(r)) |
|
785 | return subset.filter(lambda r: _matchvalue(r)) | |
786 |
|
786 | |||
787 | def filelog(repo, subset, x): |
|
787 | def filelog(repo, subset, x): | |
788 | """``filelog(pattern)`` |
|
788 | """``filelog(pattern)`` | |
789 | Changesets connected to the specified filelog. |
|
789 | Changesets connected to the specified filelog. | |
790 |
|
790 | |||
791 | For performance reasons, visits only revisions mentioned in the file-level |
|
791 | For performance reasons, visits only revisions mentioned in the file-level | |
792 | filelog, rather than filtering through all changesets (much faster, but |
|
792 | filelog, rather than filtering through all changesets (much faster, but | |
793 | doesn't include deletes or duplicate changes). For a slower, more accurate |
|
793 | doesn't include deletes or duplicate changes). For a slower, more accurate | |
794 | result, use ``file()``. |
|
794 | result, use ``file()``. | |
795 |
|
795 | |||
796 | The pattern without explicit kind like ``glob:`` is expected to be |
|
796 | The pattern without explicit kind like ``glob:`` is expected to be | |
797 | relative to the current directory and match against a file exactly |
|
797 | relative to the current directory and match against a file exactly | |
798 | for efficiency. |
|
798 | for efficiency. | |
799 | """ |
|
799 | """ | |
800 |
|
800 | |||
801 | # i18n: "filelog" is a keyword |
|
801 | # i18n: "filelog" is a keyword | |
802 | pat = getstring(x, _("filelog requires a pattern")) |
|
802 | pat = getstring(x, _("filelog requires a pattern")) | |
803 | s = set() |
|
803 | s = set() | |
804 |
|
804 | |||
805 | if not matchmod.patkind(pat): |
|
805 | if not matchmod.patkind(pat): | |
806 | f = pathutil.canonpath(repo.root, repo.getcwd(), pat) |
|
806 | f = pathutil.canonpath(repo.root, repo.getcwd(), pat) | |
807 | fl = repo.file(f) |
|
807 | fl = repo.file(f) | |
808 | for fr in fl: |
|
808 | for fr in fl: | |
809 | s.add(fl.linkrev(fr)) |
|
809 | s.add(fl.linkrev(fr)) | |
810 | else: |
|
810 | else: | |
811 | m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=repo[None]) |
|
811 | m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=repo[None]) | |
812 | for f in repo[None]: |
|
812 | for f in repo[None]: | |
813 | if m(f): |
|
813 | if m(f): | |
814 | fl = repo.file(f) |
|
814 | fl = repo.file(f) | |
815 | for fr in fl: |
|
815 | for fr in fl: | |
816 | s.add(fl.linkrev(fr)) |
|
816 | s.add(fl.linkrev(fr)) | |
817 |
|
817 | |||
818 | return subset & s |
|
818 | return subset & s | |
819 |
|
819 | |||
820 | def first(repo, subset, x): |
|
820 | def first(repo, subset, x): | |
821 | """``first(set, [n])`` |
|
821 | """``first(set, [n])`` | |
822 | An alias for limit(). |
|
822 | An alias for limit(). | |
823 | """ |
|
823 | """ | |
824 | return limit(repo, subset, x) |
|
824 | return limit(repo, subset, x) | |
825 |
|
825 | |||
826 | def _follow(repo, subset, x, name, followfirst=False): |
|
826 | def _follow(repo, subset, x, name, followfirst=False): | |
827 | l = getargs(x, 0, 1, _("%s takes no arguments or a filename") % name) |
|
827 | l = getargs(x, 0, 1, _("%s takes no arguments or a filename") % name) | |
828 | c = repo['.'] |
|
828 | c = repo['.'] | |
829 | if l: |
|
829 | if l: | |
830 | x = getstring(l[0], _("%s expected a filename") % name) |
|
830 | x = getstring(l[0], _("%s expected a filename") % name) | |
831 | if x in c: |
|
831 | if x in c: | |
832 | cx = c[x] |
|
832 | cx = c[x] | |
833 | s = set(ctx.rev() for ctx in cx.ancestors(followfirst=followfirst)) |
|
833 | s = set(ctx.rev() for ctx in cx.ancestors(followfirst=followfirst)) | |
834 | # include the revision responsible for the most recent version |
|
834 | # include the revision responsible for the most recent version | |
835 | s.add(cx.linkrev()) |
|
835 | s.add(cx.linkrev()) | |
836 | else: |
|
836 | else: | |
837 | return baseset() |
|
837 | return baseset() | |
838 | else: |
|
838 | else: | |
839 | s = _revancestors(repo, baseset([c.rev()]), followfirst) |
|
839 | s = _revancestors(repo, baseset([c.rev()]), followfirst) | |
840 |
|
840 | |||
841 | return subset & s |
|
841 | return subset & s | |
842 |
|
842 | |||
843 | def follow(repo, subset, x): |
|
843 | def follow(repo, subset, x): | |
844 | """``follow([file])`` |
|
844 | """``follow([file])`` | |
845 | An alias for ``::.`` (ancestors of the working copy's first parent). |
|
845 | An alias for ``::.`` (ancestors of the working copy's first parent). | |
846 | If a filename is specified, the history of the given file is followed, |
|
846 | If a filename is specified, the history of the given file is followed, | |
847 | including copies. |
|
847 | including copies. | |
848 | """ |
|
848 | """ | |
849 | return _follow(repo, subset, x, 'follow') |
|
849 | return _follow(repo, subset, x, 'follow') | |
850 |
|
850 | |||
851 | def _followfirst(repo, subset, x): |
|
851 | def _followfirst(repo, subset, x): | |
852 | # ``followfirst([file])`` |
|
852 | # ``followfirst([file])`` | |
853 | # Like ``follow([file])`` but follows only the first parent of |
|
853 | # Like ``follow([file])`` but follows only the first parent of | |
854 | # every revision or file revision. |
|
854 | # every revision or file revision. | |
855 | return _follow(repo, subset, x, '_followfirst', followfirst=True) |
|
855 | return _follow(repo, subset, x, '_followfirst', followfirst=True) | |
856 |
|
856 | |||
857 | def getall(repo, subset, x): |
|
857 | def getall(repo, subset, x): | |
858 | """``all()`` |
|
858 | """``all()`` | |
859 | All changesets, the same as ``0:tip``. |
|
859 | All changesets, the same as ``0:tip``. | |
860 | """ |
|
860 | """ | |
861 | # i18n: "all" is a keyword |
|
861 | # i18n: "all" is a keyword | |
862 | getargs(x, 0, 0, _("all takes no arguments")) |
|
862 | getargs(x, 0, 0, _("all takes no arguments")) | |
863 | return subset |
|
863 | return subset | |
864 |
|
864 | |||
865 | def grep(repo, subset, x): |
|
865 | def grep(repo, subset, x): | |
866 | """``grep(regex)`` |
|
866 | """``grep(regex)`` | |
867 | Like ``keyword(string)`` but accepts a regex. Use ``grep(r'...')`` |
|
867 | Like ``keyword(string)`` but accepts a regex. Use ``grep(r'...')`` | |
868 | to ensure special escape characters are handled correctly. Unlike |
|
868 | to ensure special escape characters are handled correctly. Unlike | |
869 | ``keyword(string)``, the match is case-sensitive. |
|
869 | ``keyword(string)``, the match is case-sensitive. | |
870 | """ |
|
870 | """ | |
871 | try: |
|
871 | try: | |
872 | # i18n: "grep" is a keyword |
|
872 | # i18n: "grep" is a keyword | |
873 | gr = re.compile(getstring(x, _("grep requires a string"))) |
|
873 | gr = re.compile(getstring(x, _("grep requires a string"))) | |
874 | except re.error, e: |
|
874 | except re.error, e: | |
875 | raise error.ParseError(_('invalid match pattern: %s') % e) |
|
875 | raise error.ParseError(_('invalid match pattern: %s') % e) | |
876 |
|
876 | |||
877 | def matches(x): |
|
877 | def matches(x): | |
878 | c = repo[x] |
|
878 | c = repo[x] | |
879 | for e in c.files() + [c.user(), c.description()]: |
|
879 | for e in c.files() + [c.user(), c.description()]: | |
880 | if gr.search(e): |
|
880 | if gr.search(e): | |
881 | return True |
|
881 | return True | |
882 | return False |
|
882 | return False | |
883 |
|
883 | |||
884 | return subset.filter(matches) |
|
884 | return subset.filter(matches) | |
885 |
|
885 | |||
886 | def _matchfiles(repo, subset, x): |
|
886 | def _matchfiles(repo, subset, x): | |
887 | # _matchfiles takes a revset list of prefixed arguments: |
|
887 | # _matchfiles takes a revset list of prefixed arguments: | |
888 | # |
|
888 | # | |
889 | # [p:foo, i:bar, x:baz] |
|
889 | # [p:foo, i:bar, x:baz] | |
890 | # |
|
890 | # | |
891 | # builds a match object from them and filters subset. Allowed |
|
891 | # builds a match object from them and filters subset. Allowed | |
892 | # prefixes are 'p:' for regular patterns, 'i:' for include |
|
892 | # prefixes are 'p:' for regular patterns, 'i:' for include | |
893 | # patterns and 'x:' for exclude patterns. Use 'r:' prefix to pass |
|
893 | # patterns and 'x:' for exclude patterns. Use 'r:' prefix to pass | |
894 | # a revision identifier, or the empty string to reference the |
|
894 | # a revision identifier, or the empty string to reference the | |
895 | # working directory, from which the match object is |
|
895 | # working directory, from which the match object is | |
896 | # initialized. Use 'd:' to set the default matching mode, default |
|
896 | # initialized. Use 'd:' to set the default matching mode, default | |
897 | # to 'glob'. At most one 'r:' and 'd:' argument can be passed. |
|
897 | # to 'glob'. At most one 'r:' and 'd:' argument can be passed. | |
898 |
|
898 | |||
899 | # i18n: "_matchfiles" is a keyword |
|
899 | # i18n: "_matchfiles" is a keyword | |
900 | l = getargs(x, 1, -1, _("_matchfiles requires at least one argument")) |
|
900 | l = getargs(x, 1, -1, _("_matchfiles requires at least one argument")) | |
901 | pats, inc, exc = [], [], [] |
|
901 | pats, inc, exc = [], [], [] | |
902 | rev, default = None, None |
|
902 | rev, default = None, None | |
903 | for arg in l: |
|
903 | for arg in l: | |
904 | # i18n: "_matchfiles" is a keyword |
|
904 | # i18n: "_matchfiles" is a keyword | |
905 | s = getstring(arg, _("_matchfiles requires string arguments")) |
|
905 | s = getstring(arg, _("_matchfiles requires string arguments")) | |
906 | prefix, value = s[:2], s[2:] |
|
906 | prefix, value = s[:2], s[2:] | |
907 | if prefix == 'p:': |
|
907 | if prefix == 'p:': | |
908 | pats.append(value) |
|
908 | pats.append(value) | |
909 | elif prefix == 'i:': |
|
909 | elif prefix == 'i:': | |
910 | inc.append(value) |
|
910 | inc.append(value) | |
911 | elif prefix == 'x:': |
|
911 | elif prefix == 'x:': | |
912 | exc.append(value) |
|
912 | exc.append(value) | |
913 | elif prefix == 'r:': |
|
913 | elif prefix == 'r:': | |
914 | if rev is not None: |
|
914 | if rev is not None: | |
915 | # i18n: "_matchfiles" is a keyword |
|
915 | # i18n: "_matchfiles" is a keyword | |
916 | raise error.ParseError(_('_matchfiles expected at most one ' |
|
916 | raise error.ParseError(_('_matchfiles expected at most one ' | |
917 | 'revision')) |
|
917 | 'revision')) | |
918 | rev = value |
|
918 | rev = value | |
919 | elif prefix == 'd:': |
|
919 | elif prefix == 'd:': | |
920 | if default is not None: |
|
920 | if default is not None: | |
921 | # i18n: "_matchfiles" is a keyword |
|
921 | # i18n: "_matchfiles" is a keyword | |
922 | raise error.ParseError(_('_matchfiles expected at most one ' |
|
922 | raise error.ParseError(_('_matchfiles expected at most one ' | |
923 | 'default mode')) |
|
923 | 'default mode')) | |
924 | default = value |
|
924 | default = value | |
925 | else: |
|
925 | else: | |
926 | # i18n: "_matchfiles" is a keyword |
|
926 | # i18n: "_matchfiles" is a keyword | |
927 | raise error.ParseError(_('invalid _matchfiles prefix: %s') % prefix) |
|
927 | raise error.ParseError(_('invalid _matchfiles prefix: %s') % prefix) | |
928 | if not default: |
|
928 | if not default: | |
929 | default = 'glob' |
|
929 | default = 'glob' | |
930 |
|
930 | |||
931 | m = matchmod.match(repo.root, repo.getcwd(), pats, include=inc, |
|
931 | m = matchmod.match(repo.root, repo.getcwd(), pats, include=inc, | |
932 | exclude=exc, ctx=repo[rev], default=default) |
|
932 | exclude=exc, ctx=repo[rev], default=default) | |
933 |
|
933 | |||
934 | def matches(x): |
|
934 | def matches(x): | |
935 | for f in repo[x].files(): |
|
935 | for f in repo[x].files(): | |
936 | if m(f): |
|
936 | if m(f): | |
937 | return True |
|
937 | return True | |
938 | return False |
|
938 | return False | |
939 |
|
939 | |||
940 | return subset.filter(matches) |
|
940 | return subset.filter(matches) | |
941 |
|
941 | |||
942 | def hasfile(repo, subset, x): |
|
942 | def hasfile(repo, subset, x): | |
943 | """``file(pattern)`` |
|
943 | """``file(pattern)`` | |
944 | Changesets affecting files matched by pattern. |
|
944 | Changesets affecting files matched by pattern. | |
945 |
|
945 | |||
946 | For a faster but less accurate result, consider using ``filelog()`` |
|
946 | For a faster but less accurate result, consider using ``filelog()`` | |
947 | instead. |
|
947 | instead. | |
948 |
|
948 | |||
949 | This predicate uses ``glob:`` as the default kind of pattern. |
|
949 | This predicate uses ``glob:`` as the default kind of pattern. | |
950 | """ |
|
950 | """ | |
951 | # i18n: "file" is a keyword |
|
951 | # i18n: "file" is a keyword | |
952 | pat = getstring(x, _("file requires a pattern")) |
|
952 | pat = getstring(x, _("file requires a pattern")) | |
953 | return _matchfiles(repo, subset, ('string', 'p:' + pat)) |
|
953 | return _matchfiles(repo, subset, ('string', 'p:' + pat)) | |
954 |
|
954 | |||
955 | def head(repo, subset, x): |
|
955 | def head(repo, subset, x): | |
956 | """``head()`` |
|
956 | """``head()`` | |
957 | Changeset is a named branch head. |
|
957 | Changeset is a named branch head. | |
958 | """ |
|
958 | """ | |
959 | # i18n: "head" is a keyword |
|
959 | # i18n: "head" is a keyword | |
960 | getargs(x, 0, 0, _("head takes no arguments")) |
|
960 | getargs(x, 0, 0, _("head takes no arguments")) | |
961 | hs = set() |
|
961 | hs = set() | |
962 | for b, ls in repo.branchmap().iteritems(): |
|
962 | for b, ls in repo.branchmap().iteritems(): | |
963 | hs.update(repo[h].rev() for h in ls) |
|
963 | hs.update(repo[h].rev() for h in ls) | |
964 | return baseset(hs).filter(subset.__contains__) |
|
964 | return baseset(hs).filter(subset.__contains__) | |
965 |
|
965 | |||
966 | def heads(repo, subset, x): |
|
966 | def heads(repo, subset, x): | |
967 | """``heads(set)`` |
|
967 | """``heads(set)`` | |
968 | Members of set with no children in set. |
|
968 | Members of set with no children in set. | |
969 | """ |
|
969 | """ | |
970 | s = getset(repo, subset, x) |
|
970 | s = getset(repo, subset, x) | |
971 | ps = parents(repo, subset, x) |
|
971 | ps = parents(repo, subset, x) | |
972 | return s - ps |
|
972 | return s - ps | |
973 |
|
973 | |||
974 | def hidden(repo, subset, x): |
|
974 | def hidden(repo, subset, x): | |
975 | """``hidden()`` |
|
975 | """``hidden()`` | |
976 | Hidden changesets. |
|
976 | Hidden changesets. | |
977 | """ |
|
977 | """ | |
978 | # i18n: "hidden" is a keyword |
|
978 | # i18n: "hidden" is a keyword | |
979 | getargs(x, 0, 0, _("hidden takes no arguments")) |
|
979 | getargs(x, 0, 0, _("hidden takes no arguments")) | |
980 | hiddenrevs = repoview.filterrevs(repo, 'visible') |
|
980 | hiddenrevs = repoview.filterrevs(repo, 'visible') | |
981 | return subset & hiddenrevs |
|
981 | return subset & hiddenrevs | |
982 |
|
982 | |||
983 | def keyword(repo, subset, x): |
|
983 | def keyword(repo, subset, x): | |
984 | """``keyword(string)`` |
|
984 | """``keyword(string)`` | |
985 | Search commit message, user name, and names of changed files for |
|
985 | Search commit message, user name, and names of changed files for | |
986 | string. The match is case-insensitive. |
|
986 | string. The match is case-insensitive. | |
987 | """ |
|
987 | """ | |
988 | # i18n: "keyword" is a keyword |
|
988 | # i18n: "keyword" is a keyword | |
989 | kw = encoding.lower(getstring(x, _("keyword requires a string"))) |
|
989 | kw = encoding.lower(getstring(x, _("keyword requires a string"))) | |
990 |
|
990 | |||
991 | def matches(r): |
|
991 | def matches(r): | |
992 | c = repo[r] |
|
992 | c = repo[r] | |
993 | return util.any(kw in encoding.lower(t) for t in c.files() + [c.user(), |
|
993 | return util.any(kw in encoding.lower(t) for t in c.files() + [c.user(), | |
994 | c.description()]) |
|
994 | c.description()]) | |
995 |
|
995 | |||
996 | return subset.filter(matches) |
|
996 | return subset.filter(matches) | |
997 |
|
997 | |||
998 | def limit(repo, subset, x): |
|
998 | def limit(repo, subset, x): | |
999 | """``limit(set, [n])`` |
|
999 | """``limit(set, [n])`` | |
1000 | First n members of set, defaulting to 1. |
|
1000 | First n members of set, defaulting to 1. | |
1001 | """ |
|
1001 | """ | |
1002 | # i18n: "limit" is a keyword |
|
1002 | # i18n: "limit" is a keyword | |
1003 | l = getargs(x, 1, 2, _("limit requires one or two arguments")) |
|
1003 | l = getargs(x, 1, 2, _("limit requires one or two arguments")) | |
1004 | try: |
|
1004 | try: | |
1005 | lim = 1 |
|
1005 | lim = 1 | |
1006 | if len(l) == 2: |
|
1006 | if len(l) == 2: | |
1007 | # i18n: "limit" is a keyword |
|
1007 | # i18n: "limit" is a keyword | |
1008 | lim = int(getstring(l[1], _("limit requires a number"))) |
|
1008 | lim = int(getstring(l[1], _("limit requires a number"))) | |
1009 | except (TypeError, ValueError): |
|
1009 | except (TypeError, ValueError): | |
1010 | # i18n: "limit" is a keyword |
|
1010 | # i18n: "limit" is a keyword | |
1011 | raise error.ParseError(_("limit expects a number")) |
|
1011 | raise error.ParseError(_("limit expects a number")) | |
1012 | ss = subset |
|
1012 | ss = subset | |
1013 | os = getset(repo, spanset(repo), l[0]) |
|
1013 | os = getset(repo, spanset(repo), l[0]) | |
1014 | result = [] |
|
1014 | result = [] | |
1015 | it = iter(os) |
|
1015 | it = iter(os) | |
1016 | for x in xrange(lim): |
|
1016 | for x in xrange(lim): | |
1017 | try: |
|
1017 | try: | |
1018 | y = it.next() |
|
1018 | y = it.next() | |
1019 | if y in ss: |
|
1019 | if y in ss: | |
1020 | result.append(y) |
|
1020 | result.append(y) | |
1021 | except (StopIteration): |
|
1021 | except (StopIteration): | |
1022 | break |
|
1022 | break | |
1023 | return baseset(result) |
|
1023 | return baseset(result) | |
1024 |
|
1024 | |||
1025 | def last(repo, subset, x): |
|
1025 | def last(repo, subset, x): | |
1026 | """``last(set, [n])`` |
|
1026 | """``last(set, [n])`` | |
1027 | Last n members of set, defaulting to 1. |
|
1027 | Last n members of set, defaulting to 1. | |
1028 | """ |
|
1028 | """ | |
1029 | # i18n: "last" is a keyword |
|
1029 | # i18n: "last" is a keyword | |
1030 | l = getargs(x, 1, 2, _("last requires one or two arguments")) |
|
1030 | l = getargs(x, 1, 2, _("last requires one or two arguments")) | |
1031 | try: |
|
1031 | try: | |
1032 | lim = 1 |
|
1032 | lim = 1 | |
1033 | if len(l) == 2: |
|
1033 | if len(l) == 2: | |
1034 | # i18n: "last" is a keyword |
|
1034 | # i18n: "last" is a keyword | |
1035 | lim = int(getstring(l[1], _("last requires a number"))) |
|
1035 | lim = int(getstring(l[1], _("last requires a number"))) | |
1036 | except (TypeError, ValueError): |
|
1036 | except (TypeError, ValueError): | |
1037 | # i18n: "last" is a keyword |
|
1037 | # i18n: "last" is a keyword | |
1038 | raise error.ParseError(_("last expects a number")) |
|
1038 | raise error.ParseError(_("last expects a number")) | |
1039 | ss = subset |
|
1039 | ss = subset | |
1040 | os = getset(repo, spanset(repo), l[0]) |
|
1040 | os = getset(repo, spanset(repo), l[0]) | |
1041 | os.reverse() |
|
1041 | os.reverse() | |
1042 | result = [] |
|
1042 | result = [] | |
1043 | it = iter(os) |
|
1043 | it = iter(os) | |
1044 | for x in xrange(lim): |
|
1044 | for x in xrange(lim): | |
1045 | try: |
|
1045 | try: | |
1046 | y = it.next() |
|
1046 | y = it.next() | |
1047 | if y in ss: |
|
1047 | if y in ss: | |
1048 | result.append(y) |
|
1048 | result.append(y) | |
1049 | except (StopIteration): |
|
1049 | except (StopIteration): | |
1050 | break |
|
1050 | break | |
1051 | return baseset(result) |
|
1051 | return baseset(result) | |
1052 |
|
1052 | |||
1053 | def maxrev(repo, subset, x): |
|
1053 | def maxrev(repo, subset, x): | |
1054 | """``max(set)`` |
|
1054 | """``max(set)`` | |
1055 | Changeset with highest revision number in set. |
|
1055 | Changeset with highest revision number in set. | |
1056 | """ |
|
1056 | """ | |
1057 | os = getset(repo, spanset(repo), x) |
|
1057 | os = getset(repo, spanset(repo), x) | |
1058 | if os: |
|
1058 | if os: | |
1059 | m = os.max() |
|
1059 | m = os.max() | |
1060 | if m in subset: |
|
1060 | if m in subset: | |
1061 | return baseset([m]) |
|
1061 | return baseset([m]) | |
1062 | return baseset() |
|
1062 | return baseset() | |
1063 |
|
1063 | |||
1064 | def merge(repo, subset, x): |
|
1064 | def merge(repo, subset, x): | |
1065 | """``merge()`` |
|
1065 | """``merge()`` | |
1066 | Changeset is a merge changeset. |
|
1066 | Changeset is a merge changeset. | |
1067 | """ |
|
1067 | """ | |
1068 | # i18n: "merge" is a keyword |
|
1068 | # i18n: "merge" is a keyword | |
1069 | getargs(x, 0, 0, _("merge takes no arguments")) |
|
1069 | getargs(x, 0, 0, _("merge takes no arguments")) | |
1070 | cl = repo.changelog |
|
1070 | cl = repo.changelog | |
1071 | return subset.filter(lambda r: cl.parentrevs(r)[1] != -1) |
|
1071 | return subset.filter(lambda r: cl.parentrevs(r)[1] != -1) | |
1072 |
|
1072 | |||
1073 | def branchpoint(repo, subset, x): |
|
1073 | def branchpoint(repo, subset, x): | |
1074 | """``branchpoint()`` |
|
1074 | """``branchpoint()`` | |
1075 | Changesets with more than one child. |
|
1075 | Changesets with more than one child. | |
1076 | """ |
|
1076 | """ | |
1077 | # i18n: "branchpoint" is a keyword |
|
1077 | # i18n: "branchpoint" is a keyword | |
1078 | getargs(x, 0, 0, _("branchpoint takes no arguments")) |
|
1078 | getargs(x, 0, 0, _("branchpoint takes no arguments")) | |
1079 | cl = repo.changelog |
|
1079 | cl = repo.changelog | |
1080 | if not subset: |
|
1080 | if not subset: | |
1081 | return baseset() |
|
1081 | return baseset() | |
1082 | baserev = min(subset) |
|
1082 | baserev = min(subset) | |
1083 | parentscount = [0]*(len(repo) - baserev) |
|
1083 | parentscount = [0]*(len(repo) - baserev) | |
1084 | for r in cl.revs(start=baserev + 1): |
|
1084 | for r in cl.revs(start=baserev + 1): | |
1085 | for p in cl.parentrevs(r): |
|
1085 | for p in cl.parentrevs(r): | |
1086 | if p >= baserev: |
|
1086 | if p >= baserev: | |
1087 | parentscount[p - baserev] += 1 |
|
1087 | parentscount[p - baserev] += 1 | |
1088 | return subset.filter(lambda r: parentscount[r - baserev] > 1) |
|
1088 | return subset.filter(lambda r: parentscount[r - baserev] > 1) | |
1089 |
|
1089 | |||
1090 | def minrev(repo, subset, x): |
|
1090 | def minrev(repo, subset, x): | |
1091 | """``min(set)`` |
|
1091 | """``min(set)`` | |
1092 | Changeset with lowest revision number in set. |
|
1092 | Changeset with lowest revision number in set. | |
1093 | """ |
|
1093 | """ | |
1094 | os = getset(repo, spanset(repo), x) |
|
1094 | os = getset(repo, spanset(repo), x) | |
1095 | if os: |
|
1095 | if os: | |
1096 | m = os.min() |
|
1096 | m = os.min() | |
1097 | if m in subset: |
|
1097 | if m in subset: | |
1098 | return baseset([m]) |
|
1098 | return baseset([m]) | |
1099 | return baseset() |
|
1099 | return baseset() | |
1100 |
|
1100 | |||
1101 | def modifies(repo, subset, x): |
|
1101 | def modifies(repo, subset, x): | |
1102 | """``modifies(pattern)`` |
|
1102 | """``modifies(pattern)`` | |
1103 | Changesets modifying files matched by pattern. |
|
1103 | Changesets modifying files matched by pattern. | |
1104 |
|
1104 | |||
1105 | The pattern without explicit kind like ``glob:`` is expected to be |
|
1105 | The pattern without explicit kind like ``glob:`` is expected to be | |
1106 | relative to the current directory and match against a file or a |
|
1106 | relative to the current directory and match against a file or a | |
1107 | directory. |
|
1107 | directory. | |
1108 | """ |
|
1108 | """ | |
1109 | # i18n: "modifies" is a keyword |
|
1109 | # i18n: "modifies" is a keyword | |
1110 | pat = getstring(x, _("modifies requires a pattern")) |
|
1110 | pat = getstring(x, _("modifies requires a pattern")) | |
1111 | return checkstatus(repo, subset, pat, 0) |
|
1111 | return checkstatus(repo, subset, pat, 0) | |
1112 |
|
1112 | |||
1113 | def node_(repo, subset, x): |
|
1113 | def node_(repo, subset, x): | |
1114 | """``id(string)`` |
|
1114 | """``id(string)`` | |
1115 | Revision non-ambiguously specified by the given hex string prefix. |
|
1115 | Revision non-ambiguously specified by the given hex string prefix. | |
1116 | """ |
|
1116 | """ | |
1117 | # i18n: "id" is a keyword |
|
1117 | # i18n: "id" is a keyword | |
1118 | l = getargs(x, 1, 1, _("id requires one argument")) |
|
1118 | l = getargs(x, 1, 1, _("id requires one argument")) | |
1119 | # i18n: "id" is a keyword |
|
1119 | # i18n: "id" is a keyword | |
1120 | n = getstring(l[0], _("id requires a string")) |
|
1120 | n = getstring(l[0], _("id requires a string")) | |
1121 | if len(n) == 40: |
|
1121 | if len(n) == 40: | |
1122 | rn = repo[n].rev() |
|
1122 | rn = repo[n].rev() | |
1123 | else: |
|
1123 | else: | |
1124 | rn = None |
|
1124 | rn = None | |
1125 | pm = repo.changelog._partialmatch(n) |
|
1125 | pm = repo.changelog._partialmatch(n) | |
1126 | if pm is not None: |
|
1126 | if pm is not None: | |
1127 | rn = repo.changelog.rev(pm) |
|
1127 | rn = repo.changelog.rev(pm) | |
1128 |
|
1128 | |||
1129 | if rn is None: |
|
1129 | if rn is None: | |
1130 | return baseset() |
|
1130 | return baseset() | |
1131 | result = baseset([rn]) |
|
1131 | result = baseset([rn]) | |
1132 | return result & subset |
|
1132 | return result & subset | |
1133 |
|
1133 | |||
1134 | def obsolete(repo, subset, x): |
|
1134 | def obsolete(repo, subset, x): | |
1135 | """``obsolete()`` |
|
1135 | """``obsolete()`` | |
1136 | Mutable changeset with a newer version.""" |
|
1136 | Mutable changeset with a newer version.""" | |
1137 | # i18n: "obsolete" is a keyword |
|
1137 | # i18n: "obsolete" is a keyword | |
1138 | getargs(x, 0, 0, _("obsolete takes no arguments")) |
|
1138 | getargs(x, 0, 0, _("obsolete takes no arguments")) | |
1139 | obsoletes = obsmod.getrevs(repo, 'obsolete') |
|
1139 | obsoletes = obsmod.getrevs(repo, 'obsolete') | |
1140 | return subset & obsoletes |
|
1140 | return subset & obsoletes | |
1141 |
|
1141 | |||
1142 | def origin(repo, subset, x): |
|
1142 | def origin(repo, subset, x): | |
1143 | """``origin([set])`` |
|
1143 | """``origin([set])`` | |
1144 | Changesets that were specified as a source for the grafts, transplants or |
|
1144 | Changesets that were specified as a source for the grafts, transplants or | |
1145 | rebases that created the given revisions. Omitting the optional set is the |
|
1145 | rebases that created the given revisions. Omitting the optional set is the | |
1146 | same as passing all(). If a changeset created by these operations is itself |
|
1146 | same as passing all(). If a changeset created by these operations is itself | |
1147 | specified as a source for one of these operations, only the source changeset |
|
1147 | specified as a source for one of these operations, only the source changeset | |
1148 | for the first operation is selected. |
|
1148 | for the first operation is selected. | |
1149 | """ |
|
1149 | """ | |
1150 | if x is not None: |
|
1150 | if x is not None: | |
1151 | dests = getset(repo, spanset(repo), x) |
|
1151 | dests = getset(repo, spanset(repo), x) | |
1152 | else: |
|
1152 | else: | |
1153 | dests = getall(repo, spanset(repo), x) |
|
1153 | dests = getall(repo, spanset(repo), x) | |
1154 |
|
1154 | |||
1155 | def _firstsrc(rev): |
|
1155 | def _firstsrc(rev): | |
1156 | src = _getrevsource(repo, rev) |
|
1156 | src = _getrevsource(repo, rev) | |
1157 | if src is None: |
|
1157 | if src is None: | |
1158 | return None |
|
1158 | return None | |
1159 |
|
1159 | |||
1160 | while True: |
|
1160 | while True: | |
1161 | prev = _getrevsource(repo, src) |
|
1161 | prev = _getrevsource(repo, src) | |
1162 |
|
1162 | |||
1163 | if prev is None: |
|
1163 | if prev is None: | |
1164 | return src |
|
1164 | return src | |
1165 | src = prev |
|
1165 | src = prev | |
1166 |
|
1166 | |||
1167 | o = set([_firstsrc(r) for r in dests]) |
|
1167 | o = set([_firstsrc(r) for r in dests]) | |
1168 | o -= set([None]) |
|
1168 | o -= set([None]) | |
1169 | return subset & o |
|
1169 | return subset & o | |
1170 |
|
1170 | |||
1171 | def outgoing(repo, subset, x): |
|
1171 | def outgoing(repo, subset, x): | |
1172 | """``outgoing([path])`` |
|
1172 | """``outgoing([path])`` | |
1173 | Changesets not found in the specified destination repository, or the |
|
1173 | Changesets not found in the specified destination repository, or the | |
1174 | default push location. |
|
1174 | default push location. | |
1175 | """ |
|
1175 | """ | |
1176 | import hg # avoid start-up nasties |
|
1176 | import hg # avoid start-up nasties | |
1177 | # i18n: "outgoing" is a keyword |
|
1177 | # i18n: "outgoing" is a keyword | |
1178 | l = getargs(x, 0, 1, _("outgoing takes one or no arguments")) |
|
1178 | l = getargs(x, 0, 1, _("outgoing takes one or no arguments")) | |
1179 | # i18n: "outgoing" is a keyword |
|
1179 | # i18n: "outgoing" is a keyword | |
1180 | dest = l and getstring(l[0], _("outgoing requires a repository path")) or '' |
|
1180 | dest = l and getstring(l[0], _("outgoing requires a repository path")) or '' | |
1181 | dest = repo.ui.expandpath(dest or 'default-push', dest or 'default') |
|
1181 | dest = repo.ui.expandpath(dest or 'default-push', dest or 'default') | |
1182 | dest, branches = hg.parseurl(dest) |
|
1182 | dest, branches = hg.parseurl(dest) | |
1183 | revs, checkout = hg.addbranchrevs(repo, repo, branches, []) |
|
1183 | revs, checkout = hg.addbranchrevs(repo, repo, branches, []) | |
1184 | if revs: |
|
1184 | if revs: | |
1185 | revs = [repo.lookup(rev) for rev in revs] |
|
1185 | revs = [repo.lookup(rev) for rev in revs] | |
1186 | other = hg.peer(repo, {}, dest) |
|
1186 | other = hg.peer(repo, {}, dest) | |
1187 | repo.ui.pushbuffer() |
|
1187 | repo.ui.pushbuffer() | |
1188 | outgoing = discovery.findcommonoutgoing(repo, other, onlyheads=revs) |
|
1188 | outgoing = discovery.findcommonoutgoing(repo, other, onlyheads=revs) | |
1189 | repo.ui.popbuffer() |
|
1189 | repo.ui.popbuffer() | |
1190 | cl = repo.changelog |
|
1190 | cl = repo.changelog | |
1191 | o = set([cl.rev(r) for r in outgoing.missing]) |
|
1191 | o = set([cl.rev(r) for r in outgoing.missing]) | |
1192 | return subset & o |
|
1192 | return subset & o | |
1193 |
|
1193 | |||
1194 | def p1(repo, subset, x): |
|
1194 | def p1(repo, subset, x): | |
1195 | """``p1([set])`` |
|
1195 | """``p1([set])`` | |
1196 | First parent of changesets in set, or the working directory. |
|
1196 | First parent of changesets in set, or the working directory. | |
1197 | """ |
|
1197 | """ | |
1198 | if x is None: |
|
1198 | if x is None: | |
1199 | p = repo[x].p1().rev() |
|
1199 | p = repo[x].p1().rev() | |
1200 | if p >= 0: |
|
1200 | if p >= 0: | |
1201 | return subset & baseset([p]) |
|
1201 | return subset & baseset([p]) | |
1202 | return baseset() |
|
1202 | return baseset() | |
1203 |
|
1203 | |||
1204 | ps = set() |
|
1204 | ps = set() | |
1205 | cl = repo.changelog |
|
1205 | cl = repo.changelog | |
1206 | for r in getset(repo, spanset(repo), x): |
|
1206 | for r in getset(repo, spanset(repo), x): | |
1207 | ps.add(cl.parentrevs(r)[0]) |
|
1207 | ps.add(cl.parentrevs(r)[0]) | |
1208 | ps -= set([node.nullrev]) |
|
1208 | ps -= set([node.nullrev]) | |
1209 | return subset & ps |
|
1209 | return subset & ps | |
1210 |
|
1210 | |||
1211 | def p2(repo, subset, x): |
|
1211 | def p2(repo, subset, x): | |
1212 | """``p2([set])`` |
|
1212 | """``p2([set])`` | |
1213 | Second parent of changesets in set, or the working directory. |
|
1213 | Second parent of changesets in set, or the working directory. | |
1214 | """ |
|
1214 | """ | |
1215 | if x is None: |
|
1215 | if x is None: | |
1216 | ps = repo[x].parents() |
|
1216 | ps = repo[x].parents() | |
1217 | try: |
|
1217 | try: | |
1218 | p = ps[1].rev() |
|
1218 | p = ps[1].rev() | |
1219 | if p >= 0: |
|
1219 | if p >= 0: | |
1220 | return subset & baseset([p]) |
|
1220 | return subset & baseset([p]) | |
1221 | return baseset() |
|
1221 | return baseset() | |
1222 | except IndexError: |
|
1222 | except IndexError: | |
1223 | return baseset() |
|
1223 | return baseset() | |
1224 |
|
1224 | |||
1225 | ps = set() |
|
1225 | ps = set() | |
1226 | cl = repo.changelog |
|
1226 | cl = repo.changelog | |
1227 | for r in getset(repo, spanset(repo), x): |
|
1227 | for r in getset(repo, spanset(repo), x): | |
1228 | ps.add(cl.parentrevs(r)[1]) |
|
1228 | ps.add(cl.parentrevs(r)[1]) | |
1229 | ps -= set([node.nullrev]) |
|
1229 | ps -= set([node.nullrev]) | |
1230 | return subset & ps |
|
1230 | return subset & ps | |
1231 |
|
1231 | |||
1232 | def parents(repo, subset, x): |
|
1232 | def parents(repo, subset, x): | |
1233 | """``parents([set])`` |
|
1233 | """``parents([set])`` | |
1234 | The set of all parents for all changesets in set, or the working directory. |
|
1234 | The set of all parents for all changesets in set, or the working directory. | |
1235 | """ |
|
1235 | """ | |
1236 | if x is None: |
|
1236 | if x is None: | |
1237 | ps = set(p.rev() for p in repo[x].parents()) |
|
1237 | ps = set(p.rev() for p in repo[x].parents()) | |
1238 | else: |
|
1238 | else: | |
1239 | ps = set() |
|
1239 | ps = set() | |
1240 | cl = repo.changelog |
|
1240 | cl = repo.changelog | |
1241 | for r in getset(repo, spanset(repo), x): |
|
1241 | for r in getset(repo, spanset(repo), x): | |
1242 | ps.update(cl.parentrevs(r)) |
|
1242 | ps.update(cl.parentrevs(r)) | |
1243 | ps -= set([node.nullrev]) |
|
1243 | ps -= set([node.nullrev]) | |
1244 | return subset & ps |
|
1244 | return subset & ps | |
1245 |
|
1245 | |||
1246 | def parentspec(repo, subset, x, n): |
|
1246 | def parentspec(repo, subset, x, n): | |
1247 | """``set^0`` |
|
1247 | """``set^0`` | |
1248 | The set. |
|
1248 | The set. | |
1249 | ``set^1`` (or ``set^``), ``set^2`` |
|
1249 | ``set^1`` (or ``set^``), ``set^2`` | |
1250 | First or second parent, respectively, of all changesets in set. |
|
1250 | First or second parent, respectively, of all changesets in set. | |
1251 | """ |
|
1251 | """ | |
1252 | try: |
|
1252 | try: | |
1253 | n = int(n[1]) |
|
1253 | n = int(n[1]) | |
1254 | if n not in (0, 1, 2): |
|
1254 | if n not in (0, 1, 2): | |
1255 | raise ValueError |
|
1255 | raise ValueError | |
1256 | except (TypeError, ValueError): |
|
1256 | except (TypeError, ValueError): | |
1257 | raise error.ParseError(_("^ expects a number 0, 1, or 2")) |
|
1257 | raise error.ParseError(_("^ expects a number 0, 1, or 2")) | |
1258 | ps = set() |
|
1258 | ps = set() | |
1259 | cl = repo.changelog |
|
1259 | cl = repo.changelog | |
1260 | for r in getset(repo, baseset(cl), x): |
|
1260 | for r in getset(repo, baseset(cl), x): | |
1261 | if n == 0: |
|
1261 | if n == 0: | |
1262 | ps.add(r) |
|
1262 | ps.add(r) | |
1263 | elif n == 1: |
|
1263 | elif n == 1: | |
1264 | ps.add(cl.parentrevs(r)[0]) |
|
1264 | ps.add(cl.parentrevs(r)[0]) | |
1265 | elif n == 2: |
|
1265 | elif n == 2: | |
1266 | parents = cl.parentrevs(r) |
|
1266 | parents = cl.parentrevs(r) | |
1267 | if len(parents) > 1: |
|
1267 | if len(parents) > 1: | |
1268 | ps.add(parents[1]) |
|
1268 | ps.add(parents[1]) | |
1269 | return subset & ps |
|
1269 | return subset & ps | |
1270 |
|
1270 | |||
1271 | def present(repo, subset, x): |
|
1271 | def present(repo, subset, x): | |
1272 | """``present(set)`` |
|
1272 | """``present(set)`` | |
1273 | An empty set, if any revision in set isn't found; otherwise, |
|
1273 | An empty set, if any revision in set isn't found; otherwise, | |
1274 | all revisions in set. |
|
1274 | all revisions in set. | |
1275 |
|
1275 | |||
1276 | If any of specified revisions is not present in the local repository, |
|
1276 | If any of specified revisions is not present in the local repository, | |
1277 | the query is normally aborted. But this predicate allows the query |
|
1277 | the query is normally aborted. But this predicate allows the query | |
1278 | to continue even in such cases. |
|
1278 | to continue even in such cases. | |
1279 | """ |
|
1279 | """ | |
1280 | try: |
|
1280 | try: | |
1281 | return getset(repo, subset, x) |
|
1281 | return getset(repo, subset, x) | |
1282 | except error.RepoLookupError: |
|
1282 | except error.RepoLookupError: | |
1283 | return baseset() |
|
1283 | return baseset() | |
1284 |
|
1284 | |||
1285 | def public(repo, subset, x): |
|
1285 | def public(repo, subset, x): | |
1286 | """``public()`` |
|
1286 | """``public()`` | |
1287 | Changeset in public phase.""" |
|
1287 | Changeset in public phase.""" | |
1288 | # i18n: "public" is a keyword |
|
1288 | # i18n: "public" is a keyword | |
1289 | getargs(x, 0, 0, _("public takes no arguments")) |
|
1289 | getargs(x, 0, 0, _("public takes no arguments")) | |
1290 | phase = repo._phasecache.phase |
|
1290 | phase = repo._phasecache.phase | |
1291 | target = phases.public |
|
1291 | target = phases.public | |
1292 | condition = lambda r: phase(repo, r) == target |
|
1292 | condition = lambda r: phase(repo, r) == target | |
1293 | return subset.filter(condition, cache=False) |
|
1293 | return subset.filter(condition, cache=False) | |
1294 |
|
1294 | |||
1295 | def remote(repo, subset, x): |
|
1295 | def remote(repo, subset, x): | |
1296 | """``remote([id [,path]])`` |
|
1296 | """``remote([id [,path]])`` | |
1297 | Local revision that corresponds to the given identifier in a |
|
1297 | Local revision that corresponds to the given identifier in a | |
1298 | remote repository, if present. Here, the '.' identifier is a |
|
1298 | remote repository, if present. Here, the '.' identifier is a | |
1299 | synonym for the current local branch. |
|
1299 | synonym for the current local branch. | |
1300 | """ |
|
1300 | """ | |
1301 |
|
1301 | |||
1302 | import hg # avoid start-up nasties |
|
1302 | import hg # avoid start-up nasties | |
1303 | # i18n: "remote" is a keyword |
|
1303 | # i18n: "remote" is a keyword | |
1304 | l = getargs(x, 0, 2, _("remote takes one, two or no arguments")) |
|
1304 | l = getargs(x, 0, 2, _("remote takes one, two or no arguments")) | |
1305 |
|
1305 | |||
1306 | q = '.' |
|
1306 | q = '.' | |
1307 | if len(l) > 0: |
|
1307 | if len(l) > 0: | |
1308 | # i18n: "remote" is a keyword |
|
1308 | # i18n: "remote" is a keyword | |
1309 | q = getstring(l[0], _("remote requires a string id")) |
|
1309 | q = getstring(l[0], _("remote requires a string id")) | |
1310 | if q == '.': |
|
1310 | if q == '.': | |
1311 | q = repo['.'].branch() |
|
1311 | q = repo['.'].branch() | |
1312 |
|
1312 | |||
1313 | dest = '' |
|
1313 | dest = '' | |
1314 | if len(l) > 1: |
|
1314 | if len(l) > 1: | |
1315 | # i18n: "remote" is a keyword |
|
1315 | # i18n: "remote" is a keyword | |
1316 | dest = getstring(l[1], _("remote requires a repository path")) |
|
1316 | dest = getstring(l[1], _("remote requires a repository path")) | |
1317 | dest = repo.ui.expandpath(dest or 'default') |
|
1317 | dest = repo.ui.expandpath(dest or 'default') | |
1318 | dest, branches = hg.parseurl(dest) |
|
1318 | dest, branches = hg.parseurl(dest) | |
1319 | revs, checkout = hg.addbranchrevs(repo, repo, branches, []) |
|
1319 | revs, checkout = hg.addbranchrevs(repo, repo, branches, []) | |
1320 | if revs: |
|
1320 | if revs: | |
1321 | revs = [repo.lookup(rev) for rev in revs] |
|
1321 | revs = [repo.lookup(rev) for rev in revs] | |
1322 | other = hg.peer(repo, {}, dest) |
|
1322 | other = hg.peer(repo, {}, dest) | |
1323 | n = other.lookup(q) |
|
1323 | n = other.lookup(q) | |
1324 | if n in repo: |
|
1324 | if n in repo: | |
1325 | r = repo[n].rev() |
|
1325 | r = repo[n].rev() | |
1326 | if r in subset: |
|
1326 | if r in subset: | |
1327 | return baseset([r]) |
|
1327 | return baseset([r]) | |
1328 | return baseset() |
|
1328 | return baseset() | |
1329 |
|
1329 | |||
1330 | def removes(repo, subset, x): |
|
1330 | def removes(repo, subset, x): | |
1331 | """``removes(pattern)`` |
|
1331 | """``removes(pattern)`` | |
1332 | Changesets which remove files matching pattern. |
|
1332 | Changesets which remove files matching pattern. | |
1333 |
|
1333 | |||
1334 | The pattern without explicit kind like ``glob:`` is expected to be |
|
1334 | The pattern without explicit kind like ``glob:`` is expected to be | |
1335 | relative to the current directory and match against a file or a |
|
1335 | relative to the current directory and match against a file or a | |
1336 | directory. |
|
1336 | directory. | |
1337 | """ |
|
1337 | """ | |
1338 | # i18n: "removes" is a keyword |
|
1338 | # i18n: "removes" is a keyword | |
1339 | pat = getstring(x, _("removes requires a pattern")) |
|
1339 | pat = getstring(x, _("removes requires a pattern")) | |
1340 | return checkstatus(repo, subset, pat, 2) |
|
1340 | return checkstatus(repo, subset, pat, 2) | |
1341 |
|
1341 | |||
1342 | def rev(repo, subset, x): |
|
1342 | def rev(repo, subset, x): | |
1343 | """``rev(number)`` |
|
1343 | """``rev(number)`` | |
1344 | Revision with the given numeric identifier. |
|
1344 | Revision with the given numeric identifier. | |
1345 | """ |
|
1345 | """ | |
1346 | # i18n: "rev" is a keyword |
|
1346 | # i18n: "rev" is a keyword | |
1347 | l = getargs(x, 1, 1, _("rev requires one argument")) |
|
1347 | l = getargs(x, 1, 1, _("rev requires one argument")) | |
1348 | try: |
|
1348 | try: | |
1349 | # i18n: "rev" is a keyword |
|
1349 | # i18n: "rev" is a keyword | |
1350 | l = int(getstring(l[0], _("rev requires a number"))) |
|
1350 | l = int(getstring(l[0], _("rev requires a number"))) | |
1351 | except (TypeError, ValueError): |
|
1351 | except (TypeError, ValueError): | |
1352 | # i18n: "rev" is a keyword |
|
1352 | # i18n: "rev" is a keyword | |
1353 | raise error.ParseError(_("rev expects a number")) |
|
1353 | raise error.ParseError(_("rev expects a number")) | |
|
1354 | if l not in repo.changelog: | |||
|
1355 | return baseset() | |||
1354 | return subset & baseset([l]) |
|
1356 | return subset & baseset([l]) | |
1355 |
|
1357 | |||
1356 | def matching(repo, subset, x): |
|
1358 | def matching(repo, subset, x): | |
1357 | """``matching(revision [, field])`` |
|
1359 | """``matching(revision [, field])`` | |
1358 | Changesets in which a given set of fields match the set of fields in the |
|
1360 | Changesets in which a given set of fields match the set of fields in the | |
1359 | selected revision or set. |
|
1361 | selected revision or set. | |
1360 |
|
1362 | |||
1361 | To match more than one field pass the list of fields to match separated |
|
1363 | To match more than one field pass the list of fields to match separated | |
1362 | by spaces (e.g. ``author description``). |
|
1364 | by spaces (e.g. ``author description``). | |
1363 |
|
1365 | |||
1364 | Valid fields are most regular revision fields and some special fields. |
|
1366 | Valid fields are most regular revision fields and some special fields. | |
1365 |
|
1367 | |||
1366 | Regular revision fields are ``description``, ``author``, ``branch``, |
|
1368 | Regular revision fields are ``description``, ``author``, ``branch``, | |
1367 | ``date``, ``files``, ``phase``, ``parents``, ``substate``, ``user`` |
|
1369 | ``date``, ``files``, ``phase``, ``parents``, ``substate``, ``user`` | |
1368 | and ``diff``. |
|
1370 | and ``diff``. | |
1369 | Note that ``author`` and ``user`` are synonyms. ``diff`` refers to the |
|
1371 | Note that ``author`` and ``user`` are synonyms. ``diff`` refers to the | |
1370 | contents of the revision. Two revisions matching their ``diff`` will |
|
1372 | contents of the revision. Two revisions matching their ``diff`` will | |
1371 | also match their ``files``. |
|
1373 | also match their ``files``. | |
1372 |
|
1374 | |||
1373 | Special fields are ``summary`` and ``metadata``: |
|
1375 | Special fields are ``summary`` and ``metadata``: | |
1374 | ``summary`` matches the first line of the description. |
|
1376 | ``summary`` matches the first line of the description. | |
1375 | ``metadata`` is equivalent to matching ``description user date`` |
|
1377 | ``metadata`` is equivalent to matching ``description user date`` | |
1376 | (i.e. it matches the main metadata fields). |
|
1378 | (i.e. it matches the main metadata fields). | |
1377 |
|
1379 | |||
1378 | ``metadata`` is the default field which is used when no fields are |
|
1380 | ``metadata`` is the default field which is used when no fields are | |
1379 | specified. You can match more than one field at a time. |
|
1381 | specified. You can match more than one field at a time. | |
1380 | """ |
|
1382 | """ | |
1381 | # i18n: "matching" is a keyword |
|
1383 | # i18n: "matching" is a keyword | |
1382 | l = getargs(x, 1, 2, _("matching takes 1 or 2 arguments")) |
|
1384 | l = getargs(x, 1, 2, _("matching takes 1 or 2 arguments")) | |
1383 |
|
1385 | |||
1384 | revs = getset(repo, baseset(repo.changelog), l[0]) |
|
1386 | revs = getset(repo, baseset(repo.changelog), l[0]) | |
1385 |
|
1387 | |||
1386 | fieldlist = ['metadata'] |
|
1388 | fieldlist = ['metadata'] | |
1387 | if len(l) > 1: |
|
1389 | if len(l) > 1: | |
1388 | fieldlist = getstring(l[1], |
|
1390 | fieldlist = getstring(l[1], | |
1389 | # i18n: "matching" is a keyword |
|
1391 | # i18n: "matching" is a keyword | |
1390 | _("matching requires a string " |
|
1392 | _("matching requires a string " | |
1391 | "as its second argument")).split() |
|
1393 | "as its second argument")).split() | |
1392 |
|
1394 | |||
1393 | # Make sure that there are no repeated fields, |
|
1395 | # Make sure that there are no repeated fields, | |
1394 | # expand the 'special' 'metadata' field type |
|
1396 | # expand the 'special' 'metadata' field type | |
1395 | # and check the 'files' whenever we check the 'diff' |
|
1397 | # and check the 'files' whenever we check the 'diff' | |
1396 | fields = [] |
|
1398 | fields = [] | |
1397 | for field in fieldlist: |
|
1399 | for field in fieldlist: | |
1398 | if field == 'metadata': |
|
1400 | if field == 'metadata': | |
1399 | fields += ['user', 'description', 'date'] |
|
1401 | fields += ['user', 'description', 'date'] | |
1400 | elif field == 'diff': |
|
1402 | elif field == 'diff': | |
1401 | # a revision matching the diff must also match the files |
|
1403 | # a revision matching the diff must also match the files | |
1402 | # since matching the diff is very costly, make sure to |
|
1404 | # since matching the diff is very costly, make sure to | |
1403 | # also match the files first |
|
1405 | # also match the files first | |
1404 | fields += ['files', 'diff'] |
|
1406 | fields += ['files', 'diff'] | |
1405 | else: |
|
1407 | else: | |
1406 | if field == 'author': |
|
1408 | if field == 'author': | |
1407 | field = 'user' |
|
1409 | field = 'user' | |
1408 | fields.append(field) |
|
1410 | fields.append(field) | |
1409 | fields = set(fields) |
|
1411 | fields = set(fields) | |
1410 | if 'summary' in fields and 'description' in fields: |
|
1412 | if 'summary' in fields and 'description' in fields: | |
1411 | # If a revision matches its description it also matches its summary |
|
1413 | # If a revision matches its description it also matches its summary | |
1412 | fields.discard('summary') |
|
1414 | fields.discard('summary') | |
1413 |
|
1415 | |||
1414 | # We may want to match more than one field |
|
1416 | # We may want to match more than one field | |
1415 | # Not all fields take the same amount of time to be matched |
|
1417 | # Not all fields take the same amount of time to be matched | |
1416 | # Sort the selected fields in order of increasing matching cost |
|
1418 | # Sort the selected fields in order of increasing matching cost | |
1417 | fieldorder = ['phase', 'parents', 'user', 'date', 'branch', 'summary', |
|
1419 | fieldorder = ['phase', 'parents', 'user', 'date', 'branch', 'summary', | |
1418 | 'files', 'description', 'substate', 'diff'] |
|
1420 | 'files', 'description', 'substate', 'diff'] | |
1419 | def fieldkeyfunc(f): |
|
1421 | def fieldkeyfunc(f): | |
1420 | try: |
|
1422 | try: | |
1421 | return fieldorder.index(f) |
|
1423 | return fieldorder.index(f) | |
1422 | except ValueError: |
|
1424 | except ValueError: | |
1423 | # assume an unknown field is very costly |
|
1425 | # assume an unknown field is very costly | |
1424 | return len(fieldorder) |
|
1426 | return len(fieldorder) | |
1425 | fields = list(fields) |
|
1427 | fields = list(fields) | |
1426 | fields.sort(key=fieldkeyfunc) |
|
1428 | fields.sort(key=fieldkeyfunc) | |
1427 |
|
1429 | |||
1428 | # Each field will be matched with its own "getfield" function |
|
1430 | # Each field will be matched with its own "getfield" function | |
1429 | # which will be added to the getfieldfuncs array of functions |
|
1431 | # which will be added to the getfieldfuncs array of functions | |
1430 | getfieldfuncs = [] |
|
1432 | getfieldfuncs = [] | |
1431 | _funcs = { |
|
1433 | _funcs = { | |
1432 | 'user': lambda r: repo[r].user(), |
|
1434 | 'user': lambda r: repo[r].user(), | |
1433 | 'branch': lambda r: repo[r].branch(), |
|
1435 | 'branch': lambda r: repo[r].branch(), | |
1434 | 'date': lambda r: repo[r].date(), |
|
1436 | 'date': lambda r: repo[r].date(), | |
1435 | 'description': lambda r: repo[r].description(), |
|
1437 | 'description': lambda r: repo[r].description(), | |
1436 | 'files': lambda r: repo[r].files(), |
|
1438 | 'files': lambda r: repo[r].files(), | |
1437 | 'parents': lambda r: repo[r].parents(), |
|
1439 | 'parents': lambda r: repo[r].parents(), | |
1438 | 'phase': lambda r: repo[r].phase(), |
|
1440 | 'phase': lambda r: repo[r].phase(), | |
1439 | 'substate': lambda r: repo[r].substate, |
|
1441 | 'substate': lambda r: repo[r].substate, | |
1440 | 'summary': lambda r: repo[r].description().splitlines()[0], |
|
1442 | 'summary': lambda r: repo[r].description().splitlines()[0], | |
1441 | 'diff': lambda r: list(repo[r].diff(git=True),) |
|
1443 | 'diff': lambda r: list(repo[r].diff(git=True),) | |
1442 | } |
|
1444 | } | |
1443 | for info in fields: |
|
1445 | for info in fields: | |
1444 | getfield = _funcs.get(info, None) |
|
1446 | getfield = _funcs.get(info, None) | |
1445 | if getfield is None: |
|
1447 | if getfield is None: | |
1446 | raise error.ParseError( |
|
1448 | raise error.ParseError( | |
1447 | # i18n: "matching" is a keyword |
|
1449 | # i18n: "matching" is a keyword | |
1448 | _("unexpected field name passed to matching: %s") % info) |
|
1450 | _("unexpected field name passed to matching: %s") % info) | |
1449 | getfieldfuncs.append(getfield) |
|
1451 | getfieldfuncs.append(getfield) | |
1450 | # convert the getfield array of functions into a "getinfo" function |
|
1452 | # convert the getfield array of functions into a "getinfo" function | |
1451 | # which returns an array of field values (or a single value if there |
|
1453 | # which returns an array of field values (or a single value if there | |
1452 | # is only one field to match) |
|
1454 | # is only one field to match) | |
1453 | getinfo = lambda r: [f(r) for f in getfieldfuncs] |
|
1455 | getinfo = lambda r: [f(r) for f in getfieldfuncs] | |
1454 |
|
1456 | |||
1455 | def matches(x): |
|
1457 | def matches(x): | |
1456 | for rev in revs: |
|
1458 | for rev in revs: | |
1457 | target = getinfo(rev) |
|
1459 | target = getinfo(rev) | |
1458 | match = True |
|
1460 | match = True | |
1459 | for n, f in enumerate(getfieldfuncs): |
|
1461 | for n, f in enumerate(getfieldfuncs): | |
1460 | if target[n] != f(x): |
|
1462 | if target[n] != f(x): | |
1461 | match = False |
|
1463 | match = False | |
1462 | if match: |
|
1464 | if match: | |
1463 | return True |
|
1465 | return True | |
1464 | return False |
|
1466 | return False | |
1465 |
|
1467 | |||
1466 | return subset.filter(matches) |
|
1468 | return subset.filter(matches) | |
1467 |
|
1469 | |||
1468 | def reverse(repo, subset, x): |
|
1470 | def reverse(repo, subset, x): | |
1469 | """``reverse(set)`` |
|
1471 | """``reverse(set)`` | |
1470 | Reverse order of set. |
|
1472 | Reverse order of set. | |
1471 | """ |
|
1473 | """ | |
1472 | l = getset(repo, subset, x) |
|
1474 | l = getset(repo, subset, x) | |
1473 | l.reverse() |
|
1475 | l.reverse() | |
1474 | return l |
|
1476 | return l | |
1475 |
|
1477 | |||
1476 | def roots(repo, subset, x): |
|
1478 | def roots(repo, subset, x): | |
1477 | """``roots(set)`` |
|
1479 | """``roots(set)`` | |
1478 | Changesets in set with no parent changeset in set. |
|
1480 | Changesets in set with no parent changeset in set. | |
1479 | """ |
|
1481 | """ | |
1480 | s = getset(repo, spanset(repo), x) |
|
1482 | s = getset(repo, spanset(repo), x) | |
1481 | subset = baseset([r for r in s if r in subset]) |
|
1483 | subset = baseset([r for r in s if r in subset]) | |
1482 | cs = _children(repo, subset, s) |
|
1484 | cs = _children(repo, subset, s) | |
1483 | return subset - cs |
|
1485 | return subset - cs | |
1484 |
|
1486 | |||
1485 | def secret(repo, subset, x): |
|
1487 | def secret(repo, subset, x): | |
1486 | """``secret()`` |
|
1488 | """``secret()`` | |
1487 | Changeset in secret phase.""" |
|
1489 | Changeset in secret phase.""" | |
1488 | # i18n: "secret" is a keyword |
|
1490 | # i18n: "secret" is a keyword | |
1489 | getargs(x, 0, 0, _("secret takes no arguments")) |
|
1491 | getargs(x, 0, 0, _("secret takes no arguments")) | |
1490 | phase = repo._phasecache.phase |
|
1492 | phase = repo._phasecache.phase | |
1491 | target = phases.secret |
|
1493 | target = phases.secret | |
1492 | condition = lambda r: phase(repo, r) == target |
|
1494 | condition = lambda r: phase(repo, r) == target | |
1493 | return subset.filter(condition, cache=False) |
|
1495 | return subset.filter(condition, cache=False) | |
1494 |
|
1496 | |||
1495 | def sort(repo, subset, x): |
|
1497 | def sort(repo, subset, x): | |
1496 | """``sort(set[, [-]key...])`` |
|
1498 | """``sort(set[, [-]key...])`` | |
1497 | Sort set by keys. The default sort order is ascending, specify a key |
|
1499 | Sort set by keys. The default sort order is ascending, specify a key | |
1498 | as ``-key`` to sort in descending order. |
|
1500 | as ``-key`` to sort in descending order. | |
1499 |
|
1501 | |||
1500 | The keys can be: |
|
1502 | The keys can be: | |
1501 |
|
1503 | |||
1502 | - ``rev`` for the revision number, |
|
1504 | - ``rev`` for the revision number, | |
1503 | - ``branch`` for the branch name, |
|
1505 | - ``branch`` for the branch name, | |
1504 | - ``desc`` for the commit message (description), |
|
1506 | - ``desc`` for the commit message (description), | |
1505 | - ``user`` for user name (``author`` can be used as an alias), |
|
1507 | - ``user`` for user name (``author`` can be used as an alias), | |
1506 | - ``date`` for the commit date |
|
1508 | - ``date`` for the commit date | |
1507 | """ |
|
1509 | """ | |
1508 | # i18n: "sort" is a keyword |
|
1510 | # i18n: "sort" is a keyword | |
1509 | l = getargs(x, 1, 2, _("sort requires one or two arguments")) |
|
1511 | l = getargs(x, 1, 2, _("sort requires one or two arguments")) | |
1510 | keys = "rev" |
|
1512 | keys = "rev" | |
1511 | if len(l) == 2: |
|
1513 | if len(l) == 2: | |
1512 | # i18n: "sort" is a keyword |
|
1514 | # i18n: "sort" is a keyword | |
1513 | keys = getstring(l[1], _("sort spec must be a string")) |
|
1515 | keys = getstring(l[1], _("sort spec must be a string")) | |
1514 |
|
1516 | |||
1515 | s = l[0] |
|
1517 | s = l[0] | |
1516 | keys = keys.split() |
|
1518 | keys = keys.split() | |
1517 | l = [] |
|
1519 | l = [] | |
1518 | def invert(s): |
|
1520 | def invert(s): | |
1519 | return "".join(chr(255 - ord(c)) for c in s) |
|
1521 | return "".join(chr(255 - ord(c)) for c in s) | |
1520 | revs = getset(repo, subset, s) |
|
1522 | revs = getset(repo, subset, s) | |
1521 | if keys == ["rev"]: |
|
1523 | if keys == ["rev"]: | |
1522 | revs.sort() |
|
1524 | revs.sort() | |
1523 | return revs |
|
1525 | return revs | |
1524 | elif keys == ["-rev"]: |
|
1526 | elif keys == ["-rev"]: | |
1525 | revs.sort(reverse=True) |
|
1527 | revs.sort(reverse=True) | |
1526 | return revs |
|
1528 | return revs | |
1527 | for r in revs: |
|
1529 | for r in revs: | |
1528 | c = repo[r] |
|
1530 | c = repo[r] | |
1529 | e = [] |
|
1531 | e = [] | |
1530 | for k in keys: |
|
1532 | for k in keys: | |
1531 | if k == 'rev': |
|
1533 | if k == 'rev': | |
1532 | e.append(r) |
|
1534 | e.append(r) | |
1533 | elif k == '-rev': |
|
1535 | elif k == '-rev': | |
1534 | e.append(-r) |
|
1536 | e.append(-r) | |
1535 | elif k == 'branch': |
|
1537 | elif k == 'branch': | |
1536 | e.append(c.branch()) |
|
1538 | e.append(c.branch()) | |
1537 | elif k == '-branch': |
|
1539 | elif k == '-branch': | |
1538 | e.append(invert(c.branch())) |
|
1540 | e.append(invert(c.branch())) | |
1539 | elif k == 'desc': |
|
1541 | elif k == 'desc': | |
1540 | e.append(c.description()) |
|
1542 | e.append(c.description()) | |
1541 | elif k == '-desc': |
|
1543 | elif k == '-desc': | |
1542 | e.append(invert(c.description())) |
|
1544 | e.append(invert(c.description())) | |
1543 | elif k in 'user author': |
|
1545 | elif k in 'user author': | |
1544 | e.append(c.user()) |
|
1546 | e.append(c.user()) | |
1545 | elif k in '-user -author': |
|
1547 | elif k in '-user -author': | |
1546 | e.append(invert(c.user())) |
|
1548 | e.append(invert(c.user())) | |
1547 | elif k == 'date': |
|
1549 | elif k == 'date': | |
1548 | e.append(c.date()[0]) |
|
1550 | e.append(c.date()[0]) | |
1549 | elif k == '-date': |
|
1551 | elif k == '-date': | |
1550 | e.append(-c.date()[0]) |
|
1552 | e.append(-c.date()[0]) | |
1551 | else: |
|
1553 | else: | |
1552 | raise error.ParseError(_("unknown sort key %r") % k) |
|
1554 | raise error.ParseError(_("unknown sort key %r") % k) | |
1553 | e.append(r) |
|
1555 | e.append(r) | |
1554 | l.append(e) |
|
1556 | l.append(e) | |
1555 | l.sort() |
|
1557 | l.sort() | |
1556 | return baseset([e[-1] for e in l]) |
|
1558 | return baseset([e[-1] for e in l]) | |
1557 |
|
1559 | |||
1558 | def _stringmatcher(pattern): |
|
1560 | def _stringmatcher(pattern): | |
1559 | """ |
|
1561 | """ | |
1560 | accepts a string, possibly starting with 're:' or 'literal:' prefix. |
|
1562 | accepts a string, possibly starting with 're:' or 'literal:' prefix. | |
1561 | returns the matcher name, pattern, and matcher function. |
|
1563 | returns the matcher name, pattern, and matcher function. | |
1562 | missing or unknown prefixes are treated as literal matches. |
|
1564 | missing or unknown prefixes are treated as literal matches. | |
1563 |
|
1565 | |||
1564 | helper for tests: |
|
1566 | helper for tests: | |
1565 | >>> def test(pattern, *tests): |
|
1567 | >>> def test(pattern, *tests): | |
1566 | ... kind, pattern, matcher = _stringmatcher(pattern) |
|
1568 | ... kind, pattern, matcher = _stringmatcher(pattern) | |
1567 | ... return (kind, pattern, [bool(matcher(t)) for t in tests]) |
|
1569 | ... return (kind, pattern, [bool(matcher(t)) for t in tests]) | |
1568 |
|
1570 | |||
1569 | exact matching (no prefix): |
|
1571 | exact matching (no prefix): | |
1570 | >>> test('abcdefg', 'abc', 'def', 'abcdefg') |
|
1572 | >>> test('abcdefg', 'abc', 'def', 'abcdefg') | |
1571 | ('literal', 'abcdefg', [False, False, True]) |
|
1573 | ('literal', 'abcdefg', [False, False, True]) | |
1572 |
|
1574 | |||
1573 | regex matching ('re:' prefix) |
|
1575 | regex matching ('re:' prefix) | |
1574 | >>> test('re:a.+b', 'nomatch', 'fooadef', 'fooadefbar') |
|
1576 | >>> test('re:a.+b', 'nomatch', 'fooadef', 'fooadefbar') | |
1575 | ('re', 'a.+b', [False, False, True]) |
|
1577 | ('re', 'a.+b', [False, False, True]) | |
1576 |
|
1578 | |||
1577 | force exact matches ('literal:' prefix) |
|
1579 | force exact matches ('literal:' prefix) | |
1578 | >>> test('literal:re:foobar', 'foobar', 're:foobar') |
|
1580 | >>> test('literal:re:foobar', 'foobar', 're:foobar') | |
1579 | ('literal', 're:foobar', [False, True]) |
|
1581 | ('literal', 're:foobar', [False, True]) | |
1580 |
|
1582 | |||
1581 | unknown prefixes are ignored and treated as literals |
|
1583 | unknown prefixes are ignored and treated as literals | |
1582 | >>> test('foo:bar', 'foo', 'bar', 'foo:bar') |
|
1584 | >>> test('foo:bar', 'foo', 'bar', 'foo:bar') | |
1583 | ('literal', 'foo:bar', [False, False, True]) |
|
1585 | ('literal', 'foo:bar', [False, False, True]) | |
1584 | """ |
|
1586 | """ | |
1585 | if pattern.startswith('re:'): |
|
1587 | if pattern.startswith('re:'): | |
1586 | pattern = pattern[3:] |
|
1588 | pattern = pattern[3:] | |
1587 | try: |
|
1589 | try: | |
1588 | regex = re.compile(pattern) |
|
1590 | regex = re.compile(pattern) | |
1589 | except re.error, e: |
|
1591 | except re.error, e: | |
1590 | raise error.ParseError(_('invalid regular expression: %s') |
|
1592 | raise error.ParseError(_('invalid regular expression: %s') | |
1591 | % e) |
|
1593 | % e) | |
1592 | return 're', pattern, regex.search |
|
1594 | return 're', pattern, regex.search | |
1593 | elif pattern.startswith('literal:'): |
|
1595 | elif pattern.startswith('literal:'): | |
1594 | pattern = pattern[8:] |
|
1596 | pattern = pattern[8:] | |
1595 | return 'literal', pattern, pattern.__eq__ |
|
1597 | return 'literal', pattern, pattern.__eq__ | |
1596 |
|
1598 | |||
1597 | def _substringmatcher(pattern): |
|
1599 | def _substringmatcher(pattern): | |
1598 | kind, pattern, matcher = _stringmatcher(pattern) |
|
1600 | kind, pattern, matcher = _stringmatcher(pattern) | |
1599 | if kind == 'literal': |
|
1601 | if kind == 'literal': | |
1600 | matcher = lambda s: pattern in s |
|
1602 | matcher = lambda s: pattern in s | |
1601 | return kind, pattern, matcher |
|
1603 | return kind, pattern, matcher | |
1602 |
|
1604 | |||
1603 | def tag(repo, subset, x): |
|
1605 | def tag(repo, subset, x): | |
1604 | """``tag([name])`` |
|
1606 | """``tag([name])`` | |
1605 | The specified tag by name, or all tagged revisions if no name is given. |
|
1607 | The specified tag by name, or all tagged revisions if no name is given. | |
1606 |
|
1608 | |||
1607 | If `name` starts with `re:`, the remainder of the name is treated as |
|
1609 | If `name` starts with `re:`, the remainder of the name is treated as | |
1608 | a regular expression. To match a tag that actually starts with `re:`, |
|
1610 | a regular expression. To match a tag that actually starts with `re:`, | |
1609 | use the prefix `literal:`. |
|
1611 | use the prefix `literal:`. | |
1610 | """ |
|
1612 | """ | |
1611 | # i18n: "tag" is a keyword |
|
1613 | # i18n: "tag" is a keyword | |
1612 | args = getargs(x, 0, 1, _("tag takes one or no arguments")) |
|
1614 | args = getargs(x, 0, 1, _("tag takes one or no arguments")) | |
1613 | cl = repo.changelog |
|
1615 | cl = repo.changelog | |
1614 | if args: |
|
1616 | if args: | |
1615 | pattern = getstring(args[0], |
|
1617 | pattern = getstring(args[0], | |
1616 | # i18n: "tag" is a keyword |
|
1618 | # i18n: "tag" is a keyword | |
1617 | _('the argument to tag must be a string')) |
|
1619 | _('the argument to tag must be a string')) | |
1618 | kind, pattern, matcher = _stringmatcher(pattern) |
|
1620 | kind, pattern, matcher = _stringmatcher(pattern) | |
1619 | if kind == 'literal': |
|
1621 | if kind == 'literal': | |
1620 | # avoid resolving all tags |
|
1622 | # avoid resolving all tags | |
1621 | tn = repo._tagscache.tags.get(pattern, None) |
|
1623 | tn = repo._tagscache.tags.get(pattern, None) | |
1622 | if tn is None: |
|
1624 | if tn is None: | |
1623 | raise util.Abort(_("tag '%s' does not exist") % pattern) |
|
1625 | raise util.Abort(_("tag '%s' does not exist") % pattern) | |
1624 | s = set([repo[tn].rev()]) |
|
1626 | s = set([repo[tn].rev()]) | |
1625 | else: |
|
1627 | else: | |
1626 | s = set([cl.rev(n) for t, n in repo.tagslist() if matcher(t)]) |
|
1628 | s = set([cl.rev(n) for t, n in repo.tagslist() if matcher(t)]) | |
1627 | else: |
|
1629 | else: | |
1628 | s = set([cl.rev(n) for t, n in repo.tagslist() if t != 'tip']) |
|
1630 | s = set([cl.rev(n) for t, n in repo.tagslist() if t != 'tip']) | |
1629 | return subset & s |
|
1631 | return subset & s | |
1630 |
|
1632 | |||
1631 | def tagged(repo, subset, x): |
|
1633 | def tagged(repo, subset, x): | |
1632 | return tag(repo, subset, x) |
|
1634 | return tag(repo, subset, x) | |
1633 |
|
1635 | |||
1634 | def unstable(repo, subset, x): |
|
1636 | def unstable(repo, subset, x): | |
1635 | """``unstable()`` |
|
1637 | """``unstable()`` | |
1636 | Non-obsolete changesets with obsolete ancestors. |
|
1638 | Non-obsolete changesets with obsolete ancestors. | |
1637 | """ |
|
1639 | """ | |
1638 | # i18n: "unstable" is a keyword |
|
1640 | # i18n: "unstable" is a keyword | |
1639 | getargs(x, 0, 0, _("unstable takes no arguments")) |
|
1641 | getargs(x, 0, 0, _("unstable takes no arguments")) | |
1640 | unstables = obsmod.getrevs(repo, 'unstable') |
|
1642 | unstables = obsmod.getrevs(repo, 'unstable') | |
1641 | return subset & unstables |
|
1643 | return subset & unstables | |
1642 |
|
1644 | |||
1643 |
|
1645 | |||
1644 | def user(repo, subset, x): |
|
1646 | def user(repo, subset, x): | |
1645 | """``user(string)`` |
|
1647 | """``user(string)`` | |
1646 | User name contains string. The match is case-insensitive. |
|
1648 | User name contains string. The match is case-insensitive. | |
1647 |
|
1649 | |||
1648 | If `string` starts with `re:`, the remainder of the string is treated as |
|
1650 | If `string` starts with `re:`, the remainder of the string is treated as | |
1649 | a regular expression. To match a user that actually contains `re:`, use |
|
1651 | a regular expression. To match a user that actually contains `re:`, use | |
1650 | the prefix `literal:`. |
|
1652 | the prefix `literal:`. | |
1651 | """ |
|
1653 | """ | |
1652 | return author(repo, subset, x) |
|
1654 | return author(repo, subset, x) | |
1653 |
|
1655 | |||
1654 | # for internal use |
|
1656 | # for internal use | |
1655 | def _list(repo, subset, x): |
|
1657 | def _list(repo, subset, x): | |
1656 | s = getstring(x, "internal error") |
|
1658 | s = getstring(x, "internal error") | |
1657 | if not s: |
|
1659 | if not s: | |
1658 | return baseset() |
|
1660 | return baseset() | |
1659 | ls = [repo[r].rev() for r in s.split('\0')] |
|
1661 | ls = [repo[r].rev() for r in s.split('\0')] | |
1660 | s = subset |
|
1662 | s = subset | |
1661 | return baseset([r for r in ls if r in s]) |
|
1663 | return baseset([r for r in ls if r in s]) | |
1662 |
|
1664 | |||
1663 | # for internal use |
|
1665 | # for internal use | |
1664 | def _intlist(repo, subset, x): |
|
1666 | def _intlist(repo, subset, x): | |
1665 | s = getstring(x, "internal error") |
|
1667 | s = getstring(x, "internal error") | |
1666 | if not s: |
|
1668 | if not s: | |
1667 | return baseset() |
|
1669 | return baseset() | |
1668 | ls = [int(r) for r in s.split('\0')] |
|
1670 | ls = [int(r) for r in s.split('\0')] | |
1669 | s = subset |
|
1671 | s = subset | |
1670 | return baseset([r for r in ls if r in s]) |
|
1672 | return baseset([r for r in ls if r in s]) | |
1671 |
|
1673 | |||
1672 | # for internal use |
|
1674 | # for internal use | |
1673 | def _hexlist(repo, subset, x): |
|
1675 | def _hexlist(repo, subset, x): | |
1674 | s = getstring(x, "internal error") |
|
1676 | s = getstring(x, "internal error") | |
1675 | if not s: |
|
1677 | if not s: | |
1676 | return baseset() |
|
1678 | return baseset() | |
1677 | cl = repo.changelog |
|
1679 | cl = repo.changelog | |
1678 | ls = [cl.rev(node.bin(r)) for r in s.split('\0')] |
|
1680 | ls = [cl.rev(node.bin(r)) for r in s.split('\0')] | |
1679 | s = subset |
|
1681 | s = subset | |
1680 | return baseset([r for r in ls if r in s]) |
|
1682 | return baseset([r for r in ls if r in s]) | |
1681 |
|
1683 | |||
1682 | symbols = { |
|
1684 | symbols = { | |
1683 | "adds": adds, |
|
1685 | "adds": adds, | |
1684 | "all": getall, |
|
1686 | "all": getall, | |
1685 | "ancestor": ancestor, |
|
1687 | "ancestor": ancestor, | |
1686 | "ancestors": ancestors, |
|
1688 | "ancestors": ancestors, | |
1687 | "_firstancestors": _firstancestors, |
|
1689 | "_firstancestors": _firstancestors, | |
1688 | "author": author, |
|
1690 | "author": author, | |
1689 | "only": only, |
|
1691 | "only": only, | |
1690 | "bisect": bisect, |
|
1692 | "bisect": bisect, | |
1691 | "bisected": bisected, |
|
1693 | "bisected": bisected, | |
1692 | "bookmark": bookmark, |
|
1694 | "bookmark": bookmark, | |
1693 | "branch": branch, |
|
1695 | "branch": branch, | |
1694 | "branchpoint": branchpoint, |
|
1696 | "branchpoint": branchpoint, | |
1695 | "bumped": bumped, |
|
1697 | "bumped": bumped, | |
1696 | "bundle": bundle, |
|
1698 | "bundle": bundle, | |
1697 | "children": children, |
|
1699 | "children": children, | |
1698 | "closed": closed, |
|
1700 | "closed": closed, | |
1699 | "contains": contains, |
|
1701 | "contains": contains, | |
1700 | "converted": converted, |
|
1702 | "converted": converted, | |
1701 | "date": date, |
|
1703 | "date": date, | |
1702 | "desc": desc, |
|
1704 | "desc": desc, | |
1703 | "descendants": descendants, |
|
1705 | "descendants": descendants, | |
1704 | "_firstdescendants": _firstdescendants, |
|
1706 | "_firstdescendants": _firstdescendants, | |
1705 | "destination": destination, |
|
1707 | "destination": destination, | |
1706 | "divergent": divergent, |
|
1708 | "divergent": divergent, | |
1707 | "draft": draft, |
|
1709 | "draft": draft, | |
1708 | "extinct": extinct, |
|
1710 | "extinct": extinct, | |
1709 | "extra": extra, |
|
1711 | "extra": extra, | |
1710 | "file": hasfile, |
|
1712 | "file": hasfile, | |
1711 | "filelog": filelog, |
|
1713 | "filelog": filelog, | |
1712 | "first": first, |
|
1714 | "first": first, | |
1713 | "follow": follow, |
|
1715 | "follow": follow, | |
1714 | "_followfirst": _followfirst, |
|
1716 | "_followfirst": _followfirst, | |
1715 | "grep": grep, |
|
1717 | "grep": grep, | |
1716 | "head": head, |
|
1718 | "head": head, | |
1717 | "heads": heads, |
|
1719 | "heads": heads, | |
1718 | "hidden": hidden, |
|
1720 | "hidden": hidden, | |
1719 | "id": node_, |
|
1721 | "id": node_, | |
1720 | "keyword": keyword, |
|
1722 | "keyword": keyword, | |
1721 | "last": last, |
|
1723 | "last": last, | |
1722 | "limit": limit, |
|
1724 | "limit": limit, | |
1723 | "_matchfiles": _matchfiles, |
|
1725 | "_matchfiles": _matchfiles, | |
1724 | "max": maxrev, |
|
1726 | "max": maxrev, | |
1725 | "merge": merge, |
|
1727 | "merge": merge, | |
1726 | "min": minrev, |
|
1728 | "min": minrev, | |
1727 | "modifies": modifies, |
|
1729 | "modifies": modifies, | |
1728 | "obsolete": obsolete, |
|
1730 | "obsolete": obsolete, | |
1729 | "origin": origin, |
|
1731 | "origin": origin, | |
1730 | "outgoing": outgoing, |
|
1732 | "outgoing": outgoing, | |
1731 | "p1": p1, |
|
1733 | "p1": p1, | |
1732 | "p2": p2, |
|
1734 | "p2": p2, | |
1733 | "parents": parents, |
|
1735 | "parents": parents, | |
1734 | "present": present, |
|
1736 | "present": present, | |
1735 | "public": public, |
|
1737 | "public": public, | |
1736 | "remote": remote, |
|
1738 | "remote": remote, | |
1737 | "removes": removes, |
|
1739 | "removes": removes, | |
1738 | "rev": rev, |
|
1740 | "rev": rev, | |
1739 | "reverse": reverse, |
|
1741 | "reverse": reverse, | |
1740 | "roots": roots, |
|
1742 | "roots": roots, | |
1741 | "sort": sort, |
|
1743 | "sort": sort, | |
1742 | "secret": secret, |
|
1744 | "secret": secret, | |
1743 | "matching": matching, |
|
1745 | "matching": matching, | |
1744 | "tag": tag, |
|
1746 | "tag": tag, | |
1745 | "tagged": tagged, |
|
1747 | "tagged": tagged, | |
1746 | "user": user, |
|
1748 | "user": user, | |
1747 | "unstable": unstable, |
|
1749 | "unstable": unstable, | |
1748 | "_list": _list, |
|
1750 | "_list": _list, | |
1749 | "_intlist": _intlist, |
|
1751 | "_intlist": _intlist, | |
1750 | "_hexlist": _hexlist, |
|
1752 | "_hexlist": _hexlist, | |
1751 | } |
|
1753 | } | |
1752 |
|
1754 | |||
1753 | # symbols which can't be used for a DoS attack for any given input |
|
1755 | # symbols which can't be used for a DoS attack for any given input | |
1754 | # (e.g. those which accept regexes as plain strings shouldn't be included) |
|
1756 | # (e.g. those which accept regexes as plain strings shouldn't be included) | |
1755 | # functions that just return a lot of changesets (like all) don't count here |
|
1757 | # functions that just return a lot of changesets (like all) don't count here | |
1756 | safesymbols = set([ |
|
1758 | safesymbols = set([ | |
1757 | "adds", |
|
1759 | "adds", | |
1758 | "all", |
|
1760 | "all", | |
1759 | "ancestor", |
|
1761 | "ancestor", | |
1760 | "ancestors", |
|
1762 | "ancestors", | |
1761 | "_firstancestors", |
|
1763 | "_firstancestors", | |
1762 | "author", |
|
1764 | "author", | |
1763 | "bisect", |
|
1765 | "bisect", | |
1764 | "bisected", |
|
1766 | "bisected", | |
1765 | "bookmark", |
|
1767 | "bookmark", | |
1766 | "branch", |
|
1768 | "branch", | |
1767 | "branchpoint", |
|
1769 | "branchpoint", | |
1768 | "bumped", |
|
1770 | "bumped", | |
1769 | "bundle", |
|
1771 | "bundle", | |
1770 | "children", |
|
1772 | "children", | |
1771 | "closed", |
|
1773 | "closed", | |
1772 | "converted", |
|
1774 | "converted", | |
1773 | "date", |
|
1775 | "date", | |
1774 | "desc", |
|
1776 | "desc", | |
1775 | "descendants", |
|
1777 | "descendants", | |
1776 | "_firstdescendants", |
|
1778 | "_firstdescendants", | |
1777 | "destination", |
|
1779 | "destination", | |
1778 | "divergent", |
|
1780 | "divergent", | |
1779 | "draft", |
|
1781 | "draft", | |
1780 | "extinct", |
|
1782 | "extinct", | |
1781 | "extra", |
|
1783 | "extra", | |
1782 | "file", |
|
1784 | "file", | |
1783 | "filelog", |
|
1785 | "filelog", | |
1784 | "first", |
|
1786 | "first", | |
1785 | "follow", |
|
1787 | "follow", | |
1786 | "_followfirst", |
|
1788 | "_followfirst", | |
1787 | "head", |
|
1789 | "head", | |
1788 | "heads", |
|
1790 | "heads", | |
1789 | "hidden", |
|
1791 | "hidden", | |
1790 | "id", |
|
1792 | "id", | |
1791 | "keyword", |
|
1793 | "keyword", | |
1792 | "last", |
|
1794 | "last", | |
1793 | "limit", |
|
1795 | "limit", | |
1794 | "_matchfiles", |
|
1796 | "_matchfiles", | |
1795 | "max", |
|
1797 | "max", | |
1796 | "merge", |
|
1798 | "merge", | |
1797 | "min", |
|
1799 | "min", | |
1798 | "modifies", |
|
1800 | "modifies", | |
1799 | "obsolete", |
|
1801 | "obsolete", | |
1800 | "origin", |
|
1802 | "origin", | |
1801 | "outgoing", |
|
1803 | "outgoing", | |
1802 | "p1", |
|
1804 | "p1", | |
1803 | "p2", |
|
1805 | "p2", | |
1804 | "parents", |
|
1806 | "parents", | |
1805 | "present", |
|
1807 | "present", | |
1806 | "public", |
|
1808 | "public", | |
1807 | "remote", |
|
1809 | "remote", | |
1808 | "removes", |
|
1810 | "removes", | |
1809 | "rev", |
|
1811 | "rev", | |
1810 | "reverse", |
|
1812 | "reverse", | |
1811 | "roots", |
|
1813 | "roots", | |
1812 | "sort", |
|
1814 | "sort", | |
1813 | "secret", |
|
1815 | "secret", | |
1814 | "matching", |
|
1816 | "matching", | |
1815 | "tag", |
|
1817 | "tag", | |
1816 | "tagged", |
|
1818 | "tagged", | |
1817 | "user", |
|
1819 | "user", | |
1818 | "unstable", |
|
1820 | "unstable", | |
1819 | "_list", |
|
1821 | "_list", | |
1820 | "_intlist", |
|
1822 | "_intlist", | |
1821 | "_hexlist", |
|
1823 | "_hexlist", | |
1822 | ]) |
|
1824 | ]) | |
1823 |
|
1825 | |||
1824 | methods = { |
|
1826 | methods = { | |
1825 | "range": rangeset, |
|
1827 | "range": rangeset, | |
1826 | "dagrange": dagrange, |
|
1828 | "dagrange": dagrange, | |
1827 | "string": stringset, |
|
1829 | "string": stringset, | |
1828 | "symbol": symbolset, |
|
1830 | "symbol": symbolset, | |
1829 | "and": andset, |
|
1831 | "and": andset, | |
1830 | "or": orset, |
|
1832 | "or": orset, | |
1831 | "not": notset, |
|
1833 | "not": notset, | |
1832 | "list": listset, |
|
1834 | "list": listset, | |
1833 | "func": func, |
|
1835 | "func": func, | |
1834 | "ancestor": ancestorspec, |
|
1836 | "ancestor": ancestorspec, | |
1835 | "parent": parentspec, |
|
1837 | "parent": parentspec, | |
1836 | "parentpost": p1, |
|
1838 | "parentpost": p1, | |
1837 | } |
|
1839 | } | |
1838 |
|
1840 | |||
1839 | def optimize(x, small): |
|
1841 | def optimize(x, small): | |
1840 | if x is None: |
|
1842 | if x is None: | |
1841 | return 0, x |
|
1843 | return 0, x | |
1842 |
|
1844 | |||
1843 | smallbonus = 1 |
|
1845 | smallbonus = 1 | |
1844 | if small: |
|
1846 | if small: | |
1845 | smallbonus = .5 |
|
1847 | smallbonus = .5 | |
1846 |
|
1848 | |||
1847 | op = x[0] |
|
1849 | op = x[0] | |
1848 | if op == 'minus': |
|
1850 | if op == 'minus': | |
1849 | return optimize(('and', x[1], ('not', x[2])), small) |
|
1851 | return optimize(('and', x[1], ('not', x[2])), small) | |
1850 | elif op == 'dagrangepre': |
|
1852 | elif op == 'dagrangepre': | |
1851 | return optimize(('func', ('symbol', 'ancestors'), x[1]), small) |
|
1853 | return optimize(('func', ('symbol', 'ancestors'), x[1]), small) | |
1852 | elif op == 'dagrangepost': |
|
1854 | elif op == 'dagrangepost': | |
1853 | return optimize(('func', ('symbol', 'descendants'), x[1]), small) |
|
1855 | return optimize(('func', ('symbol', 'descendants'), x[1]), small) | |
1854 | elif op == 'rangepre': |
|
1856 | elif op == 'rangepre': | |
1855 | return optimize(('range', ('string', '0'), x[1]), small) |
|
1857 | return optimize(('range', ('string', '0'), x[1]), small) | |
1856 | elif op == 'rangepost': |
|
1858 | elif op == 'rangepost': | |
1857 | return optimize(('range', x[1], ('string', 'tip')), small) |
|
1859 | return optimize(('range', x[1], ('string', 'tip')), small) | |
1858 | elif op == 'negate': |
|
1860 | elif op == 'negate': | |
1859 | return optimize(('string', |
|
1861 | return optimize(('string', | |
1860 | '-' + getstring(x[1], _("can't negate that"))), small) |
|
1862 | '-' + getstring(x[1], _("can't negate that"))), small) | |
1861 | elif op in 'string symbol negate': |
|
1863 | elif op in 'string symbol negate': | |
1862 | return smallbonus, x # single revisions are small |
|
1864 | return smallbonus, x # single revisions are small | |
1863 | elif op == 'and': |
|
1865 | elif op == 'and': | |
1864 | wa, ta = optimize(x[1], True) |
|
1866 | wa, ta = optimize(x[1], True) | |
1865 | wb, tb = optimize(x[2], True) |
|
1867 | wb, tb = optimize(x[2], True) | |
1866 |
|
1868 | |||
1867 | # (::x and not ::y)/(not ::y and ::x) have a fast path |
|
1869 | # (::x and not ::y)/(not ::y and ::x) have a fast path | |
1868 | def isonly(revs, bases): |
|
1870 | def isonly(revs, bases): | |
1869 | return ( |
|
1871 | return ( | |
1870 | revs[0] == 'func' |
|
1872 | revs[0] == 'func' | |
1871 | and getstring(revs[1], _('not a symbol')) == 'ancestors' |
|
1873 | and getstring(revs[1], _('not a symbol')) == 'ancestors' | |
1872 | and bases[0] == 'not' |
|
1874 | and bases[0] == 'not' | |
1873 | and bases[1][0] == 'func' |
|
1875 | and bases[1][0] == 'func' | |
1874 | and getstring(bases[1][1], _('not a symbol')) == 'ancestors') |
|
1876 | and getstring(bases[1][1], _('not a symbol')) == 'ancestors') | |
1875 |
|
1877 | |||
1876 | w = min(wa, wb) |
|
1878 | w = min(wa, wb) | |
1877 | if isonly(ta, tb): |
|
1879 | if isonly(ta, tb): | |
1878 | return w, ('func', ('symbol', 'only'), ('list', ta[2], tb[1][2])) |
|
1880 | return w, ('func', ('symbol', 'only'), ('list', ta[2], tb[1][2])) | |
1879 | if isonly(tb, ta): |
|
1881 | if isonly(tb, ta): | |
1880 | return w, ('func', ('symbol', 'only'), ('list', tb[2], ta[1][2])) |
|
1882 | return w, ('func', ('symbol', 'only'), ('list', tb[2], ta[1][2])) | |
1881 |
|
1883 | |||
1882 | if wa > wb: |
|
1884 | if wa > wb: | |
1883 | return w, (op, tb, ta) |
|
1885 | return w, (op, tb, ta) | |
1884 | return w, (op, ta, tb) |
|
1886 | return w, (op, ta, tb) | |
1885 | elif op == 'or': |
|
1887 | elif op == 'or': | |
1886 | wa, ta = optimize(x[1], False) |
|
1888 | wa, ta = optimize(x[1], False) | |
1887 | wb, tb = optimize(x[2], False) |
|
1889 | wb, tb = optimize(x[2], False) | |
1888 | if wb < wa: |
|
1890 | if wb < wa: | |
1889 | wb, wa = wa, wb |
|
1891 | wb, wa = wa, wb | |
1890 | return max(wa, wb), (op, ta, tb) |
|
1892 | return max(wa, wb), (op, ta, tb) | |
1891 | elif op == 'not': |
|
1893 | elif op == 'not': | |
1892 | o = optimize(x[1], not small) |
|
1894 | o = optimize(x[1], not small) | |
1893 | return o[0], (op, o[1]) |
|
1895 | return o[0], (op, o[1]) | |
1894 | elif op == 'parentpost': |
|
1896 | elif op == 'parentpost': | |
1895 | o = optimize(x[1], small) |
|
1897 | o = optimize(x[1], small) | |
1896 | return o[0], (op, o[1]) |
|
1898 | return o[0], (op, o[1]) | |
1897 | elif op == 'group': |
|
1899 | elif op == 'group': | |
1898 | return optimize(x[1], small) |
|
1900 | return optimize(x[1], small) | |
1899 | elif op in 'dagrange range list parent ancestorspec': |
|
1901 | elif op in 'dagrange range list parent ancestorspec': | |
1900 | if op == 'parent': |
|
1902 | if op == 'parent': | |
1901 | # x^:y means (x^) : y, not x ^ (:y) |
|
1903 | # x^:y means (x^) : y, not x ^ (:y) | |
1902 | post = ('parentpost', x[1]) |
|
1904 | post = ('parentpost', x[1]) | |
1903 | if x[2][0] == 'dagrangepre': |
|
1905 | if x[2][0] == 'dagrangepre': | |
1904 | return optimize(('dagrange', post, x[2][1]), small) |
|
1906 | return optimize(('dagrange', post, x[2][1]), small) | |
1905 | elif x[2][0] == 'rangepre': |
|
1907 | elif x[2][0] == 'rangepre': | |
1906 | return optimize(('range', post, x[2][1]), small) |
|
1908 | return optimize(('range', post, x[2][1]), small) | |
1907 |
|
1909 | |||
1908 | wa, ta = optimize(x[1], small) |
|
1910 | wa, ta = optimize(x[1], small) | |
1909 | wb, tb = optimize(x[2], small) |
|
1911 | wb, tb = optimize(x[2], small) | |
1910 | return wa + wb, (op, ta, tb) |
|
1912 | return wa + wb, (op, ta, tb) | |
1911 | elif op == 'func': |
|
1913 | elif op == 'func': | |
1912 | f = getstring(x[1], _("not a symbol")) |
|
1914 | f = getstring(x[1], _("not a symbol")) | |
1913 | wa, ta = optimize(x[2], small) |
|
1915 | wa, ta = optimize(x[2], small) | |
1914 | if f in ("author branch closed date desc file grep keyword " |
|
1916 | if f in ("author branch closed date desc file grep keyword " | |
1915 | "outgoing user"): |
|
1917 | "outgoing user"): | |
1916 | w = 10 # slow |
|
1918 | w = 10 # slow | |
1917 | elif f in "modifies adds removes": |
|
1919 | elif f in "modifies adds removes": | |
1918 | w = 30 # slower |
|
1920 | w = 30 # slower | |
1919 | elif f == "contains": |
|
1921 | elif f == "contains": | |
1920 | w = 100 # very slow |
|
1922 | w = 100 # very slow | |
1921 | elif f == "ancestor": |
|
1923 | elif f == "ancestor": | |
1922 | w = 1 * smallbonus |
|
1924 | w = 1 * smallbonus | |
1923 | elif f in "reverse limit first _intlist": |
|
1925 | elif f in "reverse limit first _intlist": | |
1924 | w = 0 |
|
1926 | w = 0 | |
1925 | elif f in "sort": |
|
1927 | elif f in "sort": | |
1926 | w = 10 # assume most sorts look at changelog |
|
1928 | w = 10 # assume most sorts look at changelog | |
1927 | else: |
|
1929 | else: | |
1928 | w = 1 |
|
1930 | w = 1 | |
1929 | return w + wa, (op, x[1], ta) |
|
1931 | return w + wa, (op, x[1], ta) | |
1930 | return 1, x |
|
1932 | return 1, x | |
1931 |
|
1933 | |||
1932 | _aliasarg = ('func', ('symbol', '_aliasarg')) |
|
1934 | _aliasarg = ('func', ('symbol', '_aliasarg')) | |
1933 | def _getaliasarg(tree): |
|
1935 | def _getaliasarg(tree): | |
1934 | """If tree matches ('func', ('symbol', '_aliasarg'), ('string', X)) |
|
1936 | """If tree matches ('func', ('symbol', '_aliasarg'), ('string', X)) | |
1935 | return X, None otherwise. |
|
1937 | return X, None otherwise. | |
1936 | """ |
|
1938 | """ | |
1937 | if (len(tree) == 3 and tree[:2] == _aliasarg |
|
1939 | if (len(tree) == 3 and tree[:2] == _aliasarg | |
1938 | and tree[2][0] == 'string'): |
|
1940 | and tree[2][0] == 'string'): | |
1939 | return tree[2][1] |
|
1941 | return tree[2][1] | |
1940 | return None |
|
1942 | return None | |
1941 |
|
1943 | |||
1942 | def _checkaliasarg(tree, known=None): |
|
1944 | def _checkaliasarg(tree, known=None): | |
1943 | """Check tree contains no _aliasarg construct or only ones which |
|
1945 | """Check tree contains no _aliasarg construct or only ones which | |
1944 | value is in known. Used to avoid alias placeholders injection. |
|
1946 | value is in known. Used to avoid alias placeholders injection. | |
1945 | """ |
|
1947 | """ | |
1946 | if isinstance(tree, tuple): |
|
1948 | if isinstance(tree, tuple): | |
1947 | arg = _getaliasarg(tree) |
|
1949 | arg = _getaliasarg(tree) | |
1948 | if arg is not None and (not known or arg not in known): |
|
1950 | if arg is not None and (not known or arg not in known): | |
1949 | raise error.ParseError(_("not a function: %s") % '_aliasarg') |
|
1951 | raise error.ParseError(_("not a function: %s") % '_aliasarg') | |
1950 | for t in tree: |
|
1952 | for t in tree: | |
1951 | _checkaliasarg(t, known) |
|
1953 | _checkaliasarg(t, known) | |
1952 |
|
1954 | |||
1953 | class revsetalias(object): |
|
1955 | class revsetalias(object): | |
1954 | funcre = re.compile('^([^(]+)\(([^)]+)\)$') |
|
1956 | funcre = re.compile('^([^(]+)\(([^)]+)\)$') | |
1955 | args = None |
|
1957 | args = None | |
1956 |
|
1958 | |||
1957 | def __init__(self, name, value): |
|
1959 | def __init__(self, name, value): | |
1958 | '''Aliases like: |
|
1960 | '''Aliases like: | |
1959 |
|
1961 | |||
1960 | h = heads(default) |
|
1962 | h = heads(default) | |
1961 | b($1) = ancestors($1) - ancestors(default) |
|
1963 | b($1) = ancestors($1) - ancestors(default) | |
1962 | ''' |
|
1964 | ''' | |
1963 | m = self.funcre.search(name) |
|
1965 | m = self.funcre.search(name) | |
1964 | if m: |
|
1966 | if m: | |
1965 | self.name = m.group(1) |
|
1967 | self.name = m.group(1) | |
1966 | self.tree = ('func', ('symbol', m.group(1))) |
|
1968 | self.tree = ('func', ('symbol', m.group(1))) | |
1967 | self.args = [x.strip() for x in m.group(2).split(',')] |
|
1969 | self.args = [x.strip() for x in m.group(2).split(',')] | |
1968 | for arg in self.args: |
|
1970 | for arg in self.args: | |
1969 | # _aliasarg() is an unknown symbol only used separate |
|
1971 | # _aliasarg() is an unknown symbol only used separate | |
1970 | # alias argument placeholders from regular strings. |
|
1972 | # alias argument placeholders from regular strings. | |
1971 | value = value.replace(arg, '_aliasarg(%r)' % (arg,)) |
|
1973 | value = value.replace(arg, '_aliasarg(%r)' % (arg,)) | |
1972 | else: |
|
1974 | else: | |
1973 | self.name = name |
|
1975 | self.name = name | |
1974 | self.tree = ('symbol', name) |
|
1976 | self.tree = ('symbol', name) | |
1975 |
|
1977 | |||
1976 | self.replacement, pos = parse(value) |
|
1978 | self.replacement, pos = parse(value) | |
1977 | if pos != len(value): |
|
1979 | if pos != len(value): | |
1978 | raise error.ParseError(_('invalid token'), pos) |
|
1980 | raise error.ParseError(_('invalid token'), pos) | |
1979 | # Check for placeholder injection |
|
1981 | # Check for placeholder injection | |
1980 | _checkaliasarg(self.replacement, self.args) |
|
1982 | _checkaliasarg(self.replacement, self.args) | |
1981 |
|
1983 | |||
1982 | def _getalias(aliases, tree): |
|
1984 | def _getalias(aliases, tree): | |
1983 | """If tree looks like an unexpanded alias, return it. Return None |
|
1985 | """If tree looks like an unexpanded alias, return it. Return None | |
1984 | otherwise. |
|
1986 | otherwise. | |
1985 | """ |
|
1987 | """ | |
1986 | if isinstance(tree, tuple) and tree: |
|
1988 | if isinstance(tree, tuple) and tree: | |
1987 | if tree[0] == 'symbol' and len(tree) == 2: |
|
1989 | if tree[0] == 'symbol' and len(tree) == 2: | |
1988 | name = tree[1] |
|
1990 | name = tree[1] | |
1989 | alias = aliases.get(name) |
|
1991 | alias = aliases.get(name) | |
1990 | if alias and alias.args is None and alias.tree == tree: |
|
1992 | if alias and alias.args is None and alias.tree == tree: | |
1991 | return alias |
|
1993 | return alias | |
1992 | if tree[0] == 'func' and len(tree) > 1: |
|
1994 | if tree[0] == 'func' and len(tree) > 1: | |
1993 | if tree[1][0] == 'symbol' and len(tree[1]) == 2: |
|
1995 | if tree[1][0] == 'symbol' and len(tree[1]) == 2: | |
1994 | name = tree[1][1] |
|
1996 | name = tree[1][1] | |
1995 | alias = aliases.get(name) |
|
1997 | alias = aliases.get(name) | |
1996 | if alias and alias.args is not None and alias.tree == tree[:2]: |
|
1998 | if alias and alias.args is not None and alias.tree == tree[:2]: | |
1997 | return alias |
|
1999 | return alias | |
1998 | return None |
|
2000 | return None | |
1999 |
|
2001 | |||
2000 | def _expandargs(tree, args): |
|
2002 | def _expandargs(tree, args): | |
2001 | """Replace _aliasarg instances with the substitution value of the |
|
2003 | """Replace _aliasarg instances with the substitution value of the | |
2002 | same name in args, recursively. |
|
2004 | same name in args, recursively. | |
2003 | """ |
|
2005 | """ | |
2004 | if not tree or not isinstance(tree, tuple): |
|
2006 | if not tree or not isinstance(tree, tuple): | |
2005 | return tree |
|
2007 | return tree | |
2006 | arg = _getaliasarg(tree) |
|
2008 | arg = _getaliasarg(tree) | |
2007 | if arg is not None: |
|
2009 | if arg is not None: | |
2008 | return args[arg] |
|
2010 | return args[arg] | |
2009 | return tuple(_expandargs(t, args) for t in tree) |
|
2011 | return tuple(_expandargs(t, args) for t in tree) | |
2010 |
|
2012 | |||
2011 | def _expandaliases(aliases, tree, expanding, cache): |
|
2013 | def _expandaliases(aliases, tree, expanding, cache): | |
2012 | """Expand aliases in tree, recursively. |
|
2014 | """Expand aliases in tree, recursively. | |
2013 |
|
2015 | |||
2014 | 'aliases' is a dictionary mapping user defined aliases to |
|
2016 | 'aliases' is a dictionary mapping user defined aliases to | |
2015 | revsetalias objects. |
|
2017 | revsetalias objects. | |
2016 | """ |
|
2018 | """ | |
2017 | if not isinstance(tree, tuple): |
|
2019 | if not isinstance(tree, tuple): | |
2018 | # Do not expand raw strings |
|
2020 | # Do not expand raw strings | |
2019 | return tree |
|
2021 | return tree | |
2020 | alias = _getalias(aliases, tree) |
|
2022 | alias = _getalias(aliases, tree) | |
2021 | if alias is not None: |
|
2023 | if alias is not None: | |
2022 | if alias in expanding: |
|
2024 | if alias in expanding: | |
2023 | raise error.ParseError(_('infinite expansion of revset alias "%s" ' |
|
2025 | raise error.ParseError(_('infinite expansion of revset alias "%s" ' | |
2024 | 'detected') % alias.name) |
|
2026 | 'detected') % alias.name) | |
2025 | expanding.append(alias) |
|
2027 | expanding.append(alias) | |
2026 | if alias.name not in cache: |
|
2028 | if alias.name not in cache: | |
2027 | cache[alias.name] = _expandaliases(aliases, alias.replacement, |
|
2029 | cache[alias.name] = _expandaliases(aliases, alias.replacement, | |
2028 | expanding, cache) |
|
2030 | expanding, cache) | |
2029 | result = cache[alias.name] |
|
2031 | result = cache[alias.name] | |
2030 | expanding.pop() |
|
2032 | expanding.pop() | |
2031 | if alias.args is not None: |
|
2033 | if alias.args is not None: | |
2032 | l = getlist(tree[2]) |
|
2034 | l = getlist(tree[2]) | |
2033 | if len(l) != len(alias.args): |
|
2035 | if len(l) != len(alias.args): | |
2034 | raise error.ParseError( |
|
2036 | raise error.ParseError( | |
2035 | _('invalid number of arguments: %s') % len(l)) |
|
2037 | _('invalid number of arguments: %s') % len(l)) | |
2036 | l = [_expandaliases(aliases, a, [], cache) for a in l] |
|
2038 | l = [_expandaliases(aliases, a, [], cache) for a in l] | |
2037 | result = _expandargs(result, dict(zip(alias.args, l))) |
|
2039 | result = _expandargs(result, dict(zip(alias.args, l))) | |
2038 | else: |
|
2040 | else: | |
2039 | result = tuple(_expandaliases(aliases, t, expanding, cache) |
|
2041 | result = tuple(_expandaliases(aliases, t, expanding, cache) | |
2040 | for t in tree) |
|
2042 | for t in tree) | |
2041 | return result |
|
2043 | return result | |
2042 |
|
2044 | |||
2043 | def findaliases(ui, tree): |
|
2045 | def findaliases(ui, tree): | |
2044 | _checkaliasarg(tree) |
|
2046 | _checkaliasarg(tree) | |
2045 | aliases = {} |
|
2047 | aliases = {} | |
2046 | for k, v in ui.configitems('revsetalias'): |
|
2048 | for k, v in ui.configitems('revsetalias'): | |
2047 | alias = revsetalias(k, v) |
|
2049 | alias = revsetalias(k, v) | |
2048 | aliases[alias.name] = alias |
|
2050 | aliases[alias.name] = alias | |
2049 | return _expandaliases(aliases, tree, [], {}) |
|
2051 | return _expandaliases(aliases, tree, [], {}) | |
2050 |
|
2052 | |||
2051 | def parse(spec, lookup=None): |
|
2053 | def parse(spec, lookup=None): | |
2052 | p = parser.parser(tokenize, elements) |
|
2054 | p = parser.parser(tokenize, elements) | |
2053 | return p.parse(spec, lookup=lookup) |
|
2055 | return p.parse(spec, lookup=lookup) | |
2054 |
|
2056 | |||
2055 | def match(ui, spec, repo=None): |
|
2057 | def match(ui, spec, repo=None): | |
2056 | if not spec: |
|
2058 | if not spec: | |
2057 | raise error.ParseError(_("empty query")) |
|
2059 | raise error.ParseError(_("empty query")) | |
2058 | lookup = None |
|
2060 | lookup = None | |
2059 | if repo: |
|
2061 | if repo: | |
2060 | lookup = repo.__contains__ |
|
2062 | lookup = repo.__contains__ | |
2061 | tree, pos = parse(spec, lookup) |
|
2063 | tree, pos = parse(spec, lookup) | |
2062 | if (pos != len(spec)): |
|
2064 | if (pos != len(spec)): | |
2063 | raise error.ParseError(_("invalid token"), pos) |
|
2065 | raise error.ParseError(_("invalid token"), pos) | |
2064 | if ui: |
|
2066 | if ui: | |
2065 | tree = findaliases(ui, tree) |
|
2067 | tree = findaliases(ui, tree) | |
2066 | weight, tree = optimize(tree, True) |
|
2068 | weight, tree = optimize(tree, True) | |
2067 | def mfunc(repo, subset): |
|
2069 | def mfunc(repo, subset): | |
2068 | if util.safehasattr(subset, 'isascending'): |
|
2070 | if util.safehasattr(subset, 'isascending'): | |
2069 | result = getset(repo, subset, tree) |
|
2071 | result = getset(repo, subset, tree) | |
2070 | else: |
|
2072 | else: | |
2071 | result = getset(repo, baseset(subset), tree) |
|
2073 | result = getset(repo, baseset(subset), tree) | |
2072 | return result |
|
2074 | return result | |
2073 | return mfunc |
|
2075 | return mfunc | |
2074 |
|
2076 | |||
2075 | def formatspec(expr, *args): |
|
2077 | def formatspec(expr, *args): | |
2076 | ''' |
|
2078 | ''' | |
2077 | This is a convenience function for using revsets internally, and |
|
2079 | This is a convenience function for using revsets internally, and | |
2078 | escapes arguments appropriately. Aliases are intentionally ignored |
|
2080 | escapes arguments appropriately. Aliases are intentionally ignored | |
2079 | so that intended expression behavior isn't accidentally subverted. |
|
2081 | so that intended expression behavior isn't accidentally subverted. | |
2080 |
|
2082 | |||
2081 | Supported arguments: |
|
2083 | Supported arguments: | |
2082 |
|
2084 | |||
2083 | %r = revset expression, parenthesized |
|
2085 | %r = revset expression, parenthesized | |
2084 | %d = int(arg), no quoting |
|
2086 | %d = int(arg), no quoting | |
2085 | %s = string(arg), escaped and single-quoted |
|
2087 | %s = string(arg), escaped and single-quoted | |
2086 | %b = arg.branch(), escaped and single-quoted |
|
2088 | %b = arg.branch(), escaped and single-quoted | |
2087 | %n = hex(arg), single-quoted |
|
2089 | %n = hex(arg), single-quoted | |
2088 | %% = a literal '%' |
|
2090 | %% = a literal '%' | |
2089 |
|
2091 | |||
2090 | Prefixing the type with 'l' specifies a parenthesized list of that type. |
|
2092 | Prefixing the type with 'l' specifies a parenthesized list of that type. | |
2091 |
|
2093 | |||
2092 | >>> formatspec('%r:: and %lr', '10 or 11', ("this()", "that()")) |
|
2094 | >>> formatspec('%r:: and %lr', '10 or 11', ("this()", "that()")) | |
2093 | '(10 or 11):: and ((this()) or (that()))' |
|
2095 | '(10 or 11):: and ((this()) or (that()))' | |
2094 | >>> formatspec('%d:: and not %d::', 10, 20) |
|
2096 | >>> formatspec('%d:: and not %d::', 10, 20) | |
2095 | '10:: and not 20::' |
|
2097 | '10:: and not 20::' | |
2096 | >>> formatspec('%ld or %ld', [], [1]) |
|
2098 | >>> formatspec('%ld or %ld', [], [1]) | |
2097 | "_list('') or 1" |
|
2099 | "_list('') or 1" | |
2098 | >>> formatspec('keyword(%s)', 'foo\\xe9') |
|
2100 | >>> formatspec('keyword(%s)', 'foo\\xe9') | |
2099 | "keyword('foo\\\\xe9')" |
|
2101 | "keyword('foo\\\\xe9')" | |
2100 | >>> b = lambda: 'default' |
|
2102 | >>> b = lambda: 'default' | |
2101 | >>> b.branch = b |
|
2103 | >>> b.branch = b | |
2102 | >>> formatspec('branch(%b)', b) |
|
2104 | >>> formatspec('branch(%b)', b) | |
2103 | "branch('default')" |
|
2105 | "branch('default')" | |
2104 | >>> formatspec('root(%ls)', ['a', 'b', 'c', 'd']) |
|
2106 | >>> formatspec('root(%ls)', ['a', 'b', 'c', 'd']) | |
2105 | "root(_list('a\\x00b\\x00c\\x00d'))" |
|
2107 | "root(_list('a\\x00b\\x00c\\x00d'))" | |
2106 | ''' |
|
2108 | ''' | |
2107 |
|
2109 | |||
2108 | def quote(s): |
|
2110 | def quote(s): | |
2109 | return repr(str(s)) |
|
2111 | return repr(str(s)) | |
2110 |
|
2112 | |||
2111 | def argtype(c, arg): |
|
2113 | def argtype(c, arg): | |
2112 | if c == 'd': |
|
2114 | if c == 'd': | |
2113 | return str(int(arg)) |
|
2115 | return str(int(arg)) | |
2114 | elif c == 's': |
|
2116 | elif c == 's': | |
2115 | return quote(arg) |
|
2117 | return quote(arg) | |
2116 | elif c == 'r': |
|
2118 | elif c == 'r': | |
2117 | parse(arg) # make sure syntax errors are confined |
|
2119 | parse(arg) # make sure syntax errors are confined | |
2118 | return '(%s)' % arg |
|
2120 | return '(%s)' % arg | |
2119 | elif c == 'n': |
|
2121 | elif c == 'n': | |
2120 | return quote(node.hex(arg)) |
|
2122 | return quote(node.hex(arg)) | |
2121 | elif c == 'b': |
|
2123 | elif c == 'b': | |
2122 | return quote(arg.branch()) |
|
2124 | return quote(arg.branch()) | |
2123 |
|
2125 | |||
2124 | def listexp(s, t): |
|
2126 | def listexp(s, t): | |
2125 | l = len(s) |
|
2127 | l = len(s) | |
2126 | if l == 0: |
|
2128 | if l == 0: | |
2127 | return "_list('')" |
|
2129 | return "_list('')" | |
2128 | elif l == 1: |
|
2130 | elif l == 1: | |
2129 | return argtype(t, s[0]) |
|
2131 | return argtype(t, s[0]) | |
2130 | elif t == 'd': |
|
2132 | elif t == 'd': | |
2131 | return "_intlist('%s')" % "\0".join(str(int(a)) for a in s) |
|
2133 | return "_intlist('%s')" % "\0".join(str(int(a)) for a in s) | |
2132 | elif t == 's': |
|
2134 | elif t == 's': | |
2133 | return "_list('%s')" % "\0".join(s) |
|
2135 | return "_list('%s')" % "\0".join(s) | |
2134 | elif t == 'n': |
|
2136 | elif t == 'n': | |
2135 | return "_hexlist('%s')" % "\0".join(node.hex(a) for a in s) |
|
2137 | return "_hexlist('%s')" % "\0".join(node.hex(a) for a in s) | |
2136 | elif t == 'b': |
|
2138 | elif t == 'b': | |
2137 | return "_list('%s')" % "\0".join(a.branch() for a in s) |
|
2139 | return "_list('%s')" % "\0".join(a.branch() for a in s) | |
2138 |
|
2140 | |||
2139 | m = l // 2 |
|
2141 | m = l // 2 | |
2140 | return '(%s or %s)' % (listexp(s[:m], t), listexp(s[m:], t)) |
|
2142 | return '(%s or %s)' % (listexp(s[:m], t), listexp(s[m:], t)) | |
2141 |
|
2143 | |||
2142 | ret = '' |
|
2144 | ret = '' | |
2143 | pos = 0 |
|
2145 | pos = 0 | |
2144 | arg = 0 |
|
2146 | arg = 0 | |
2145 | while pos < len(expr): |
|
2147 | while pos < len(expr): | |
2146 | c = expr[pos] |
|
2148 | c = expr[pos] | |
2147 | if c == '%': |
|
2149 | if c == '%': | |
2148 | pos += 1 |
|
2150 | pos += 1 | |
2149 | d = expr[pos] |
|
2151 | d = expr[pos] | |
2150 | if d == '%': |
|
2152 | if d == '%': | |
2151 | ret += d |
|
2153 | ret += d | |
2152 | elif d in 'dsnbr': |
|
2154 | elif d in 'dsnbr': | |
2153 | ret += argtype(d, args[arg]) |
|
2155 | ret += argtype(d, args[arg]) | |
2154 | arg += 1 |
|
2156 | arg += 1 | |
2155 | elif d == 'l': |
|
2157 | elif d == 'l': | |
2156 | # a list of some type |
|
2158 | # a list of some type | |
2157 | pos += 1 |
|
2159 | pos += 1 | |
2158 | d = expr[pos] |
|
2160 | d = expr[pos] | |
2159 | ret += listexp(list(args[arg]), d) |
|
2161 | ret += listexp(list(args[arg]), d) | |
2160 | arg += 1 |
|
2162 | arg += 1 | |
2161 | else: |
|
2163 | else: | |
2162 | raise util.Abort('unexpected revspec format character %s' % d) |
|
2164 | raise util.Abort('unexpected revspec format character %s' % d) | |
2163 | else: |
|
2165 | else: | |
2164 | ret += c |
|
2166 | ret += c | |
2165 | pos += 1 |
|
2167 | pos += 1 | |
2166 |
|
2168 | |||
2167 | return ret |
|
2169 | return ret | |
2168 |
|
2170 | |||
2169 | def prettyformat(tree): |
|
2171 | def prettyformat(tree): | |
2170 | def _prettyformat(tree, level, lines): |
|
2172 | def _prettyformat(tree, level, lines): | |
2171 | if not isinstance(tree, tuple) or tree[0] in ('string', 'symbol'): |
|
2173 | if not isinstance(tree, tuple) or tree[0] in ('string', 'symbol'): | |
2172 | lines.append((level, str(tree))) |
|
2174 | lines.append((level, str(tree))) | |
2173 | else: |
|
2175 | else: | |
2174 | lines.append((level, '(%s' % tree[0])) |
|
2176 | lines.append((level, '(%s' % tree[0])) | |
2175 | for s in tree[1:]: |
|
2177 | for s in tree[1:]: | |
2176 | _prettyformat(s, level + 1, lines) |
|
2178 | _prettyformat(s, level + 1, lines) | |
2177 | lines[-1:] = [(lines[-1][0], lines[-1][1] + ')')] |
|
2179 | lines[-1:] = [(lines[-1][0], lines[-1][1] + ')')] | |
2178 |
|
2180 | |||
2179 | lines = [] |
|
2181 | lines = [] | |
2180 | _prettyformat(tree, 0, lines) |
|
2182 | _prettyformat(tree, 0, lines) | |
2181 | output = '\n'.join((' '*l + s) for l, s in lines) |
|
2183 | output = '\n'.join((' '*l + s) for l, s in lines) | |
2182 | return output |
|
2184 | return output | |
2183 |
|
2185 | |||
2184 | def depth(tree): |
|
2186 | def depth(tree): | |
2185 | if isinstance(tree, tuple): |
|
2187 | if isinstance(tree, tuple): | |
2186 | return max(map(depth, tree)) + 1 |
|
2188 | return max(map(depth, tree)) + 1 | |
2187 | else: |
|
2189 | else: | |
2188 | return 0 |
|
2190 | return 0 | |
2189 |
|
2191 | |||
2190 | def funcsused(tree): |
|
2192 | def funcsused(tree): | |
2191 | if not isinstance(tree, tuple) or tree[0] in ('string', 'symbol'): |
|
2193 | if not isinstance(tree, tuple) or tree[0] in ('string', 'symbol'): | |
2192 | return set() |
|
2194 | return set() | |
2193 | else: |
|
2195 | else: | |
2194 | funcs = set() |
|
2196 | funcs = set() | |
2195 | for s in tree[1:]: |
|
2197 | for s in tree[1:]: | |
2196 | funcs |= funcsused(s) |
|
2198 | funcs |= funcsused(s) | |
2197 | if tree[0] == 'func': |
|
2199 | if tree[0] == 'func': | |
2198 | funcs.add(tree[1][1]) |
|
2200 | funcs.add(tree[1][1]) | |
2199 | return funcs |
|
2201 | return funcs | |
2200 |
|
2202 | |||
2201 | class abstractsmartset(object): |
|
2203 | class abstractsmartset(object): | |
2202 |
|
2204 | |||
2203 | def __nonzero__(self): |
|
2205 | def __nonzero__(self): | |
2204 | """True if the smartset is not empty""" |
|
2206 | """True if the smartset is not empty""" | |
2205 | raise NotImplementedError() |
|
2207 | raise NotImplementedError() | |
2206 |
|
2208 | |||
2207 | def __contains__(self, rev): |
|
2209 | def __contains__(self, rev): | |
2208 | """provide fast membership testing""" |
|
2210 | """provide fast membership testing""" | |
2209 | raise NotImplementedError() |
|
2211 | raise NotImplementedError() | |
2210 |
|
2212 | |||
2211 | def __iter__(self): |
|
2213 | def __iter__(self): | |
2212 | """iterate the set in the order it is supposed to be iterated""" |
|
2214 | """iterate the set in the order it is supposed to be iterated""" | |
2213 | raise NotImplementedError() |
|
2215 | raise NotImplementedError() | |
2214 |
|
2216 | |||
2215 | # Attributes containing a function to perform a fast iteration in a given |
|
2217 | # Attributes containing a function to perform a fast iteration in a given | |
2216 | # direction. A smartset can have none, one, or both defined. |
|
2218 | # direction. A smartset can have none, one, or both defined. | |
2217 | # |
|
2219 | # | |
2218 | # Default value is None instead of a function returning None to avoid |
|
2220 | # Default value is None instead of a function returning None to avoid | |
2219 | # initializing an iterator just for testing if a fast method exists. |
|
2221 | # initializing an iterator just for testing if a fast method exists. | |
2220 | fastasc = None |
|
2222 | fastasc = None | |
2221 | fastdesc = None |
|
2223 | fastdesc = None | |
2222 |
|
2224 | |||
2223 | def isascending(self): |
|
2225 | def isascending(self): | |
2224 | """True if the set will iterate in ascending order""" |
|
2226 | """True if the set will iterate in ascending order""" | |
2225 | raise NotImplementedError() |
|
2227 | raise NotImplementedError() | |
2226 |
|
2228 | |||
2227 | def isdescending(self): |
|
2229 | def isdescending(self): | |
2228 | """True if the set will iterate in descending order""" |
|
2230 | """True if the set will iterate in descending order""" | |
2229 | raise NotImplementedError() |
|
2231 | raise NotImplementedError() | |
2230 |
|
2232 | |||
2231 | def min(self): |
|
2233 | def min(self): | |
2232 | """return the minimum element in the set""" |
|
2234 | """return the minimum element in the set""" | |
2233 | if self.fastasc is not None: |
|
2235 | if self.fastasc is not None: | |
2234 | for r in self.fastasc(): |
|
2236 | for r in self.fastasc(): | |
2235 | return r |
|
2237 | return r | |
2236 | raise ValueError('arg is an empty sequence') |
|
2238 | raise ValueError('arg is an empty sequence') | |
2237 | return min(self) |
|
2239 | return min(self) | |
2238 |
|
2240 | |||
2239 | def max(self): |
|
2241 | def max(self): | |
2240 | """return the maximum element in the set""" |
|
2242 | """return the maximum element in the set""" | |
2241 | if self.fastdesc is not None: |
|
2243 | if self.fastdesc is not None: | |
2242 | for r in self.fastdesc(): |
|
2244 | for r in self.fastdesc(): | |
2243 | return r |
|
2245 | return r | |
2244 | raise ValueError('arg is an empty sequence') |
|
2246 | raise ValueError('arg is an empty sequence') | |
2245 | return max(self) |
|
2247 | return max(self) | |
2246 |
|
2248 | |||
2247 | def first(self): |
|
2249 | def first(self): | |
2248 | """return the first element in the set (user iteration perspective) |
|
2250 | """return the first element in the set (user iteration perspective) | |
2249 |
|
2251 | |||
2250 | Return None if the set is empty""" |
|
2252 | Return None if the set is empty""" | |
2251 | raise NotImplementedError() |
|
2253 | raise NotImplementedError() | |
2252 |
|
2254 | |||
2253 | def last(self): |
|
2255 | def last(self): | |
2254 | """return the last element in the set (user iteration perspective) |
|
2256 | """return the last element in the set (user iteration perspective) | |
2255 |
|
2257 | |||
2256 | Return None if the set is empty""" |
|
2258 | Return None if the set is empty""" | |
2257 | raise NotImplementedError() |
|
2259 | raise NotImplementedError() | |
2258 |
|
2260 | |||
2259 | def __len__(self): |
|
2261 | def __len__(self): | |
2260 | """return the length of the smartsets |
|
2262 | """return the length of the smartsets | |
2261 |
|
2263 | |||
2262 | This can be expensive on smartset that could be lazy otherwise.""" |
|
2264 | This can be expensive on smartset that could be lazy otherwise.""" | |
2263 | raise NotImplementedError() |
|
2265 | raise NotImplementedError() | |
2264 |
|
2266 | |||
2265 | def reverse(self): |
|
2267 | def reverse(self): | |
2266 | """reverse the expected iteration order""" |
|
2268 | """reverse the expected iteration order""" | |
2267 | raise NotImplementedError() |
|
2269 | raise NotImplementedError() | |
2268 |
|
2270 | |||
2269 | def sort(self, reverse=True): |
|
2271 | def sort(self, reverse=True): | |
2270 | """get the set to iterate in an ascending or descending order""" |
|
2272 | """get the set to iterate in an ascending or descending order""" | |
2271 | raise NotImplementedError() |
|
2273 | raise NotImplementedError() | |
2272 |
|
2274 | |||
2273 | def __and__(self, other): |
|
2275 | def __and__(self, other): | |
2274 | """Returns a new object with the intersection of the two collections. |
|
2276 | """Returns a new object with the intersection of the two collections. | |
2275 |
|
2277 | |||
2276 | This is part of the mandatory API for smartset.""" |
|
2278 | This is part of the mandatory API for smartset.""" | |
2277 | return self.filter(other.__contains__, cache=False) |
|
2279 | return self.filter(other.__contains__, cache=False) | |
2278 |
|
2280 | |||
2279 | def __add__(self, other): |
|
2281 | def __add__(self, other): | |
2280 | """Returns a new object with the union of the two collections. |
|
2282 | """Returns a new object with the union of the two collections. | |
2281 |
|
2283 | |||
2282 | This is part of the mandatory API for smartset.""" |
|
2284 | This is part of the mandatory API for smartset.""" | |
2283 | return addset(self, other) |
|
2285 | return addset(self, other) | |
2284 |
|
2286 | |||
2285 | def __sub__(self, other): |
|
2287 | def __sub__(self, other): | |
2286 | """Returns a new object with the substraction of the two collections. |
|
2288 | """Returns a new object with the substraction of the two collections. | |
2287 |
|
2289 | |||
2288 | This is part of the mandatory API for smartset.""" |
|
2290 | This is part of the mandatory API for smartset.""" | |
2289 | c = other.__contains__ |
|
2291 | c = other.__contains__ | |
2290 | return self.filter(lambda r: not c(r), cache=False) |
|
2292 | return self.filter(lambda r: not c(r), cache=False) | |
2291 |
|
2293 | |||
2292 | def filter(self, condition, cache=True): |
|
2294 | def filter(self, condition, cache=True): | |
2293 | """Returns this smartset filtered by condition as a new smartset. |
|
2295 | """Returns this smartset filtered by condition as a new smartset. | |
2294 |
|
2296 | |||
2295 | `condition` is a callable which takes a revision number and returns a |
|
2297 | `condition` is a callable which takes a revision number and returns a | |
2296 | boolean. |
|
2298 | boolean. | |
2297 |
|
2299 | |||
2298 | This is part of the mandatory API for smartset.""" |
|
2300 | This is part of the mandatory API for smartset.""" | |
2299 | # builtin cannot be cached. but do not needs to |
|
2301 | # builtin cannot be cached. but do not needs to | |
2300 | if cache and util.safehasattr(condition, 'func_code'): |
|
2302 | if cache and util.safehasattr(condition, 'func_code'): | |
2301 | condition = util.cachefunc(condition) |
|
2303 | condition = util.cachefunc(condition) | |
2302 | return filteredset(self, condition) |
|
2304 | return filteredset(self, condition) | |
2303 |
|
2305 | |||
2304 | class baseset(abstractsmartset): |
|
2306 | class baseset(abstractsmartset): | |
2305 | """Basic data structure that represents a revset and contains the basic |
|
2307 | """Basic data structure that represents a revset and contains the basic | |
2306 | operation that it should be able to perform. |
|
2308 | operation that it should be able to perform. | |
2307 |
|
2309 | |||
2308 | Every method in this class should be implemented by any smartset class. |
|
2310 | Every method in this class should be implemented by any smartset class. | |
2309 | """ |
|
2311 | """ | |
2310 | def __init__(self, data=()): |
|
2312 | def __init__(self, data=()): | |
2311 | if not isinstance(data, list): |
|
2313 | if not isinstance(data, list): | |
2312 | data = list(data) |
|
2314 | data = list(data) | |
2313 | self._list = data |
|
2315 | self._list = data | |
2314 | self._ascending = None |
|
2316 | self._ascending = None | |
2315 |
|
2317 | |||
2316 | @util.propertycache |
|
2318 | @util.propertycache | |
2317 | def _set(self): |
|
2319 | def _set(self): | |
2318 | return set(self._list) |
|
2320 | return set(self._list) | |
2319 |
|
2321 | |||
2320 | @util.propertycache |
|
2322 | @util.propertycache | |
2321 | def _asclist(self): |
|
2323 | def _asclist(self): | |
2322 | asclist = self._list[:] |
|
2324 | asclist = self._list[:] | |
2323 | asclist.sort() |
|
2325 | asclist.sort() | |
2324 | return asclist |
|
2326 | return asclist | |
2325 |
|
2327 | |||
2326 | def __iter__(self): |
|
2328 | def __iter__(self): | |
2327 | if self._ascending is None: |
|
2329 | if self._ascending is None: | |
2328 | return iter(self._list) |
|
2330 | return iter(self._list) | |
2329 | elif self._ascending: |
|
2331 | elif self._ascending: | |
2330 | return iter(self._asclist) |
|
2332 | return iter(self._asclist) | |
2331 | else: |
|
2333 | else: | |
2332 | return reversed(self._asclist) |
|
2334 | return reversed(self._asclist) | |
2333 |
|
2335 | |||
2334 | def fastasc(self): |
|
2336 | def fastasc(self): | |
2335 | return iter(self._asclist) |
|
2337 | return iter(self._asclist) | |
2336 |
|
2338 | |||
2337 | def fastdesc(self): |
|
2339 | def fastdesc(self): | |
2338 | return reversed(self._asclist) |
|
2340 | return reversed(self._asclist) | |
2339 |
|
2341 | |||
2340 | @util.propertycache |
|
2342 | @util.propertycache | |
2341 | def __contains__(self): |
|
2343 | def __contains__(self): | |
2342 | return self._set.__contains__ |
|
2344 | return self._set.__contains__ | |
2343 |
|
2345 | |||
2344 | def __nonzero__(self): |
|
2346 | def __nonzero__(self): | |
2345 | return bool(self._list) |
|
2347 | return bool(self._list) | |
2346 |
|
2348 | |||
2347 | def sort(self, reverse=False): |
|
2349 | def sort(self, reverse=False): | |
2348 | self._ascending = not bool(reverse) |
|
2350 | self._ascending = not bool(reverse) | |
2349 |
|
2351 | |||
2350 | def reverse(self): |
|
2352 | def reverse(self): | |
2351 | if self._ascending is None: |
|
2353 | if self._ascending is None: | |
2352 | self._list.reverse() |
|
2354 | self._list.reverse() | |
2353 | else: |
|
2355 | else: | |
2354 | self._ascending = not self._ascending |
|
2356 | self._ascending = not self._ascending | |
2355 |
|
2357 | |||
2356 | def __len__(self): |
|
2358 | def __len__(self): | |
2357 | return len(self._list) |
|
2359 | return len(self._list) | |
2358 |
|
2360 | |||
2359 | def isascending(self): |
|
2361 | def isascending(self): | |
2360 | """Returns True if the collection is ascending order, False if not. |
|
2362 | """Returns True if the collection is ascending order, False if not. | |
2361 |
|
2363 | |||
2362 | This is part of the mandatory API for smartset.""" |
|
2364 | This is part of the mandatory API for smartset.""" | |
2363 | if len(self) <= 1: |
|
2365 | if len(self) <= 1: | |
2364 | return True |
|
2366 | return True | |
2365 | return self._ascending is not None and self._ascending |
|
2367 | return self._ascending is not None and self._ascending | |
2366 |
|
2368 | |||
2367 | def isdescending(self): |
|
2369 | def isdescending(self): | |
2368 | """Returns True if the collection is descending order, False if not. |
|
2370 | """Returns True if the collection is descending order, False if not. | |
2369 |
|
2371 | |||
2370 | This is part of the mandatory API for smartset.""" |
|
2372 | This is part of the mandatory API for smartset.""" | |
2371 | if len(self) <= 1: |
|
2373 | if len(self) <= 1: | |
2372 | return True |
|
2374 | return True | |
2373 | return self._ascending is not None and not self._ascending |
|
2375 | return self._ascending is not None and not self._ascending | |
2374 |
|
2376 | |||
2375 | def first(self): |
|
2377 | def first(self): | |
2376 | if self: |
|
2378 | if self: | |
2377 | if self._ascending is None: |
|
2379 | if self._ascending is None: | |
2378 | return self._list[0] |
|
2380 | return self._list[0] | |
2379 | elif self._ascending: |
|
2381 | elif self._ascending: | |
2380 | return self._asclist[0] |
|
2382 | return self._asclist[0] | |
2381 | else: |
|
2383 | else: | |
2382 | return self._asclist[-1] |
|
2384 | return self._asclist[-1] | |
2383 | return None |
|
2385 | return None | |
2384 |
|
2386 | |||
2385 | def last(self): |
|
2387 | def last(self): | |
2386 | if self: |
|
2388 | if self: | |
2387 | if self._ascending is None: |
|
2389 | if self._ascending is None: | |
2388 | return self._list[-1] |
|
2390 | return self._list[-1] | |
2389 | elif self._ascending: |
|
2391 | elif self._ascending: | |
2390 | return self._asclist[-1] |
|
2392 | return self._asclist[-1] | |
2391 | else: |
|
2393 | else: | |
2392 | return self._asclist[0] |
|
2394 | return self._asclist[0] | |
2393 | return None |
|
2395 | return None | |
2394 |
|
2396 | |||
2395 | class filteredset(abstractsmartset): |
|
2397 | class filteredset(abstractsmartset): | |
2396 | """Duck type for baseset class which iterates lazily over the revisions in |
|
2398 | """Duck type for baseset class which iterates lazily over the revisions in | |
2397 | the subset and contains a function which tests for membership in the |
|
2399 | the subset and contains a function which tests for membership in the | |
2398 | revset |
|
2400 | revset | |
2399 | """ |
|
2401 | """ | |
2400 | def __init__(self, subset, condition=lambda x: True): |
|
2402 | def __init__(self, subset, condition=lambda x: True): | |
2401 | """ |
|
2403 | """ | |
2402 | condition: a function that decide whether a revision in the subset |
|
2404 | condition: a function that decide whether a revision in the subset | |
2403 | belongs to the revset or not. |
|
2405 | belongs to the revset or not. | |
2404 | """ |
|
2406 | """ | |
2405 | self._subset = subset |
|
2407 | self._subset = subset | |
2406 | self._condition = condition |
|
2408 | self._condition = condition | |
2407 | self._cache = {} |
|
2409 | self._cache = {} | |
2408 |
|
2410 | |||
2409 | def __contains__(self, x): |
|
2411 | def __contains__(self, x): | |
2410 | c = self._cache |
|
2412 | c = self._cache | |
2411 | if x not in c: |
|
2413 | if x not in c: | |
2412 | v = c[x] = x in self._subset and self._condition(x) |
|
2414 | v = c[x] = x in self._subset and self._condition(x) | |
2413 | return v |
|
2415 | return v | |
2414 | return c[x] |
|
2416 | return c[x] | |
2415 |
|
2417 | |||
2416 | def __iter__(self): |
|
2418 | def __iter__(self): | |
2417 | return self._iterfilter(self._subset) |
|
2419 | return self._iterfilter(self._subset) | |
2418 |
|
2420 | |||
2419 | def _iterfilter(self, it): |
|
2421 | def _iterfilter(self, it): | |
2420 | cond = self._condition |
|
2422 | cond = self._condition | |
2421 | for x in it: |
|
2423 | for x in it: | |
2422 | if cond(x): |
|
2424 | if cond(x): | |
2423 | yield x |
|
2425 | yield x | |
2424 |
|
2426 | |||
2425 | @property |
|
2427 | @property | |
2426 | def fastasc(self): |
|
2428 | def fastasc(self): | |
2427 | it = self._subset.fastasc |
|
2429 | it = self._subset.fastasc | |
2428 | if it is None: |
|
2430 | if it is None: | |
2429 | return None |
|
2431 | return None | |
2430 | return lambda: self._iterfilter(it()) |
|
2432 | return lambda: self._iterfilter(it()) | |
2431 |
|
2433 | |||
2432 | @property |
|
2434 | @property | |
2433 | def fastdesc(self): |
|
2435 | def fastdesc(self): | |
2434 | it = self._subset.fastdesc |
|
2436 | it = self._subset.fastdesc | |
2435 | if it is None: |
|
2437 | if it is None: | |
2436 | return None |
|
2438 | return None | |
2437 | return lambda: self._iterfilter(it()) |
|
2439 | return lambda: self._iterfilter(it()) | |
2438 |
|
2440 | |||
2439 | def __nonzero__(self): |
|
2441 | def __nonzero__(self): | |
2440 | for r in self: |
|
2442 | for r in self: | |
2441 | return True |
|
2443 | return True | |
2442 | return False |
|
2444 | return False | |
2443 |
|
2445 | |||
2444 | def __len__(self): |
|
2446 | def __len__(self): | |
2445 | # Basic implementation to be changed in future patches. |
|
2447 | # Basic implementation to be changed in future patches. | |
2446 | l = baseset([r for r in self]) |
|
2448 | l = baseset([r for r in self]) | |
2447 | return len(l) |
|
2449 | return len(l) | |
2448 |
|
2450 | |||
2449 | def sort(self, reverse=False): |
|
2451 | def sort(self, reverse=False): | |
2450 | self._subset.sort(reverse=reverse) |
|
2452 | self._subset.sort(reverse=reverse) | |
2451 |
|
2453 | |||
2452 | def reverse(self): |
|
2454 | def reverse(self): | |
2453 | self._subset.reverse() |
|
2455 | self._subset.reverse() | |
2454 |
|
2456 | |||
2455 | def isascending(self): |
|
2457 | def isascending(self): | |
2456 | return self._subset.isascending() |
|
2458 | return self._subset.isascending() | |
2457 |
|
2459 | |||
2458 | def isdescending(self): |
|
2460 | def isdescending(self): | |
2459 | return self._subset.isdescending() |
|
2461 | return self._subset.isdescending() | |
2460 |
|
2462 | |||
2461 | def first(self): |
|
2463 | def first(self): | |
2462 | for x in self: |
|
2464 | for x in self: | |
2463 | return x |
|
2465 | return x | |
2464 | return None |
|
2466 | return None | |
2465 |
|
2467 | |||
2466 | def last(self): |
|
2468 | def last(self): | |
2467 | it = None |
|
2469 | it = None | |
2468 | if self._subset.isascending: |
|
2470 | if self._subset.isascending: | |
2469 | it = self.fastdesc |
|
2471 | it = self.fastdesc | |
2470 | elif self._subset.isdescending: |
|
2472 | elif self._subset.isdescending: | |
2471 | it = self.fastdesc |
|
2473 | it = self.fastdesc | |
2472 | if it is None: |
|
2474 | if it is None: | |
2473 | # slowly consume everything. This needs improvement |
|
2475 | # slowly consume everything. This needs improvement | |
2474 | it = lambda: reversed(list(self)) |
|
2476 | it = lambda: reversed(list(self)) | |
2475 | for x in it(): |
|
2477 | for x in it(): | |
2476 | return x |
|
2478 | return x | |
2477 | return None |
|
2479 | return None | |
2478 |
|
2480 | |||
2479 | class addset(abstractsmartset): |
|
2481 | class addset(abstractsmartset): | |
2480 | """Represent the addition of two sets |
|
2482 | """Represent the addition of two sets | |
2481 |
|
2483 | |||
2482 | Wrapper structure for lazily adding two structures without losing much |
|
2484 | Wrapper structure for lazily adding two structures without losing much | |
2483 | performance on the __contains__ method |
|
2485 | performance on the __contains__ method | |
2484 |
|
2486 | |||
2485 | If the ascending attribute is set, that means the two structures are |
|
2487 | If the ascending attribute is set, that means the two structures are | |
2486 | ordered in either an ascending or descending way. Therefore, we can add |
|
2488 | ordered in either an ascending or descending way. Therefore, we can add | |
2487 | them maintaining the order by iterating over both at the same time |
|
2489 | them maintaining the order by iterating over both at the same time | |
2488 | """ |
|
2490 | """ | |
2489 | def __init__(self, revs1, revs2, ascending=None): |
|
2491 | def __init__(self, revs1, revs2, ascending=None): | |
2490 | self._r1 = revs1 |
|
2492 | self._r1 = revs1 | |
2491 | self._r2 = revs2 |
|
2493 | self._r2 = revs2 | |
2492 | self._iter = None |
|
2494 | self._iter = None | |
2493 | self._ascending = ascending |
|
2495 | self._ascending = ascending | |
2494 | self._genlist = None |
|
2496 | self._genlist = None | |
2495 | self._asclist = None |
|
2497 | self._asclist = None | |
2496 |
|
2498 | |||
2497 | def __len__(self): |
|
2499 | def __len__(self): | |
2498 | return len(self._list) |
|
2500 | return len(self._list) | |
2499 |
|
2501 | |||
2500 | def __nonzero__(self): |
|
2502 | def __nonzero__(self): | |
2501 | return bool(self._r1 or self._r2) |
|
2503 | return bool(self._r1 or self._r2) | |
2502 |
|
2504 | |||
2503 | @util.propertycache |
|
2505 | @util.propertycache | |
2504 | def _list(self): |
|
2506 | def _list(self): | |
2505 | if not self._genlist: |
|
2507 | if not self._genlist: | |
2506 | self._genlist = baseset(self._iterator()) |
|
2508 | self._genlist = baseset(self._iterator()) | |
2507 | return self._genlist |
|
2509 | return self._genlist | |
2508 |
|
2510 | |||
2509 | def _iterator(self): |
|
2511 | def _iterator(self): | |
2510 | """Iterate over both collections without repeating elements |
|
2512 | """Iterate over both collections without repeating elements | |
2511 |
|
2513 | |||
2512 | If the ascending attribute is not set, iterate over the first one and |
|
2514 | If the ascending attribute is not set, iterate over the first one and | |
2513 | then over the second one checking for membership on the first one so we |
|
2515 | then over the second one checking for membership on the first one so we | |
2514 | dont yield any duplicates. |
|
2516 | dont yield any duplicates. | |
2515 |
|
2517 | |||
2516 | If the ascending attribute is set, iterate over both collections at the |
|
2518 | If the ascending attribute is set, iterate over both collections at the | |
2517 | same time, yielding only one value at a time in the given order. |
|
2519 | same time, yielding only one value at a time in the given order. | |
2518 | """ |
|
2520 | """ | |
2519 | if self._ascending is None: |
|
2521 | if self._ascending is None: | |
2520 | def gen(): |
|
2522 | def gen(): | |
2521 | for r in self._r1: |
|
2523 | for r in self._r1: | |
2522 | yield r |
|
2524 | yield r | |
2523 | inr1 = self._r1.__contains__ |
|
2525 | inr1 = self._r1.__contains__ | |
2524 | for r in self._r2: |
|
2526 | for r in self._r2: | |
2525 | if not inr1(r): |
|
2527 | if not inr1(r): | |
2526 | yield r |
|
2528 | yield r | |
2527 | gen = gen() |
|
2529 | gen = gen() | |
2528 | else: |
|
2530 | else: | |
2529 | iter1 = iter(self._r1) |
|
2531 | iter1 = iter(self._r1) | |
2530 | iter2 = iter(self._r2) |
|
2532 | iter2 = iter(self._r2) | |
2531 | gen = self._iterordered(self._ascending, iter1, iter2) |
|
2533 | gen = self._iterordered(self._ascending, iter1, iter2) | |
2532 | return gen |
|
2534 | return gen | |
2533 |
|
2535 | |||
2534 | def __iter__(self): |
|
2536 | def __iter__(self): | |
2535 | if self._ascending is None: |
|
2537 | if self._ascending is None: | |
2536 | if self._genlist: |
|
2538 | if self._genlist: | |
2537 | return iter(self._genlist) |
|
2539 | return iter(self._genlist) | |
2538 | return iter(self._iterator()) |
|
2540 | return iter(self._iterator()) | |
2539 | self._trysetasclist() |
|
2541 | self._trysetasclist() | |
2540 | if self._ascending: |
|
2542 | if self._ascending: | |
2541 | it = self.fastasc |
|
2543 | it = self.fastasc | |
2542 | else: |
|
2544 | else: | |
2543 | it = self.fastdesc |
|
2545 | it = self.fastdesc | |
2544 | if it is None: |
|
2546 | if it is None: | |
2545 | # consume the gen and try again |
|
2547 | # consume the gen and try again | |
2546 | self._list |
|
2548 | self._list | |
2547 | return iter(self) |
|
2549 | return iter(self) | |
2548 | return it() |
|
2550 | return it() | |
2549 |
|
2551 | |||
2550 | def _trysetasclist(self): |
|
2552 | def _trysetasclist(self): | |
2551 | """populate the _asclist attribut if possible and necessary""" |
|
2553 | """populate the _asclist attribut if possible and necessary""" | |
2552 | if self._genlist is not None and self._asclist is None: |
|
2554 | if self._genlist is not None and self._asclist is None: | |
2553 | self._asclist = sorted(self._genlist) |
|
2555 | self._asclist = sorted(self._genlist) | |
2554 |
|
2556 | |||
2555 | @property |
|
2557 | @property | |
2556 | def fastasc(self): |
|
2558 | def fastasc(self): | |
2557 | self._trysetasclist() |
|
2559 | self._trysetasclist() | |
2558 | if self._asclist is not None: |
|
2560 | if self._asclist is not None: | |
2559 | return self._asclist.__iter__ |
|
2561 | return self._asclist.__iter__ | |
2560 | iter1 = self._r1.fastasc |
|
2562 | iter1 = self._r1.fastasc | |
2561 | iter2 = self._r2.fastasc |
|
2563 | iter2 = self._r2.fastasc | |
2562 | if None in (iter1, iter2): |
|
2564 | if None in (iter1, iter2): | |
2563 | return None |
|
2565 | return None | |
2564 | return lambda: self._iterordered(True, iter1(), iter2()) |
|
2566 | return lambda: self._iterordered(True, iter1(), iter2()) | |
2565 |
|
2567 | |||
2566 | @property |
|
2568 | @property | |
2567 | def fastdesc(self): |
|
2569 | def fastdesc(self): | |
2568 | self._trysetasclist() |
|
2570 | self._trysetasclist() | |
2569 | if self._asclist is not None: |
|
2571 | if self._asclist is not None: | |
2570 | return self._asclist.__reversed__ |
|
2572 | return self._asclist.__reversed__ | |
2571 | iter1 = self._r1.fastdesc |
|
2573 | iter1 = self._r1.fastdesc | |
2572 | iter2 = self._r2.fastdesc |
|
2574 | iter2 = self._r2.fastdesc | |
2573 | if None in (iter1, iter2): |
|
2575 | if None in (iter1, iter2): | |
2574 | return None |
|
2576 | return None | |
2575 | return lambda: self._iterordered(False, iter1(), iter2()) |
|
2577 | return lambda: self._iterordered(False, iter1(), iter2()) | |
2576 |
|
2578 | |||
2577 | def _iterordered(self, ascending, iter1, iter2): |
|
2579 | def _iterordered(self, ascending, iter1, iter2): | |
2578 | """produce an ordered iteration from two iterators with the same order |
|
2580 | """produce an ordered iteration from two iterators with the same order | |
2579 |
|
2581 | |||
2580 | The ascending is used to indicated the iteration direction. |
|
2582 | The ascending is used to indicated the iteration direction. | |
2581 | """ |
|
2583 | """ | |
2582 | choice = max |
|
2584 | choice = max | |
2583 | if ascending: |
|
2585 | if ascending: | |
2584 | choice = min |
|
2586 | choice = min | |
2585 |
|
2587 | |||
2586 | val1 = None |
|
2588 | val1 = None | |
2587 | val2 = None |
|
2589 | val2 = None | |
2588 |
|
2590 | |||
2589 | choice = max |
|
2591 | choice = max | |
2590 | if ascending: |
|
2592 | if ascending: | |
2591 | choice = min |
|
2593 | choice = min | |
2592 | try: |
|
2594 | try: | |
2593 | # Consume both iterators in an ordered way until one is |
|
2595 | # Consume both iterators in an ordered way until one is | |
2594 | # empty |
|
2596 | # empty | |
2595 | while True: |
|
2597 | while True: | |
2596 | if val1 is None: |
|
2598 | if val1 is None: | |
2597 | val1 = iter1.next() |
|
2599 | val1 = iter1.next() | |
2598 | if val2 is None: |
|
2600 | if val2 is None: | |
2599 | val2 = iter2.next() |
|
2601 | val2 = iter2.next() | |
2600 | next = choice(val1, val2) |
|
2602 | next = choice(val1, val2) | |
2601 | yield next |
|
2603 | yield next | |
2602 | if val1 == next: |
|
2604 | if val1 == next: | |
2603 | val1 = None |
|
2605 | val1 = None | |
2604 | if val2 == next: |
|
2606 | if val2 == next: | |
2605 | val2 = None |
|
2607 | val2 = None | |
2606 | except StopIteration: |
|
2608 | except StopIteration: | |
2607 | # Flush any remaining values and consume the other one |
|
2609 | # Flush any remaining values and consume the other one | |
2608 | it = iter2 |
|
2610 | it = iter2 | |
2609 | if val1 is not None: |
|
2611 | if val1 is not None: | |
2610 | yield val1 |
|
2612 | yield val1 | |
2611 | it = iter1 |
|
2613 | it = iter1 | |
2612 | elif val2 is not None: |
|
2614 | elif val2 is not None: | |
2613 | # might have been equality and both are empty |
|
2615 | # might have been equality and both are empty | |
2614 | yield val2 |
|
2616 | yield val2 | |
2615 | for val in it: |
|
2617 | for val in it: | |
2616 | yield val |
|
2618 | yield val | |
2617 |
|
2619 | |||
2618 | def __contains__(self, x): |
|
2620 | def __contains__(self, x): | |
2619 | return x in self._r1 or x in self._r2 |
|
2621 | return x in self._r1 or x in self._r2 | |
2620 |
|
2622 | |||
2621 | def sort(self, reverse=False): |
|
2623 | def sort(self, reverse=False): | |
2622 | """Sort the added set |
|
2624 | """Sort the added set | |
2623 |
|
2625 | |||
2624 | For this we use the cached list with all the generated values and if we |
|
2626 | For this we use the cached list with all the generated values and if we | |
2625 | know they are ascending or descending we can sort them in a smart way. |
|
2627 | know they are ascending or descending we can sort them in a smart way. | |
2626 | """ |
|
2628 | """ | |
2627 | self._ascending = not reverse |
|
2629 | self._ascending = not reverse | |
2628 |
|
2630 | |||
2629 | def isascending(self): |
|
2631 | def isascending(self): | |
2630 | return self._ascending is not None and self._ascending |
|
2632 | return self._ascending is not None and self._ascending | |
2631 |
|
2633 | |||
2632 | def isdescending(self): |
|
2634 | def isdescending(self): | |
2633 | return self._ascending is not None and not self._ascending |
|
2635 | return self._ascending is not None and not self._ascending | |
2634 |
|
2636 | |||
2635 | def reverse(self): |
|
2637 | def reverse(self): | |
2636 | if self._ascending is None: |
|
2638 | if self._ascending is None: | |
2637 | self._list.reverse() |
|
2639 | self._list.reverse() | |
2638 | else: |
|
2640 | else: | |
2639 | self._ascending = not self._ascending |
|
2641 | self._ascending = not self._ascending | |
2640 |
|
2642 | |||
2641 | def first(self): |
|
2643 | def first(self): | |
2642 | if self: |
|
2644 | if self: | |
2643 | return self._list.first() |
|
2645 | return self._list.first() | |
2644 | return None |
|
2646 | return None | |
2645 |
|
2647 | |||
2646 | def last(self): |
|
2648 | def last(self): | |
2647 | if self: |
|
2649 | if self: | |
2648 | return self._list.last() |
|
2650 | return self._list.last() | |
2649 | return None |
|
2651 | return None | |
2650 |
|
2652 | |||
2651 | class generatorset(abstractsmartset): |
|
2653 | class generatorset(abstractsmartset): | |
2652 | """Wrap a generator for lazy iteration |
|
2654 | """Wrap a generator for lazy iteration | |
2653 |
|
2655 | |||
2654 | Wrapper structure for generators that provides lazy membership and can |
|
2656 | Wrapper structure for generators that provides lazy membership and can | |
2655 | be iterated more than once. |
|
2657 | be iterated more than once. | |
2656 | When asked for membership it generates values until either it finds the |
|
2658 | When asked for membership it generates values until either it finds the | |
2657 | requested one or has gone through all the elements in the generator |
|
2659 | requested one or has gone through all the elements in the generator | |
2658 | """ |
|
2660 | """ | |
2659 | def __init__(self, gen, iterasc=None): |
|
2661 | def __init__(self, gen, iterasc=None): | |
2660 | """ |
|
2662 | """ | |
2661 | gen: a generator producing the values for the generatorset. |
|
2663 | gen: a generator producing the values for the generatorset. | |
2662 | """ |
|
2664 | """ | |
2663 | self._gen = gen |
|
2665 | self._gen = gen | |
2664 | self._asclist = None |
|
2666 | self._asclist = None | |
2665 | self._cache = {} |
|
2667 | self._cache = {} | |
2666 | self._genlist = [] |
|
2668 | self._genlist = [] | |
2667 | self._finished = False |
|
2669 | self._finished = False | |
2668 | self._ascending = True |
|
2670 | self._ascending = True | |
2669 | if iterasc is not None: |
|
2671 | if iterasc is not None: | |
2670 | if iterasc: |
|
2672 | if iterasc: | |
2671 | self.fastasc = self._iterator |
|
2673 | self.fastasc = self._iterator | |
2672 | self.__contains__ = self._asccontains |
|
2674 | self.__contains__ = self._asccontains | |
2673 | else: |
|
2675 | else: | |
2674 | self.fastdesc = self._iterator |
|
2676 | self.fastdesc = self._iterator | |
2675 | self.__contains__ = self._desccontains |
|
2677 | self.__contains__ = self._desccontains | |
2676 |
|
2678 | |||
2677 | def __nonzero__(self): |
|
2679 | def __nonzero__(self): | |
2678 | for r in self: |
|
2680 | for r in self: | |
2679 | return True |
|
2681 | return True | |
2680 | return False |
|
2682 | return False | |
2681 |
|
2683 | |||
2682 | def __contains__(self, x): |
|
2684 | def __contains__(self, x): | |
2683 | if x in self._cache: |
|
2685 | if x in self._cache: | |
2684 | return self._cache[x] |
|
2686 | return self._cache[x] | |
2685 |
|
2687 | |||
2686 | # Use new values only, as existing values would be cached. |
|
2688 | # Use new values only, as existing values would be cached. | |
2687 | for l in self._consumegen(): |
|
2689 | for l in self._consumegen(): | |
2688 | if l == x: |
|
2690 | if l == x: | |
2689 | return True |
|
2691 | return True | |
2690 |
|
2692 | |||
2691 | self._cache[x] = False |
|
2693 | self._cache[x] = False | |
2692 | return False |
|
2694 | return False | |
2693 |
|
2695 | |||
2694 | def _asccontains(self, x): |
|
2696 | def _asccontains(self, x): | |
2695 | """version of contains optimised for ascending generator""" |
|
2697 | """version of contains optimised for ascending generator""" | |
2696 | if x in self._cache: |
|
2698 | if x in self._cache: | |
2697 | return self._cache[x] |
|
2699 | return self._cache[x] | |
2698 |
|
2700 | |||
2699 | # Use new values only, as existing values would be cached. |
|
2701 | # Use new values only, as existing values would be cached. | |
2700 | for l in self._consumegen(): |
|
2702 | for l in self._consumegen(): | |
2701 | if l == x: |
|
2703 | if l == x: | |
2702 | return True |
|
2704 | return True | |
2703 | if l > x: |
|
2705 | if l > x: | |
2704 | break |
|
2706 | break | |
2705 |
|
2707 | |||
2706 | self._cache[x] = False |
|
2708 | self._cache[x] = False | |
2707 | return False |
|
2709 | return False | |
2708 |
|
2710 | |||
2709 | def _desccontains(self, x): |
|
2711 | def _desccontains(self, x): | |
2710 | """version of contains optimised for descending generator""" |
|
2712 | """version of contains optimised for descending generator""" | |
2711 | if x in self._cache: |
|
2713 | if x in self._cache: | |
2712 | return self._cache[x] |
|
2714 | return self._cache[x] | |
2713 |
|
2715 | |||
2714 | # Use new values only, as existing values would be cached. |
|
2716 | # Use new values only, as existing values would be cached. | |
2715 | for l in self._consumegen(): |
|
2717 | for l in self._consumegen(): | |
2716 | if l == x: |
|
2718 | if l == x: | |
2717 | return True |
|
2719 | return True | |
2718 | if l < x: |
|
2720 | if l < x: | |
2719 | break |
|
2721 | break | |
2720 |
|
2722 | |||
2721 | self._cache[x] = False |
|
2723 | self._cache[x] = False | |
2722 | return False |
|
2724 | return False | |
2723 |
|
2725 | |||
2724 | def __iter__(self): |
|
2726 | def __iter__(self): | |
2725 | if self._ascending: |
|
2727 | if self._ascending: | |
2726 | it = self.fastasc |
|
2728 | it = self.fastasc | |
2727 | else: |
|
2729 | else: | |
2728 | it = self.fastdesc |
|
2730 | it = self.fastdesc | |
2729 | if it is not None: |
|
2731 | if it is not None: | |
2730 | return it() |
|
2732 | return it() | |
2731 | # we need to consume the iterator |
|
2733 | # we need to consume the iterator | |
2732 | for x in self._consumegen(): |
|
2734 | for x in self._consumegen(): | |
2733 | pass |
|
2735 | pass | |
2734 | # recall the same code |
|
2736 | # recall the same code | |
2735 | return iter(self) |
|
2737 | return iter(self) | |
2736 |
|
2738 | |||
2737 | def _iterator(self): |
|
2739 | def _iterator(self): | |
2738 | if self._finished: |
|
2740 | if self._finished: | |
2739 | return iter(self._genlist) |
|
2741 | return iter(self._genlist) | |
2740 |
|
2742 | |||
2741 | # We have to use this complex iteration strategy to allow multiple |
|
2743 | # We have to use this complex iteration strategy to allow multiple | |
2742 | # iterations at the same time. We need to be able to catch revision |
|
2744 | # iterations at the same time. We need to be able to catch revision | |
2743 | # removed from `consumegen` and added to genlist in another instance. |
|
2745 | # removed from `consumegen` and added to genlist in another instance. | |
2744 | # |
|
2746 | # | |
2745 | # Getting rid of it would provide an about 15% speed up on this |
|
2747 | # Getting rid of it would provide an about 15% speed up on this | |
2746 | # iteration. |
|
2748 | # iteration. | |
2747 | genlist = self._genlist |
|
2749 | genlist = self._genlist | |
2748 | nextrev = self._consumegen().next |
|
2750 | nextrev = self._consumegen().next | |
2749 | _len = len # cache global lookup |
|
2751 | _len = len # cache global lookup | |
2750 | def gen(): |
|
2752 | def gen(): | |
2751 | i = 0 |
|
2753 | i = 0 | |
2752 | while True: |
|
2754 | while True: | |
2753 | if i < _len(genlist): |
|
2755 | if i < _len(genlist): | |
2754 | yield genlist[i] |
|
2756 | yield genlist[i] | |
2755 | else: |
|
2757 | else: | |
2756 | yield nextrev() |
|
2758 | yield nextrev() | |
2757 | i += 1 |
|
2759 | i += 1 | |
2758 | return gen() |
|
2760 | return gen() | |
2759 |
|
2761 | |||
2760 | def _consumegen(self): |
|
2762 | def _consumegen(self): | |
2761 | cache = self._cache |
|
2763 | cache = self._cache | |
2762 | genlist = self._genlist.append |
|
2764 | genlist = self._genlist.append | |
2763 | for item in self._gen: |
|
2765 | for item in self._gen: | |
2764 | cache[item] = True |
|
2766 | cache[item] = True | |
2765 | genlist(item) |
|
2767 | genlist(item) | |
2766 | yield item |
|
2768 | yield item | |
2767 | if not self._finished: |
|
2769 | if not self._finished: | |
2768 | self._finished = True |
|
2770 | self._finished = True | |
2769 | asc = self._genlist[:] |
|
2771 | asc = self._genlist[:] | |
2770 | asc.sort() |
|
2772 | asc.sort() | |
2771 | self._asclist = asc |
|
2773 | self._asclist = asc | |
2772 | self.fastasc = asc.__iter__ |
|
2774 | self.fastasc = asc.__iter__ | |
2773 | self.fastdesc = asc.__reversed__ |
|
2775 | self.fastdesc = asc.__reversed__ | |
2774 |
|
2776 | |||
2775 | def __len__(self): |
|
2777 | def __len__(self): | |
2776 | for x in self._consumegen(): |
|
2778 | for x in self._consumegen(): | |
2777 | pass |
|
2779 | pass | |
2778 | return len(self._genlist) |
|
2780 | return len(self._genlist) | |
2779 |
|
2781 | |||
2780 | def sort(self, reverse=False): |
|
2782 | def sort(self, reverse=False): | |
2781 | self._ascending = not reverse |
|
2783 | self._ascending = not reverse | |
2782 |
|
2784 | |||
2783 | def reverse(self): |
|
2785 | def reverse(self): | |
2784 | self._ascending = not self._ascending |
|
2786 | self._ascending = not self._ascending | |
2785 |
|
2787 | |||
2786 | def isascending(self): |
|
2788 | def isascending(self): | |
2787 | return self._ascending |
|
2789 | return self._ascending | |
2788 |
|
2790 | |||
2789 | def isdescending(self): |
|
2791 | def isdescending(self): | |
2790 | return not self._ascending |
|
2792 | return not self._ascending | |
2791 |
|
2793 | |||
2792 | def first(self): |
|
2794 | def first(self): | |
2793 | if self._ascending: |
|
2795 | if self._ascending: | |
2794 | it = self.fastasc |
|
2796 | it = self.fastasc | |
2795 | else: |
|
2797 | else: | |
2796 | it = self.fastdesc |
|
2798 | it = self.fastdesc | |
2797 | if it is None: |
|
2799 | if it is None: | |
2798 | # we need to consume all and try again |
|
2800 | # we need to consume all and try again | |
2799 | for x in self._consumegen(): |
|
2801 | for x in self._consumegen(): | |
2800 | pass |
|
2802 | pass | |
2801 | return self.first() |
|
2803 | return self.first() | |
2802 | if self: |
|
2804 | if self: | |
2803 | return it.next() |
|
2805 | return it.next() | |
2804 | return None |
|
2806 | return None | |
2805 |
|
2807 | |||
2806 | def last(self): |
|
2808 | def last(self): | |
2807 | if self._ascending: |
|
2809 | if self._ascending: | |
2808 | it = self.fastdesc |
|
2810 | it = self.fastdesc | |
2809 | else: |
|
2811 | else: | |
2810 | it = self.fastasc |
|
2812 | it = self.fastasc | |
2811 | if it is None: |
|
2813 | if it is None: | |
2812 | # we need to consume all and try again |
|
2814 | # we need to consume all and try again | |
2813 | for x in self._consumegen(): |
|
2815 | for x in self._consumegen(): | |
2814 | pass |
|
2816 | pass | |
2815 | return self.first() |
|
2817 | return self.first() | |
2816 | if self: |
|
2818 | if self: | |
2817 | return it.next() |
|
2819 | return it.next() | |
2818 | return None |
|
2820 | return None | |
2819 |
|
2821 | |||
2820 | def spanset(repo, start=None, end=None): |
|
2822 | def spanset(repo, start=None, end=None): | |
2821 | """factory function to dispatch between fullreposet and actual spanset |
|
2823 | """factory function to dispatch between fullreposet and actual spanset | |
2822 |
|
2824 | |||
2823 | Feel free to update all spanset call sites and kill this function at some |
|
2825 | Feel free to update all spanset call sites and kill this function at some | |
2824 | point. |
|
2826 | point. | |
2825 | """ |
|
2827 | """ | |
2826 | if start is None and end is None: |
|
2828 | if start is None and end is None: | |
2827 | return fullreposet(repo) |
|
2829 | return fullreposet(repo) | |
2828 | return _spanset(repo, start, end) |
|
2830 | return _spanset(repo, start, end) | |
2829 |
|
2831 | |||
2830 |
|
2832 | |||
2831 | class _spanset(abstractsmartset): |
|
2833 | class _spanset(abstractsmartset): | |
2832 | """Duck type for baseset class which represents a range of revisions and |
|
2834 | """Duck type for baseset class which represents a range of revisions and | |
2833 | can work lazily and without having all the range in memory |
|
2835 | can work lazily and without having all the range in memory | |
2834 |
|
2836 | |||
2835 | Note that spanset(x, y) behave almost like xrange(x, y) except for two |
|
2837 | Note that spanset(x, y) behave almost like xrange(x, y) except for two | |
2836 | notable points: |
|
2838 | notable points: | |
2837 | - when x < y it will be automatically descending, |
|
2839 | - when x < y it will be automatically descending, | |
2838 | - revision filtered with this repoview will be skipped. |
|
2840 | - revision filtered with this repoview will be skipped. | |
2839 |
|
2841 | |||
2840 | """ |
|
2842 | """ | |
2841 | def __init__(self, repo, start=0, end=None): |
|
2843 | def __init__(self, repo, start=0, end=None): | |
2842 | """ |
|
2844 | """ | |
2843 | start: first revision included the set |
|
2845 | start: first revision included the set | |
2844 | (default to 0) |
|
2846 | (default to 0) | |
2845 | end: first revision excluded (last+1) |
|
2847 | end: first revision excluded (last+1) | |
2846 | (default to len(repo) |
|
2848 | (default to len(repo) | |
2847 |
|
2849 | |||
2848 | Spanset will be descending if `end` < `start`. |
|
2850 | Spanset will be descending if `end` < `start`. | |
2849 | """ |
|
2851 | """ | |
2850 | if end is None: |
|
2852 | if end is None: | |
2851 | end = len(repo) |
|
2853 | end = len(repo) | |
2852 | self._ascending = start <= end |
|
2854 | self._ascending = start <= end | |
2853 | if not self._ascending: |
|
2855 | if not self._ascending: | |
2854 | start, end = end + 1, start +1 |
|
2856 | start, end = end + 1, start +1 | |
2855 | self._start = start |
|
2857 | self._start = start | |
2856 | self._end = end |
|
2858 | self._end = end | |
2857 | self._hiddenrevs = repo.changelog.filteredrevs |
|
2859 | self._hiddenrevs = repo.changelog.filteredrevs | |
2858 |
|
2860 | |||
2859 | def sort(self, reverse=False): |
|
2861 | def sort(self, reverse=False): | |
2860 | self._ascending = not reverse |
|
2862 | self._ascending = not reverse | |
2861 |
|
2863 | |||
2862 | def reverse(self): |
|
2864 | def reverse(self): | |
2863 | self._ascending = not self._ascending |
|
2865 | self._ascending = not self._ascending | |
2864 |
|
2866 | |||
2865 | def _iterfilter(self, iterrange): |
|
2867 | def _iterfilter(self, iterrange): | |
2866 | s = self._hiddenrevs |
|
2868 | s = self._hiddenrevs | |
2867 | for r in iterrange: |
|
2869 | for r in iterrange: | |
2868 | if r not in s: |
|
2870 | if r not in s: | |
2869 | yield r |
|
2871 | yield r | |
2870 |
|
2872 | |||
2871 | def __iter__(self): |
|
2873 | def __iter__(self): | |
2872 | if self._ascending: |
|
2874 | if self._ascending: | |
2873 | return self.fastasc() |
|
2875 | return self.fastasc() | |
2874 | else: |
|
2876 | else: | |
2875 | return self.fastdesc() |
|
2877 | return self.fastdesc() | |
2876 |
|
2878 | |||
2877 | def fastasc(self): |
|
2879 | def fastasc(self): | |
2878 | iterrange = xrange(self._start, self._end) |
|
2880 | iterrange = xrange(self._start, self._end) | |
2879 | if self._hiddenrevs: |
|
2881 | if self._hiddenrevs: | |
2880 | return self._iterfilter(iterrange) |
|
2882 | return self._iterfilter(iterrange) | |
2881 | return iter(iterrange) |
|
2883 | return iter(iterrange) | |
2882 |
|
2884 | |||
2883 | def fastdesc(self): |
|
2885 | def fastdesc(self): | |
2884 | iterrange = xrange(self._end - 1, self._start - 1, -1) |
|
2886 | iterrange = xrange(self._end - 1, self._start - 1, -1) | |
2885 | if self._hiddenrevs: |
|
2887 | if self._hiddenrevs: | |
2886 | return self._iterfilter(iterrange) |
|
2888 | return self._iterfilter(iterrange) | |
2887 | return iter(iterrange) |
|
2889 | return iter(iterrange) | |
2888 |
|
2890 | |||
2889 | def __contains__(self, rev): |
|
2891 | def __contains__(self, rev): | |
2890 | hidden = self._hiddenrevs |
|
2892 | hidden = self._hiddenrevs | |
2891 | return ((self._start <= rev < self._end) |
|
2893 | return ((self._start <= rev < self._end) | |
2892 | and not (hidden and rev in hidden)) |
|
2894 | and not (hidden and rev in hidden)) | |
2893 |
|
2895 | |||
2894 | def __nonzero__(self): |
|
2896 | def __nonzero__(self): | |
2895 | for r in self: |
|
2897 | for r in self: | |
2896 | return True |
|
2898 | return True | |
2897 | return False |
|
2899 | return False | |
2898 |
|
2900 | |||
2899 | def __len__(self): |
|
2901 | def __len__(self): | |
2900 | if not self._hiddenrevs: |
|
2902 | if not self._hiddenrevs: | |
2901 | return abs(self._end - self._start) |
|
2903 | return abs(self._end - self._start) | |
2902 | else: |
|
2904 | else: | |
2903 | count = 0 |
|
2905 | count = 0 | |
2904 | start = self._start |
|
2906 | start = self._start | |
2905 | end = self._end |
|
2907 | end = self._end | |
2906 | for rev in self._hiddenrevs: |
|
2908 | for rev in self._hiddenrevs: | |
2907 | if (end < rev <= start) or (start <= rev < end): |
|
2909 | if (end < rev <= start) or (start <= rev < end): | |
2908 | count += 1 |
|
2910 | count += 1 | |
2909 | return abs(self._end - self._start) - count |
|
2911 | return abs(self._end - self._start) - count | |
2910 |
|
2912 | |||
2911 | def isascending(self): |
|
2913 | def isascending(self): | |
2912 | return self._start <= self._end |
|
2914 | return self._start <= self._end | |
2913 |
|
2915 | |||
2914 | def isdescending(self): |
|
2916 | def isdescending(self): | |
2915 | return self._start >= self._end |
|
2917 | return self._start >= self._end | |
2916 |
|
2918 | |||
2917 | def first(self): |
|
2919 | def first(self): | |
2918 | if self._ascending: |
|
2920 | if self._ascending: | |
2919 | it = self.fastasc |
|
2921 | it = self.fastasc | |
2920 | else: |
|
2922 | else: | |
2921 | it = self.fastdesc |
|
2923 | it = self.fastdesc | |
2922 | for x in it(): |
|
2924 | for x in it(): | |
2923 | return x |
|
2925 | return x | |
2924 | return None |
|
2926 | return None | |
2925 |
|
2927 | |||
2926 | def last(self): |
|
2928 | def last(self): | |
2927 | if self._ascending: |
|
2929 | if self._ascending: | |
2928 | it = self.fastdesc |
|
2930 | it = self.fastdesc | |
2929 | else: |
|
2931 | else: | |
2930 | it = self.fastasc |
|
2932 | it = self.fastasc | |
2931 | for x in it(): |
|
2933 | for x in it(): | |
2932 | return x |
|
2934 | return x | |
2933 | return None |
|
2935 | return None | |
2934 |
|
2936 | |||
2935 | class fullreposet(_spanset): |
|
2937 | class fullreposet(_spanset): | |
2936 | """a set containing all revisions in the repo |
|
2938 | """a set containing all revisions in the repo | |
2937 |
|
2939 | |||
2938 | This class exists to host special optimisation. |
|
2940 | This class exists to host special optimisation. | |
2939 | """ |
|
2941 | """ | |
2940 |
|
2942 | |||
2941 | def __init__(self, repo): |
|
2943 | def __init__(self, repo): | |
2942 | super(fullreposet, self).__init__(repo) |
|
2944 | super(fullreposet, self).__init__(repo) | |
2943 |
|
2945 | |||
2944 | def __and__(self, other): |
|
2946 | def __and__(self, other): | |
2945 | """fullrepo & other -> other |
|
2947 | """fullrepo & other -> other | |
2946 |
|
2948 | |||
2947 | As self contains the whole repo, all of the other set should also be in |
|
2949 | As self contains the whole repo, all of the other set should also be in | |
2948 | self. Therefor `self & other = other`. |
|
2950 | self. Therefor `self & other = other`. | |
2949 |
|
2951 | |||
2950 | This boldly assumes the other contains valid revs only. |
|
2952 | This boldly assumes the other contains valid revs only. | |
2951 | """ |
|
2953 | """ | |
2952 | # other not a smartset, make is so |
|
2954 | # other not a smartset, make is so | |
2953 | if not util.safehasattr(other, 'isascending'): |
|
2955 | if not util.safehasattr(other, 'isascending'): | |
2954 | # filter out hidden revision |
|
2956 | # filter out hidden revision | |
2955 | # (this boldly assumes all smartset are pure) |
|
2957 | # (this boldly assumes all smartset are pure) | |
2956 | # |
|
2958 | # | |
2957 | # `other` was used with "&", let's assume this is a set like |
|
2959 | # `other` was used with "&", let's assume this is a set like | |
2958 | # object. |
|
2960 | # object. | |
2959 | other = baseset(other - self._hiddenrevs) |
|
2961 | other = baseset(other - self._hiddenrevs) | |
2960 |
|
2962 | |||
2961 | if self.isascending(): |
|
2963 | if self.isascending(): | |
2962 | other.sort() |
|
2964 | other.sort() | |
2963 | else: |
|
2965 | else: | |
2964 | other.sort(reverse) |
|
2966 | other.sort(reverse) | |
2965 | return other |
|
2967 | return other | |
2966 |
|
2968 | |||
2967 | # tell hggettext to extract docstrings from these functions: |
|
2969 | # tell hggettext to extract docstrings from these functions: | |
2968 | i18nfunctions = symbols.values() |
|
2970 | i18nfunctions = symbols.values() |
@@ -1,753 +1,755 b'' | |||||
1 | $ cat >> $HGRCPATH << EOF |
|
1 | $ cat >> $HGRCPATH << EOF | |
2 | > [phases] |
|
2 | > [phases] | |
3 | > # public changeset are not obsolete |
|
3 | > # public changeset are not obsolete | |
4 | > publish=false |
|
4 | > publish=false | |
5 | > [ui] |
|
5 | > [ui] | |
6 | > logtemplate="{rev}:{node|short} ({phase}) [{tags} {bookmarks}] {desc|firstline}\n" |
|
6 | > logtemplate="{rev}:{node|short} ({phase}) [{tags} {bookmarks}] {desc|firstline}\n" | |
7 | > EOF |
|
7 | > EOF | |
8 | $ mkcommit() { |
|
8 | $ mkcommit() { | |
9 | > echo "$1" > "$1" |
|
9 | > echo "$1" > "$1" | |
10 | > hg add "$1" |
|
10 | > hg add "$1" | |
11 | > hg ci -m "add $1" |
|
11 | > hg ci -m "add $1" | |
12 | > } |
|
12 | > } | |
13 | $ getid() { |
|
13 | $ getid() { | |
14 | > hg id --debug --hidden -ir "desc('$1')" |
|
14 | > hg id --debug --hidden -ir "desc('$1')" | |
15 | > } |
|
15 | > } | |
16 |
|
16 | |||
17 | $ cat > debugkeys.py <<EOF |
|
17 | $ cat > debugkeys.py <<EOF | |
18 | > def reposetup(ui, repo): |
|
18 | > def reposetup(ui, repo): | |
19 | > class debugkeysrepo(repo.__class__): |
|
19 | > class debugkeysrepo(repo.__class__): | |
20 | > def listkeys(self, namespace): |
|
20 | > def listkeys(self, namespace): | |
21 | > ui.write('listkeys %s\n' % (namespace,)) |
|
21 | > ui.write('listkeys %s\n' % (namespace,)) | |
22 | > return super(debugkeysrepo, self).listkeys(namespace) |
|
22 | > return super(debugkeysrepo, self).listkeys(namespace) | |
23 | > |
|
23 | > | |
24 | > if repo.local(): |
|
24 | > if repo.local(): | |
25 | > repo.__class__ = debugkeysrepo |
|
25 | > repo.__class__ = debugkeysrepo | |
26 | > EOF |
|
26 | > EOF | |
27 |
|
27 | |||
28 | $ hg init tmpa |
|
28 | $ hg init tmpa | |
29 | $ cd tmpa |
|
29 | $ cd tmpa | |
30 | $ mkcommit kill_me |
|
30 | $ mkcommit kill_me | |
31 |
|
31 | |||
32 | Checking that the feature is properly disabled |
|
32 | Checking that the feature is properly disabled | |
33 |
|
33 | |||
34 | $ hg debugobsolete -d '0 0' `getid kill_me` -u babar |
|
34 | $ hg debugobsolete -d '0 0' `getid kill_me` -u babar | |
35 | abort: creating obsolete markers is not enabled on this repo |
|
35 | abort: creating obsolete markers is not enabled on this repo | |
36 | [255] |
|
36 | [255] | |
37 |
|
37 | |||
38 | Enabling it |
|
38 | Enabling it | |
39 |
|
39 | |||
40 | $ cat >> $HGRCPATH << EOF |
|
40 | $ cat >> $HGRCPATH << EOF | |
41 | > [experimental] |
|
41 | > [experimental] | |
42 | > evolution=createmarkers,exchange |
|
42 | > evolution=createmarkers,exchange | |
43 | > EOF |
|
43 | > EOF | |
44 |
|
44 | |||
45 | Killing a single changeset without replacement |
|
45 | Killing a single changeset without replacement | |
46 |
|
46 | |||
47 | $ hg debugobsolete 0 |
|
47 | $ hg debugobsolete 0 | |
48 | abort: changeset references must be full hexadecimal node identifiers |
|
48 | abort: changeset references must be full hexadecimal node identifiers | |
49 | [255] |
|
49 | [255] | |
50 | $ hg debugobsolete '00' |
|
50 | $ hg debugobsolete '00' | |
51 | abort: changeset references must be full hexadecimal node identifiers |
|
51 | abort: changeset references must be full hexadecimal node identifiers | |
52 | [255] |
|
52 | [255] | |
53 | $ hg debugobsolete -d '0 0' `getid kill_me` -u babar |
|
53 | $ hg debugobsolete -d '0 0' `getid kill_me` -u babar | |
54 | $ hg debugobsolete |
|
54 | $ hg debugobsolete | |
55 | 97b7c2d76b1845ed3eb988cd612611e72406cef0 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'babar'} |
|
55 | 97b7c2d76b1845ed3eb988cd612611e72406cef0 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'babar'} | |
56 |
|
56 | |||
57 | (test that mercurial is not confused) |
|
57 | (test that mercurial is not confused) | |
58 |
|
58 | |||
59 | $ hg up null --quiet # having 0 as parent prevents it to be hidden |
|
59 | $ hg up null --quiet # having 0 as parent prevents it to be hidden | |
60 | $ hg tip |
|
60 | $ hg tip | |
61 | -1:000000000000 (public) [tip ] |
|
61 | -1:000000000000 (public) [tip ] | |
62 | $ hg up --hidden tip --quiet |
|
62 | $ hg up --hidden tip --quiet | |
63 |
|
63 | |||
64 | Killing a single changeset with itself should fail |
|
64 | Killing a single changeset with itself should fail | |
65 | (simple local safeguard) |
|
65 | (simple local safeguard) | |
66 |
|
66 | |||
67 | $ hg debugobsolete `getid kill_me` `getid kill_me` |
|
67 | $ hg debugobsolete `getid kill_me` `getid kill_me` | |
68 | abort: bad obsmarker input: in-marker cycle with 97b7c2d76b1845ed3eb988cd612611e72406cef0 |
|
68 | abort: bad obsmarker input: in-marker cycle with 97b7c2d76b1845ed3eb988cd612611e72406cef0 | |
69 | [255] |
|
69 | [255] | |
70 |
|
70 | |||
71 | $ cd .. |
|
71 | $ cd .. | |
72 |
|
72 | |||
73 | Killing a single changeset with replacement |
|
73 | Killing a single changeset with replacement | |
74 | (and testing the format option) |
|
74 | (and testing the format option) | |
75 |
|
75 | |||
76 | $ hg init tmpb |
|
76 | $ hg init tmpb | |
77 | $ cd tmpb |
|
77 | $ cd tmpb | |
78 | $ mkcommit a |
|
78 | $ mkcommit a | |
79 | $ mkcommit b |
|
79 | $ mkcommit b | |
80 | $ mkcommit original_c |
|
80 | $ mkcommit original_c | |
81 | $ hg up "desc('b')" |
|
81 | $ hg up "desc('b')" | |
82 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
82 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
83 | $ mkcommit new_c |
|
83 | $ mkcommit new_c | |
84 | created new head |
|
84 | created new head | |
85 | $ hg log -r 'hidden()' --template '{rev}:{node|short} {desc}\n' --hidden |
|
85 | $ hg log -r 'hidden()' --template '{rev}:{node|short} {desc}\n' --hidden | |
86 | $ hg debugobsolete --config format.obsstore-version=0 --flag 12 `getid original_c` `getid new_c` -d '56 120' |
|
86 | $ hg debugobsolete --config format.obsstore-version=0 --flag 12 `getid original_c` `getid new_c` -d '56 120' | |
87 | $ hg log -r 'hidden()' --template '{rev}:{node|short} {desc}\n' --hidden |
|
87 | $ hg log -r 'hidden()' --template '{rev}:{node|short} {desc}\n' --hidden | |
88 | 2:245bde4270cd add original_c |
|
88 | 2:245bde4270cd add original_c | |
89 | $ hg debugrevlog -cd |
|
89 | $ hg debugrevlog -cd | |
90 | # rev p1rev p2rev start end deltastart base p1 p2 rawsize totalsize compression heads chainlen |
|
90 | # rev p1rev p2rev start end deltastart base p1 p2 rawsize totalsize compression heads chainlen | |
91 | 0 -1 -1 0 59 0 0 0 0 58 58 0 1 0 |
|
91 | 0 -1 -1 0 59 0 0 0 0 58 58 0 1 0 | |
92 | 1 0 -1 59 118 59 59 0 0 58 116 0 1 0 |
|
92 | 1 0 -1 59 118 59 59 0 0 58 116 0 1 0 | |
93 | 2 1 -1 118 204 59 59 59 0 76 192 0 1 1 |
|
93 | 2 1 -1 118 204 59 59 59 0 76 192 0 1 1 | |
94 | 3 1 -1 204 271 204 204 59 0 66 258 0 2 0 |
|
94 | 3 1 -1 204 271 204 204 59 0 66 258 0 2 0 | |
95 | $ hg debugobsolete |
|
95 | $ hg debugobsolete | |
96 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} |
|
96 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} | |
97 |
|
97 | |||
98 | (check for version number of the obsstore) |
|
98 | (check for version number of the obsstore) | |
99 |
|
99 | |||
100 | $ dd bs=1 count=1 if=.hg/store/obsstore 2>/dev/null |
|
100 | $ dd bs=1 count=1 if=.hg/store/obsstore 2>/dev/null | |
101 | \x00 (no-eol) (esc) |
|
101 | \x00 (no-eol) (esc) | |
102 |
|
102 | |||
103 | do it again (it read the obsstore before adding new changeset) |
|
103 | do it again (it read the obsstore before adding new changeset) | |
104 |
|
104 | |||
105 | $ hg up '.^' |
|
105 | $ hg up '.^' | |
106 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
106 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
107 | $ mkcommit new_2_c |
|
107 | $ mkcommit new_2_c | |
108 | created new head |
|
108 | created new head | |
109 | $ hg debugobsolete -d '1337 0' `getid new_c` `getid new_2_c` |
|
109 | $ hg debugobsolete -d '1337 0' `getid new_c` `getid new_2_c` | |
110 | $ hg debugobsolete |
|
110 | $ hg debugobsolete | |
111 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} |
|
111 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} | |
112 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} |
|
112 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} | |
113 |
|
113 | |||
114 | Register two markers with a missing node |
|
114 | Register two markers with a missing node | |
115 |
|
115 | |||
116 | $ hg up '.^' |
|
116 | $ hg up '.^' | |
117 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
117 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
118 | $ mkcommit new_3_c |
|
118 | $ mkcommit new_3_c | |
119 | created new head |
|
119 | created new head | |
120 | $ hg debugobsolete -d '1338 0' `getid new_2_c` 1337133713371337133713371337133713371337 |
|
120 | $ hg debugobsolete -d '1338 0' `getid new_2_c` 1337133713371337133713371337133713371337 | |
121 | $ hg debugobsolete -d '1339 0' 1337133713371337133713371337133713371337 `getid new_3_c` |
|
121 | $ hg debugobsolete -d '1339 0' 1337133713371337133713371337133713371337 `getid new_3_c` | |
122 | $ hg debugobsolete |
|
122 | $ hg debugobsolete | |
123 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} |
|
123 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} | |
124 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} |
|
124 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} | |
125 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} |
|
125 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} | |
126 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} |
|
126 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} | |
127 |
|
127 | |||
128 | Refuse pathological nullid successors |
|
128 | Refuse pathological nullid successors | |
129 | $ hg debugobsolete -d '9001 0' 1337133713371337133713371337133713371337 0000000000000000000000000000000000000000 |
|
129 | $ hg debugobsolete -d '9001 0' 1337133713371337133713371337133713371337 0000000000000000000000000000000000000000 | |
130 | transaction abort! |
|
130 | transaction abort! | |
131 | rollback completed |
|
131 | rollback completed | |
132 | abort: bad obsolescence marker detected: invalid successors nullid |
|
132 | abort: bad obsolescence marker detected: invalid successors nullid | |
133 | [255] |
|
133 | [255] | |
134 |
|
134 | |||
135 | Check that graphlog detect that a changeset is obsolete: |
|
135 | Check that graphlog detect that a changeset is obsolete: | |
136 |
|
136 | |||
137 | $ hg log -G |
|
137 | $ hg log -G | |
138 | @ 5:5601fb93a350 (draft) [tip ] add new_3_c |
|
138 | @ 5:5601fb93a350 (draft) [tip ] add new_3_c | |
139 | | |
|
139 | | | |
140 | o 1:7c3bad9141dc (draft) [ ] add b |
|
140 | o 1:7c3bad9141dc (draft) [ ] add b | |
141 | | |
|
141 | | | |
142 | o 0:1f0dee641bb7 (draft) [ ] add a |
|
142 | o 0:1f0dee641bb7 (draft) [ ] add a | |
143 |
|
143 | |||
144 |
|
144 | |||
145 | check that heads does not report them |
|
145 | check that heads does not report them | |
146 |
|
146 | |||
147 | $ hg heads |
|
147 | $ hg heads | |
148 | 5:5601fb93a350 (draft) [tip ] add new_3_c |
|
148 | 5:5601fb93a350 (draft) [tip ] add new_3_c | |
149 | $ hg heads --hidden |
|
149 | $ hg heads --hidden | |
150 | 5:5601fb93a350 (draft) [tip ] add new_3_c |
|
150 | 5:5601fb93a350 (draft) [tip ] add new_3_c | |
151 | 4:ca819180edb9 (draft) [ ] add new_2_c |
|
151 | 4:ca819180edb9 (draft) [ ] add new_2_c | |
152 | 3:cdbce2fbb163 (draft) [ ] add new_c |
|
152 | 3:cdbce2fbb163 (draft) [ ] add new_c | |
153 | 2:245bde4270cd (draft) [ ] add original_c |
|
153 | 2:245bde4270cd (draft) [ ] add original_c | |
154 |
|
154 | |||
155 |
|
155 | |||
156 | check that summary does not report them |
|
156 | check that summary does not report them | |
157 |
|
157 | |||
158 | $ hg init ../sink |
|
158 | $ hg init ../sink | |
159 | $ echo '[paths]' >> .hg/hgrc |
|
159 | $ echo '[paths]' >> .hg/hgrc | |
160 | $ echo 'default=../sink' >> .hg/hgrc |
|
160 | $ echo 'default=../sink' >> .hg/hgrc | |
161 | $ hg summary --remote |
|
161 | $ hg summary --remote | |
162 | parent: 5:5601fb93a350 tip |
|
162 | parent: 5:5601fb93a350 tip | |
163 | add new_3_c |
|
163 | add new_3_c | |
164 | branch: default |
|
164 | branch: default | |
165 | commit: (clean) |
|
165 | commit: (clean) | |
166 | update: (current) |
|
166 | update: (current) | |
167 | remote: 3 outgoing |
|
167 | remote: 3 outgoing | |
168 |
|
168 | |||
169 | $ hg summary --remote --hidden |
|
169 | $ hg summary --remote --hidden | |
170 | parent: 5:5601fb93a350 tip |
|
170 | parent: 5:5601fb93a350 tip | |
171 | add new_3_c |
|
171 | add new_3_c | |
172 | branch: default |
|
172 | branch: default | |
173 | commit: (clean) |
|
173 | commit: (clean) | |
174 | update: 3 new changesets, 4 branch heads (merge) |
|
174 | update: 3 new changesets, 4 branch heads (merge) | |
175 | remote: 3 outgoing |
|
175 | remote: 3 outgoing | |
176 |
|
176 | |||
177 | check that various commands work well with filtering |
|
177 | check that various commands work well with filtering | |
178 |
|
178 | |||
179 | $ hg tip |
|
179 | $ hg tip | |
180 | 5:5601fb93a350 (draft) [tip ] add new_3_c |
|
180 | 5:5601fb93a350 (draft) [tip ] add new_3_c | |
181 | $ hg log -r 6 |
|
181 | $ hg log -r 6 | |
182 | abort: unknown revision '6'! |
|
182 | abort: unknown revision '6'! | |
183 | [255] |
|
183 | [255] | |
184 | $ hg log -r 4 |
|
184 | $ hg log -r 4 | |
185 | abort: hidden revision '4'! |
|
185 | abort: hidden revision '4'! | |
186 | (use --hidden to access hidden revisions) |
|
186 | (use --hidden to access hidden revisions) | |
187 | [255] |
|
187 | [255] | |
|
188 | $ hg debugrevspec 'rev(6)' | |||
|
189 | $ hg debugrevspec 'rev(4)' | |||
188 |
|
190 | |||
189 | Check that public changeset are not accounted as obsolete: |
|
191 | Check that public changeset are not accounted as obsolete: | |
190 |
|
192 | |||
191 | $ hg --hidden phase --public 2 |
|
193 | $ hg --hidden phase --public 2 | |
192 | $ hg log -G |
|
194 | $ hg log -G | |
193 | @ 5:5601fb93a350 (draft) [tip ] add new_3_c |
|
195 | @ 5:5601fb93a350 (draft) [tip ] add new_3_c | |
194 | | |
|
196 | | | |
195 | | o 2:245bde4270cd (public) [ ] add original_c |
|
197 | | o 2:245bde4270cd (public) [ ] add original_c | |
196 | |/ |
|
198 | |/ | |
197 | o 1:7c3bad9141dc (public) [ ] add b |
|
199 | o 1:7c3bad9141dc (public) [ ] add b | |
198 | | |
|
200 | | | |
199 | o 0:1f0dee641bb7 (public) [ ] add a |
|
201 | o 0:1f0dee641bb7 (public) [ ] add a | |
200 |
|
202 | |||
201 |
|
203 | |||
202 | And that bumped changeset are detected |
|
204 | And that bumped changeset are detected | |
203 | -------------------------------------- |
|
205 | -------------------------------------- | |
204 |
|
206 | |||
205 | If we didn't filtered obsolete changesets out, 3 and 4 would show up too. Also |
|
207 | If we didn't filtered obsolete changesets out, 3 and 4 would show up too. Also | |
206 | note that the bumped changeset (5:5601fb93a350) is not a direct successor of |
|
208 | note that the bumped changeset (5:5601fb93a350) is not a direct successor of | |
207 | the public changeset |
|
209 | the public changeset | |
208 |
|
210 | |||
209 | $ hg log --hidden -r 'bumped()' |
|
211 | $ hg log --hidden -r 'bumped()' | |
210 | 5:5601fb93a350 (draft) [tip ] add new_3_c |
|
212 | 5:5601fb93a350 (draft) [tip ] add new_3_c | |
211 |
|
213 | |||
212 | And that we can't push bumped changeset |
|
214 | And that we can't push bumped changeset | |
213 |
|
215 | |||
214 | $ hg push ../tmpa -r 0 --force #(make repo related) |
|
216 | $ hg push ../tmpa -r 0 --force #(make repo related) | |
215 | pushing to ../tmpa |
|
217 | pushing to ../tmpa | |
216 | searching for changes |
|
218 | searching for changes | |
217 | warning: repository is unrelated |
|
219 | warning: repository is unrelated | |
218 | adding changesets |
|
220 | adding changesets | |
219 | adding manifests |
|
221 | adding manifests | |
220 | adding file changes |
|
222 | adding file changes | |
221 | added 1 changesets with 1 changes to 1 files (+1 heads) |
|
223 | added 1 changesets with 1 changes to 1 files (+1 heads) | |
222 | $ hg push ../tmpa |
|
224 | $ hg push ../tmpa | |
223 | pushing to ../tmpa |
|
225 | pushing to ../tmpa | |
224 | searching for changes |
|
226 | searching for changes | |
225 | abort: push includes bumped changeset: 5601fb93a350! |
|
227 | abort: push includes bumped changeset: 5601fb93a350! | |
226 | [255] |
|
228 | [255] | |
227 |
|
229 | |||
228 | Fixing "bumped" situation |
|
230 | Fixing "bumped" situation | |
229 | We need to create a clone of 5 and add a special marker with a flag |
|
231 | We need to create a clone of 5 and add a special marker with a flag | |
230 |
|
232 | |||
231 | $ hg up '5^' |
|
233 | $ hg up '5^' | |
232 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
234 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
233 | $ hg revert -ar 5 |
|
235 | $ hg revert -ar 5 | |
234 | adding new_3_c |
|
236 | adding new_3_c | |
235 | $ hg ci -m 'add n3w_3_c' |
|
237 | $ hg ci -m 'add n3w_3_c' | |
236 | created new head |
|
238 | created new head | |
237 | $ hg debugobsolete -d '1338 0' --flags 1 `getid new_3_c` `getid n3w_3_c` |
|
239 | $ hg debugobsolete -d '1338 0' --flags 1 `getid new_3_c` `getid n3w_3_c` | |
238 | $ hg log -r 'bumped()' |
|
240 | $ hg log -r 'bumped()' | |
239 | $ hg log -G |
|
241 | $ hg log -G | |
240 | @ 6:6f9641995072 (draft) [tip ] add n3w_3_c |
|
242 | @ 6:6f9641995072 (draft) [tip ] add n3w_3_c | |
241 | | |
|
243 | | | |
242 | | o 2:245bde4270cd (public) [ ] add original_c |
|
244 | | o 2:245bde4270cd (public) [ ] add original_c | |
243 | |/ |
|
245 | |/ | |
244 | o 1:7c3bad9141dc (public) [ ] add b |
|
246 | o 1:7c3bad9141dc (public) [ ] add b | |
245 | | |
|
247 | | | |
246 | o 0:1f0dee641bb7 (public) [ ] add a |
|
248 | o 0:1f0dee641bb7 (public) [ ] add a | |
247 |
|
249 | |||
248 |
|
250 | |||
249 |
|
251 | |||
250 |
|
252 | |||
251 | $ cd .. |
|
253 | $ cd .. | |
252 |
|
254 | |||
253 | Exchange Test |
|
255 | Exchange Test | |
254 | ============================ |
|
256 | ============================ | |
255 |
|
257 | |||
256 | Destination repo does not have any data |
|
258 | Destination repo does not have any data | |
257 | --------------------------------------- |
|
259 | --------------------------------------- | |
258 |
|
260 | |||
259 | Simple incoming test |
|
261 | Simple incoming test | |
260 |
|
262 | |||
261 | $ hg init tmpc |
|
263 | $ hg init tmpc | |
262 | $ cd tmpc |
|
264 | $ cd tmpc | |
263 | $ hg incoming ../tmpb |
|
265 | $ hg incoming ../tmpb | |
264 | comparing with ../tmpb |
|
266 | comparing with ../tmpb | |
265 | 0:1f0dee641bb7 (public) [ ] add a |
|
267 | 0:1f0dee641bb7 (public) [ ] add a | |
266 | 1:7c3bad9141dc (public) [ ] add b |
|
268 | 1:7c3bad9141dc (public) [ ] add b | |
267 | 2:245bde4270cd (public) [ ] add original_c |
|
269 | 2:245bde4270cd (public) [ ] add original_c | |
268 | 6:6f9641995072 (draft) [tip ] add n3w_3_c |
|
270 | 6:6f9641995072 (draft) [tip ] add n3w_3_c | |
269 |
|
271 | |||
270 | Try to pull markers |
|
272 | Try to pull markers | |
271 | (extinct changeset are excluded but marker are pushed) |
|
273 | (extinct changeset are excluded but marker are pushed) | |
272 |
|
274 | |||
273 | $ hg pull ../tmpb |
|
275 | $ hg pull ../tmpb | |
274 | pulling from ../tmpb |
|
276 | pulling from ../tmpb | |
275 | requesting all changes |
|
277 | requesting all changes | |
276 | adding changesets |
|
278 | adding changesets | |
277 | adding manifests |
|
279 | adding manifests | |
278 | adding file changes |
|
280 | adding file changes | |
279 | added 4 changesets with 4 changes to 4 files (+1 heads) |
|
281 | added 4 changesets with 4 changes to 4 files (+1 heads) | |
280 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
282 | (run 'hg heads' to see heads, 'hg merge' to merge) | |
281 | $ hg debugobsolete |
|
283 | $ hg debugobsolete | |
282 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} |
|
284 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} | |
283 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} |
|
285 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} | |
284 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} |
|
286 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} | |
285 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} |
|
287 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} | |
286 | 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} |
|
288 | 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} | |
287 |
|
289 | |||
288 | Rollback//Transaction support |
|
290 | Rollback//Transaction support | |
289 |
|
291 | |||
290 | $ hg debugobsolete -d '1340 0' aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb |
|
292 | $ hg debugobsolete -d '1340 0' aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | |
291 | $ hg debugobsolete |
|
293 | $ hg debugobsolete | |
292 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} |
|
294 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} | |
293 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} |
|
295 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} | |
294 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} |
|
296 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} | |
295 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} |
|
297 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} | |
296 | 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} |
|
298 | 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} | |
297 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 0 (Thu Jan 01 00:22:20 1970 +0000) {'user': 'test'} |
|
299 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 0 (Thu Jan 01 00:22:20 1970 +0000) {'user': 'test'} | |
298 | $ hg rollback -n |
|
300 | $ hg rollback -n | |
299 | repository tip rolled back to revision 3 (undo debugobsolete) |
|
301 | repository tip rolled back to revision 3 (undo debugobsolete) | |
300 | $ hg rollback |
|
302 | $ hg rollback | |
301 | repository tip rolled back to revision 3 (undo debugobsolete) |
|
303 | repository tip rolled back to revision 3 (undo debugobsolete) | |
302 | $ hg debugobsolete |
|
304 | $ hg debugobsolete | |
303 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} |
|
305 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} | |
304 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} |
|
306 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} | |
305 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} |
|
307 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} | |
306 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} |
|
308 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} | |
307 | 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} |
|
309 | 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} | |
308 |
|
310 | |||
309 | $ cd .. |
|
311 | $ cd .. | |
310 |
|
312 | |||
311 | Try to push markers |
|
313 | Try to push markers | |
312 |
|
314 | |||
313 | $ hg init tmpd |
|
315 | $ hg init tmpd | |
314 | $ hg -R tmpb push tmpd |
|
316 | $ hg -R tmpb push tmpd | |
315 | pushing to tmpd |
|
317 | pushing to tmpd | |
316 | searching for changes |
|
318 | searching for changes | |
317 | adding changesets |
|
319 | adding changesets | |
318 | adding manifests |
|
320 | adding manifests | |
319 | adding file changes |
|
321 | adding file changes | |
320 | added 4 changesets with 4 changes to 4 files (+1 heads) |
|
322 | added 4 changesets with 4 changes to 4 files (+1 heads) | |
321 | $ hg -R tmpd debugobsolete | sort |
|
323 | $ hg -R tmpd debugobsolete | sort | |
322 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} |
|
324 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} | |
323 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} |
|
325 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} | |
324 | 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} |
|
326 | 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} | |
325 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} |
|
327 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} | |
326 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} |
|
328 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} | |
327 |
|
329 | |||
328 | Check obsolete keys are exchanged only if source has an obsolete store |
|
330 | Check obsolete keys are exchanged only if source has an obsolete store | |
329 |
|
331 | |||
330 | $ hg init empty |
|
332 | $ hg init empty | |
331 | $ hg --config extensions.debugkeys=debugkeys.py -R empty push tmpd |
|
333 | $ hg --config extensions.debugkeys=debugkeys.py -R empty push tmpd | |
332 | pushing to tmpd |
|
334 | pushing to tmpd | |
333 | listkeys phases |
|
335 | listkeys phases | |
334 | listkeys bookmarks |
|
336 | listkeys bookmarks | |
335 | no changes found |
|
337 | no changes found | |
336 | listkeys phases |
|
338 | listkeys phases | |
337 | [1] |
|
339 | [1] | |
338 |
|
340 | |||
339 | clone support |
|
341 | clone support | |
340 | (markers are copied and extinct changesets are included to allow hardlinks) |
|
342 | (markers are copied and extinct changesets are included to allow hardlinks) | |
341 |
|
343 | |||
342 | $ hg clone tmpb clone-dest |
|
344 | $ hg clone tmpb clone-dest | |
343 | updating to branch default |
|
345 | updating to branch default | |
344 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
346 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
345 | $ hg -R clone-dest log -G --hidden |
|
347 | $ hg -R clone-dest log -G --hidden | |
346 | @ 6:6f9641995072 (draft) [tip ] add n3w_3_c |
|
348 | @ 6:6f9641995072 (draft) [tip ] add n3w_3_c | |
347 | | |
|
349 | | | |
348 | | x 5:5601fb93a350 (draft) [ ] add new_3_c |
|
350 | | x 5:5601fb93a350 (draft) [ ] add new_3_c | |
349 | |/ |
|
351 | |/ | |
350 | | x 4:ca819180edb9 (draft) [ ] add new_2_c |
|
352 | | x 4:ca819180edb9 (draft) [ ] add new_2_c | |
351 | |/ |
|
353 | |/ | |
352 | | x 3:cdbce2fbb163 (draft) [ ] add new_c |
|
354 | | x 3:cdbce2fbb163 (draft) [ ] add new_c | |
353 | |/ |
|
355 | |/ | |
354 | | o 2:245bde4270cd (public) [ ] add original_c |
|
356 | | o 2:245bde4270cd (public) [ ] add original_c | |
355 | |/ |
|
357 | |/ | |
356 | o 1:7c3bad9141dc (public) [ ] add b |
|
358 | o 1:7c3bad9141dc (public) [ ] add b | |
357 | | |
|
359 | | | |
358 | o 0:1f0dee641bb7 (public) [ ] add a |
|
360 | o 0:1f0dee641bb7 (public) [ ] add a | |
359 |
|
361 | |||
360 | $ hg -R clone-dest debugobsolete |
|
362 | $ hg -R clone-dest debugobsolete | |
361 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} |
|
363 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} | |
362 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} |
|
364 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} | |
363 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} |
|
365 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} | |
364 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} |
|
366 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} | |
365 | 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} |
|
367 | 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} | |
366 |
|
368 | |||
367 |
|
369 | |||
368 | Destination repo have existing data |
|
370 | Destination repo have existing data | |
369 | --------------------------------------- |
|
371 | --------------------------------------- | |
370 |
|
372 | |||
371 | On pull |
|
373 | On pull | |
372 |
|
374 | |||
373 | $ hg init tmpe |
|
375 | $ hg init tmpe | |
374 | $ cd tmpe |
|
376 | $ cd tmpe | |
375 | $ hg debugobsolete -d '1339 0' 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 |
|
377 | $ hg debugobsolete -d '1339 0' 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 | |
376 | $ hg pull ../tmpb |
|
378 | $ hg pull ../tmpb | |
377 | pulling from ../tmpb |
|
379 | pulling from ../tmpb | |
378 | requesting all changes |
|
380 | requesting all changes | |
379 | adding changesets |
|
381 | adding changesets | |
380 | adding manifests |
|
382 | adding manifests | |
381 | adding file changes |
|
383 | adding file changes | |
382 | added 4 changesets with 4 changes to 4 files (+1 heads) |
|
384 | added 4 changesets with 4 changes to 4 files (+1 heads) | |
383 | (run 'hg heads' to see heads, 'hg merge' to merge) |
|
385 | (run 'hg heads' to see heads, 'hg merge' to merge) | |
384 | $ hg debugobsolete |
|
386 | $ hg debugobsolete | |
385 | 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} |
|
387 | 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} | |
386 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} |
|
388 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} | |
387 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} |
|
389 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} | |
388 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} |
|
390 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} | |
389 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} |
|
391 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} | |
390 | 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} |
|
392 | 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} | |
391 |
|
393 | |||
392 |
|
394 | |||
393 | On push |
|
395 | On push | |
394 |
|
396 | |||
395 | $ hg push ../tmpc |
|
397 | $ hg push ../tmpc | |
396 | pushing to ../tmpc |
|
398 | pushing to ../tmpc | |
397 | searching for changes |
|
399 | searching for changes | |
398 | no changes found |
|
400 | no changes found | |
399 | [1] |
|
401 | [1] | |
400 | $ hg -R ../tmpc debugobsolete |
|
402 | $ hg -R ../tmpc debugobsolete | |
401 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} |
|
403 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} | |
402 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} |
|
404 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} | |
403 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} |
|
405 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} | |
404 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} |
|
406 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} | |
405 | 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} |
|
407 | 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} | |
406 | 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} |
|
408 | 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} | |
407 |
|
409 | |||
408 | detect outgoing obsolete and unstable |
|
410 | detect outgoing obsolete and unstable | |
409 | --------------------------------------- |
|
411 | --------------------------------------- | |
410 |
|
412 | |||
411 |
|
413 | |||
412 | $ hg log -G |
|
414 | $ hg log -G | |
413 | o 3:6f9641995072 (draft) [tip ] add n3w_3_c |
|
415 | o 3:6f9641995072 (draft) [tip ] add n3w_3_c | |
414 | | |
|
416 | | | |
415 | | o 2:245bde4270cd (public) [ ] add original_c |
|
417 | | o 2:245bde4270cd (public) [ ] add original_c | |
416 | |/ |
|
418 | |/ | |
417 | o 1:7c3bad9141dc (public) [ ] add b |
|
419 | o 1:7c3bad9141dc (public) [ ] add b | |
418 | | |
|
420 | | | |
419 | o 0:1f0dee641bb7 (public) [ ] add a |
|
421 | o 0:1f0dee641bb7 (public) [ ] add a | |
420 |
|
422 | |||
421 | $ hg up 'desc("n3w_3_c")' |
|
423 | $ hg up 'desc("n3w_3_c")' | |
422 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
424 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
423 | $ mkcommit original_d |
|
425 | $ mkcommit original_d | |
424 | $ mkcommit original_e |
|
426 | $ mkcommit original_e | |
425 | $ hg debugobsolete --record-parents `getid original_d` -d '0 0' |
|
427 | $ hg debugobsolete --record-parents `getid original_d` -d '0 0' | |
426 | $ hg debugobsolete | grep `getid original_d` |
|
428 | $ hg debugobsolete | grep `getid original_d` | |
427 | 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'} |
|
429 | 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'} | |
428 | $ hg log -r 'obsolete()' |
|
430 | $ hg log -r 'obsolete()' | |
429 | 4:94b33453f93b (draft) [ ] add original_d |
|
431 | 4:94b33453f93b (draft) [ ] add original_d | |
430 | $ hg log -G -r '::unstable()' |
|
432 | $ hg log -G -r '::unstable()' | |
431 | @ 5:cda648ca50f5 (draft) [tip ] add original_e |
|
433 | @ 5:cda648ca50f5 (draft) [tip ] add original_e | |
432 | | |
|
434 | | | |
433 | x 4:94b33453f93b (draft) [ ] add original_d |
|
435 | x 4:94b33453f93b (draft) [ ] add original_d | |
434 | | |
|
436 | | | |
435 | o 3:6f9641995072 (draft) [ ] add n3w_3_c |
|
437 | o 3:6f9641995072 (draft) [ ] add n3w_3_c | |
436 | | |
|
438 | | | |
437 | o 1:7c3bad9141dc (public) [ ] add b |
|
439 | o 1:7c3bad9141dc (public) [ ] add b | |
438 | | |
|
440 | | | |
439 | o 0:1f0dee641bb7 (public) [ ] add a |
|
441 | o 0:1f0dee641bb7 (public) [ ] add a | |
440 |
|
442 | |||
441 |
|
443 | |||
442 | refuse to push obsolete changeset |
|
444 | refuse to push obsolete changeset | |
443 |
|
445 | |||
444 | $ hg push ../tmpc/ -r 'desc("original_d")' |
|
446 | $ hg push ../tmpc/ -r 'desc("original_d")' | |
445 | pushing to ../tmpc/ |
|
447 | pushing to ../tmpc/ | |
446 | searching for changes |
|
448 | searching for changes | |
447 | abort: push includes obsolete changeset: 94b33453f93b! |
|
449 | abort: push includes obsolete changeset: 94b33453f93b! | |
448 | [255] |
|
450 | [255] | |
449 |
|
451 | |||
450 | refuse to push unstable changeset |
|
452 | refuse to push unstable changeset | |
451 |
|
453 | |||
452 | $ hg push ../tmpc/ |
|
454 | $ hg push ../tmpc/ | |
453 | pushing to ../tmpc/ |
|
455 | pushing to ../tmpc/ | |
454 | searching for changes |
|
456 | searching for changes | |
455 | abort: push includes unstable changeset: cda648ca50f5! |
|
457 | abort: push includes unstable changeset: cda648ca50f5! | |
456 | [255] |
|
458 | [255] | |
457 |
|
459 | |||
458 | Test that extinct changeset are properly detected |
|
460 | Test that extinct changeset are properly detected | |
459 |
|
461 | |||
460 | $ hg log -r 'extinct()' |
|
462 | $ hg log -r 'extinct()' | |
461 |
|
463 | |||
462 | Don't try to push extinct changeset |
|
464 | Don't try to push extinct changeset | |
463 |
|
465 | |||
464 | $ hg init ../tmpf |
|
466 | $ hg init ../tmpf | |
465 | $ hg out ../tmpf |
|
467 | $ hg out ../tmpf | |
466 | comparing with ../tmpf |
|
468 | comparing with ../tmpf | |
467 | searching for changes |
|
469 | searching for changes | |
468 | 0:1f0dee641bb7 (public) [ ] add a |
|
470 | 0:1f0dee641bb7 (public) [ ] add a | |
469 | 1:7c3bad9141dc (public) [ ] add b |
|
471 | 1:7c3bad9141dc (public) [ ] add b | |
470 | 2:245bde4270cd (public) [ ] add original_c |
|
472 | 2:245bde4270cd (public) [ ] add original_c | |
471 | 3:6f9641995072 (draft) [ ] add n3w_3_c |
|
473 | 3:6f9641995072 (draft) [ ] add n3w_3_c | |
472 | 4:94b33453f93b (draft) [ ] add original_d |
|
474 | 4:94b33453f93b (draft) [ ] add original_d | |
473 | 5:cda648ca50f5 (draft) [tip ] add original_e |
|
475 | 5:cda648ca50f5 (draft) [tip ] add original_e | |
474 | $ hg push ../tmpf -f # -f because be push unstable too |
|
476 | $ hg push ../tmpf -f # -f because be push unstable too | |
475 | pushing to ../tmpf |
|
477 | pushing to ../tmpf | |
476 | searching for changes |
|
478 | searching for changes | |
477 | adding changesets |
|
479 | adding changesets | |
478 | adding manifests |
|
480 | adding manifests | |
479 | adding file changes |
|
481 | adding file changes | |
480 | added 6 changesets with 6 changes to 6 files (+1 heads) |
|
482 | added 6 changesets with 6 changes to 6 files (+1 heads) | |
481 |
|
483 | |||
482 | no warning displayed |
|
484 | no warning displayed | |
483 |
|
485 | |||
484 | $ hg push ../tmpf |
|
486 | $ hg push ../tmpf | |
485 | pushing to ../tmpf |
|
487 | pushing to ../tmpf | |
486 | searching for changes |
|
488 | searching for changes | |
487 | no changes found |
|
489 | no changes found | |
488 | [1] |
|
490 | [1] | |
489 |
|
491 | |||
490 | Do not warn about new head when the new head is a successors of a remote one |
|
492 | Do not warn about new head when the new head is a successors of a remote one | |
491 |
|
493 | |||
492 | $ hg log -G |
|
494 | $ hg log -G | |
493 | @ 5:cda648ca50f5 (draft) [tip ] add original_e |
|
495 | @ 5:cda648ca50f5 (draft) [tip ] add original_e | |
494 | | |
|
496 | | | |
495 | x 4:94b33453f93b (draft) [ ] add original_d |
|
497 | x 4:94b33453f93b (draft) [ ] add original_d | |
496 | | |
|
498 | | | |
497 | o 3:6f9641995072 (draft) [ ] add n3w_3_c |
|
499 | o 3:6f9641995072 (draft) [ ] add n3w_3_c | |
498 | | |
|
500 | | | |
499 | | o 2:245bde4270cd (public) [ ] add original_c |
|
501 | | o 2:245bde4270cd (public) [ ] add original_c | |
500 | |/ |
|
502 | |/ | |
501 | o 1:7c3bad9141dc (public) [ ] add b |
|
503 | o 1:7c3bad9141dc (public) [ ] add b | |
502 | | |
|
504 | | | |
503 | o 0:1f0dee641bb7 (public) [ ] add a |
|
505 | o 0:1f0dee641bb7 (public) [ ] add a | |
504 |
|
506 | |||
505 | $ hg up -q 'desc(n3w_3_c)' |
|
507 | $ hg up -q 'desc(n3w_3_c)' | |
506 | $ mkcommit obsolete_e |
|
508 | $ mkcommit obsolete_e | |
507 | created new head |
|
509 | created new head | |
508 | $ hg debugobsolete `getid 'original_e'` `getid 'obsolete_e'` |
|
510 | $ hg debugobsolete `getid 'original_e'` `getid 'obsolete_e'` | |
509 | $ hg outgoing ../tmpf # parasite hg outgoing testin |
|
511 | $ hg outgoing ../tmpf # parasite hg outgoing testin | |
510 | comparing with ../tmpf |
|
512 | comparing with ../tmpf | |
511 | searching for changes |
|
513 | searching for changes | |
512 | 6:3de5eca88c00 (draft) [tip ] add obsolete_e |
|
514 | 6:3de5eca88c00 (draft) [tip ] add obsolete_e | |
513 | $ hg push ../tmpf |
|
515 | $ hg push ../tmpf | |
514 | pushing to ../tmpf |
|
516 | pushing to ../tmpf | |
515 | searching for changes |
|
517 | searching for changes | |
516 | adding changesets |
|
518 | adding changesets | |
517 | adding manifests |
|
519 | adding manifests | |
518 | adding file changes |
|
520 | adding file changes | |
519 | added 1 changesets with 1 changes to 1 files (+1 heads) |
|
521 | added 1 changesets with 1 changes to 1 files (+1 heads) | |
520 |
|
522 | |||
521 | test relevance computation |
|
523 | test relevance computation | |
522 | --------------------------------------- |
|
524 | --------------------------------------- | |
523 |
|
525 | |||
524 | Checking simple case of "marker relevance". |
|
526 | Checking simple case of "marker relevance". | |
525 |
|
527 | |||
526 |
|
528 | |||
527 | Reminder of the repo situation |
|
529 | Reminder of the repo situation | |
528 |
|
530 | |||
529 | $ hg log --hidden --graph |
|
531 | $ hg log --hidden --graph | |
530 | @ 6:3de5eca88c00 (draft) [tip ] add obsolete_e |
|
532 | @ 6:3de5eca88c00 (draft) [tip ] add obsolete_e | |
531 | | |
|
533 | | | |
532 | | x 5:cda648ca50f5 (draft) [ ] add original_e |
|
534 | | x 5:cda648ca50f5 (draft) [ ] add original_e | |
533 | | | |
|
535 | | | | |
534 | | x 4:94b33453f93b (draft) [ ] add original_d |
|
536 | | x 4:94b33453f93b (draft) [ ] add original_d | |
535 | |/ |
|
537 | |/ | |
536 | o 3:6f9641995072 (draft) [ ] add n3w_3_c |
|
538 | o 3:6f9641995072 (draft) [ ] add n3w_3_c | |
537 | | |
|
539 | | | |
538 | | o 2:245bde4270cd (public) [ ] add original_c |
|
540 | | o 2:245bde4270cd (public) [ ] add original_c | |
539 | |/ |
|
541 | |/ | |
540 | o 1:7c3bad9141dc (public) [ ] add b |
|
542 | o 1:7c3bad9141dc (public) [ ] add b | |
541 | | |
|
543 | | | |
542 | o 0:1f0dee641bb7 (public) [ ] add a |
|
544 | o 0:1f0dee641bb7 (public) [ ] add a | |
543 |
|
545 | |||
544 |
|
546 | |||
545 | List of all markers |
|
547 | List of all markers | |
546 |
|
548 | |||
547 | $ hg debugobsolete |
|
549 | $ hg debugobsolete | |
548 | 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} |
|
550 | 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} | |
549 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} |
|
551 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} | |
550 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} |
|
552 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} | |
551 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} |
|
553 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} | |
552 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} |
|
554 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} | |
553 | 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} |
|
555 | 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} | |
554 | 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'} |
|
556 | 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'} | |
555 | cda648ca50f50482b7055c0b0c4c117bba6733d9 3de5eca88c00aa039da7399a220f4a5221faa585 0 (*) {'user': 'test'} (glob) |
|
557 | cda648ca50f50482b7055c0b0c4c117bba6733d9 3de5eca88c00aa039da7399a220f4a5221faa585 0 (*) {'user': 'test'} (glob) | |
556 |
|
558 | |||
557 | List of changesets with no chain |
|
559 | List of changesets with no chain | |
558 |
|
560 | |||
559 | $ hg debugobsolete --hidden --rev ::2 |
|
561 | $ hg debugobsolete --hidden --rev ::2 | |
560 |
|
562 | |||
561 | List of changesets that are included on marker chain |
|
563 | List of changesets that are included on marker chain | |
562 |
|
564 | |||
563 | $ hg debugobsolete --hidden --rev 6 |
|
565 | $ hg debugobsolete --hidden --rev 6 | |
564 | cda648ca50f50482b7055c0b0c4c117bba6733d9 3de5eca88c00aa039da7399a220f4a5221faa585 0 (*) {'user': 'test'} (glob) |
|
566 | cda648ca50f50482b7055c0b0c4c117bba6733d9 3de5eca88c00aa039da7399a220f4a5221faa585 0 (*) {'user': 'test'} (glob) | |
565 |
|
567 | |||
566 | List of changesets with a longer chain, (including a pruned children) |
|
568 | List of changesets with a longer chain, (including a pruned children) | |
567 |
|
569 | |||
568 | $ hg debugobsolete --hidden --rev 3 |
|
570 | $ hg debugobsolete --hidden --rev 3 | |
569 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} |
|
571 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} | |
570 | 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} |
|
572 | 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} | |
571 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} |
|
573 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} | |
572 | 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} |
|
574 | 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} | |
573 | 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'} |
|
575 | 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'} | |
574 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} |
|
576 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} | |
575 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} |
|
577 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} | |
576 |
|
578 | |||
577 | List of both |
|
579 | List of both | |
578 |
|
580 | |||
579 | $ hg debugobsolete --hidden --rev 3::6 |
|
581 | $ hg debugobsolete --hidden --rev 3::6 | |
580 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} |
|
582 | 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} | |
581 | 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} |
|
583 | 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} | |
582 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} |
|
584 | 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Wed Dec 31 23:58:56 1969 -0002) {'user': 'test'} | |
583 | 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} |
|
585 | 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} | |
584 | 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'} |
|
586 | 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'} | |
585 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} |
|
587 | ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} | |
586 | cda648ca50f50482b7055c0b0c4c117bba6733d9 3de5eca88c00aa039da7399a220f4a5221faa585 0 (*) {'user': 'test'} (glob) |
|
588 | cda648ca50f50482b7055c0b0c4c117bba6733d9 3de5eca88c00aa039da7399a220f4a5221faa585 0 (*) {'user': 'test'} (glob) | |
587 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} |
|
589 | cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} | |
588 |
|
590 | |||
589 | #if serve |
|
591 | #if serve | |
590 |
|
592 | |||
591 | check hgweb does not explode |
|
593 | check hgweb does not explode | |
592 | ==================================== |
|
594 | ==================================== | |
593 |
|
595 | |||
594 | $ hg unbundle $TESTDIR/bundles/hgweb+obs.hg |
|
596 | $ hg unbundle $TESTDIR/bundles/hgweb+obs.hg | |
595 | adding changesets |
|
597 | adding changesets | |
596 | adding manifests |
|
598 | adding manifests | |
597 | adding file changes |
|
599 | adding file changes | |
598 | added 62 changesets with 63 changes to 9 files (+60 heads) |
|
600 | added 62 changesets with 63 changes to 9 files (+60 heads) | |
599 | (run 'hg heads .' to see heads, 'hg merge' to merge) |
|
601 | (run 'hg heads .' to see heads, 'hg merge' to merge) | |
600 | $ for node in `hg log -r 'desc(babar_)' --template '{node}\n'`; |
|
602 | $ for node in `hg log -r 'desc(babar_)' --template '{node}\n'`; | |
601 | > do |
|
603 | > do | |
602 | > hg debugobsolete $node |
|
604 | > hg debugobsolete $node | |
603 | > done |
|
605 | > done | |
604 | $ hg up tip |
|
606 | $ hg up tip | |
605 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
607 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
606 |
|
608 | |||
607 | $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log |
|
609 | $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log | |
608 | $ cat hg.pid >> $DAEMON_PIDS |
|
610 | $ cat hg.pid >> $DAEMON_PIDS | |
609 |
|
611 | |||
610 | check changelog view |
|
612 | check changelog view | |
611 |
|
613 | |||
612 | $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'shortlog/' |
|
614 | $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'shortlog/' | |
613 | 200 Script output follows |
|
615 | 200 Script output follows | |
614 |
|
616 | |||
615 | check graph view |
|
617 | check graph view | |
616 |
|
618 | |||
617 | $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'graph' |
|
619 | $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'graph' | |
618 | 200 Script output follows |
|
620 | 200 Script output follows | |
619 |
|
621 | |||
620 | check filelog view |
|
622 | check filelog view | |
621 |
|
623 | |||
622 | $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'log/'`hg id --debug --id`/'babar' |
|
624 | $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'log/'`hg id --debug --id`/'babar' | |
623 | 200 Script output follows |
|
625 | 200 Script output follows | |
624 |
|
626 | |||
625 | $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'rev/68' |
|
627 | $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'rev/68' | |
626 | 200 Script output follows |
|
628 | 200 Script output follows | |
627 | $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'rev/67' |
|
629 | $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'rev/67' | |
628 | 404 Not Found |
|
630 | 404 Not Found | |
629 | [1] |
|
631 | [1] | |
630 |
|
632 | |||
631 | check that web.view config option: |
|
633 | check that web.view config option: | |
632 |
|
634 | |||
633 | $ "$TESTDIR/killdaemons.py" hg.pid |
|
635 | $ "$TESTDIR/killdaemons.py" hg.pid | |
634 | $ cat >> .hg/hgrc << EOF |
|
636 | $ cat >> .hg/hgrc << EOF | |
635 | > [web] |
|
637 | > [web] | |
636 | > view=all |
|
638 | > view=all | |
637 | > EOF |
|
639 | > EOF | |
638 | $ wait |
|
640 | $ wait | |
639 | $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log |
|
641 | $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log | |
640 | $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'rev/67' |
|
642 | $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'rev/67' | |
641 | 200 Script output follows |
|
643 | 200 Script output follows | |
642 | $ "$TESTDIR/killdaemons.py" hg.pid |
|
644 | $ "$TESTDIR/killdaemons.py" hg.pid | |
643 |
|
645 | |||
644 | Checking _enable=False warning if obsolete marker exists |
|
646 | Checking _enable=False warning if obsolete marker exists | |
645 |
|
647 | |||
646 | $ echo '[experimental]' >> $HGRCPATH |
|
648 | $ echo '[experimental]' >> $HGRCPATH | |
647 | $ echo "evolution=" >> $HGRCPATH |
|
649 | $ echo "evolution=" >> $HGRCPATH | |
648 | $ hg log -r tip |
|
650 | $ hg log -r tip | |
649 | obsolete feature not enabled but 68 markers found! |
|
651 | obsolete feature not enabled but 68 markers found! | |
650 | 68:c15e9edfca13 (draft) [tip ] add celestine |
|
652 | 68:c15e9edfca13 (draft) [tip ] add celestine | |
651 |
|
653 | |||
652 | reenable for later test |
|
654 | reenable for later test | |
653 |
|
655 | |||
654 | $ echo '[experimental]' >> $HGRCPATH |
|
656 | $ echo '[experimental]' >> $HGRCPATH | |
655 | $ echo "evolution=createmarkers,exchange" >> $HGRCPATH |
|
657 | $ echo "evolution=createmarkers,exchange" >> $HGRCPATH | |
656 |
|
658 | |||
657 | #endif |
|
659 | #endif | |
658 |
|
660 | |||
659 | Test incoming/outcoming with changesets obsoleted remotely, known locally |
|
661 | Test incoming/outcoming with changesets obsoleted remotely, known locally | |
660 | =============================================================================== |
|
662 | =============================================================================== | |
661 |
|
663 | |||
662 | This test issue 3805 |
|
664 | This test issue 3805 | |
663 |
|
665 | |||
664 | $ hg init repo-issue3805 |
|
666 | $ hg init repo-issue3805 | |
665 | $ cd repo-issue3805 |
|
667 | $ cd repo-issue3805 | |
666 | $ echo "foo" > foo |
|
668 | $ echo "foo" > foo | |
667 | $ hg ci -Am "A" |
|
669 | $ hg ci -Am "A" | |
668 | adding foo |
|
670 | adding foo | |
669 | $ hg clone . ../other-issue3805 |
|
671 | $ hg clone . ../other-issue3805 | |
670 | updating to branch default |
|
672 | updating to branch default | |
671 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
673 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
672 | $ echo "bar" >> foo |
|
674 | $ echo "bar" >> foo | |
673 | $ hg ci --amend |
|
675 | $ hg ci --amend | |
674 | $ cd ../other-issue3805 |
|
676 | $ cd ../other-issue3805 | |
675 | $ hg log -G |
|
677 | $ hg log -G | |
676 | @ 0:193e9254ce7e (draft) [tip ] A |
|
678 | @ 0:193e9254ce7e (draft) [tip ] A | |
677 |
|
679 | |||
678 | $ hg log -G -R ../repo-issue3805 |
|
680 | $ hg log -G -R ../repo-issue3805 | |
679 | @ 2:3816541e5485 (draft) [tip ] A |
|
681 | @ 2:3816541e5485 (draft) [tip ] A | |
680 |
|
682 | |||
681 | $ hg incoming |
|
683 | $ hg incoming | |
682 | comparing with $TESTTMP/tmpe/repo-issue3805 (glob) |
|
684 | comparing with $TESTTMP/tmpe/repo-issue3805 (glob) | |
683 | searching for changes |
|
685 | searching for changes | |
684 | 2:3816541e5485 (draft) [tip ] A |
|
686 | 2:3816541e5485 (draft) [tip ] A | |
685 | $ hg incoming --bundle ../issue3805.hg |
|
687 | $ hg incoming --bundle ../issue3805.hg | |
686 | comparing with $TESTTMP/tmpe/repo-issue3805 (glob) |
|
688 | comparing with $TESTTMP/tmpe/repo-issue3805 (glob) | |
687 | searching for changes |
|
689 | searching for changes | |
688 | 2:3816541e5485 (draft) [tip ] A |
|
690 | 2:3816541e5485 (draft) [tip ] A | |
689 | $ hg outgoing |
|
691 | $ hg outgoing | |
690 | comparing with $TESTTMP/tmpe/repo-issue3805 (glob) |
|
692 | comparing with $TESTTMP/tmpe/repo-issue3805 (glob) | |
691 | searching for changes |
|
693 | searching for changes | |
692 | no changes found |
|
694 | no changes found | |
693 | [1] |
|
695 | [1] | |
694 |
|
696 | |||
695 | #if serve |
|
697 | #if serve | |
696 |
|
698 | |||
697 | $ hg serve -R ../repo-issue3805 -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log |
|
699 | $ hg serve -R ../repo-issue3805 -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log | |
698 | $ cat hg.pid >> $DAEMON_PIDS |
|
700 | $ cat hg.pid >> $DAEMON_PIDS | |
699 |
|
701 | |||
700 | $ hg incoming http://localhost:$HGPORT |
|
702 | $ hg incoming http://localhost:$HGPORT | |
701 | comparing with http://localhost:$HGPORT/ |
|
703 | comparing with http://localhost:$HGPORT/ | |
702 | searching for changes |
|
704 | searching for changes | |
703 | 1:3816541e5485 (public) [tip ] A |
|
705 | 1:3816541e5485 (public) [tip ] A | |
704 | $ hg outgoing http://localhost:$HGPORT |
|
706 | $ hg outgoing http://localhost:$HGPORT | |
705 | comparing with http://localhost:$HGPORT/ |
|
707 | comparing with http://localhost:$HGPORT/ | |
706 | searching for changes |
|
708 | searching for changes | |
707 | no changes found |
|
709 | no changes found | |
708 | [1] |
|
710 | [1] | |
709 |
|
711 | |||
710 | $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS |
|
712 | $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS | |
711 |
|
713 | |||
712 | #endif |
|
714 | #endif | |
713 |
|
715 | |||
714 | This test issue 3814 |
|
716 | This test issue 3814 | |
715 |
|
717 | |||
716 | (nothing to push but locally hidden changeset) |
|
718 | (nothing to push but locally hidden changeset) | |
717 |
|
719 | |||
718 | $ cd .. |
|
720 | $ cd .. | |
719 | $ hg init repo-issue3814 |
|
721 | $ hg init repo-issue3814 | |
720 | $ cd repo-issue3805 |
|
722 | $ cd repo-issue3805 | |
721 | $ hg push -r 3816541e5485 ../repo-issue3814 |
|
723 | $ hg push -r 3816541e5485 ../repo-issue3814 | |
722 | pushing to ../repo-issue3814 |
|
724 | pushing to ../repo-issue3814 | |
723 | searching for changes |
|
725 | searching for changes | |
724 | adding changesets |
|
726 | adding changesets | |
725 | adding manifests |
|
727 | adding manifests | |
726 | adding file changes |
|
728 | adding file changes | |
727 | added 1 changesets with 1 changes to 1 files |
|
729 | added 1 changesets with 1 changes to 1 files | |
728 | $ hg out ../repo-issue3814 |
|
730 | $ hg out ../repo-issue3814 | |
729 | comparing with ../repo-issue3814 |
|
731 | comparing with ../repo-issue3814 | |
730 | searching for changes |
|
732 | searching for changes | |
731 | no changes found |
|
733 | no changes found | |
732 | [1] |
|
734 | [1] | |
733 |
|
735 | |||
734 | Test that a local tag blocks a changeset from being hidden |
|
736 | Test that a local tag blocks a changeset from being hidden | |
735 |
|
737 | |||
736 | $ hg tag -l visible -r 0 --hidden |
|
738 | $ hg tag -l visible -r 0 --hidden | |
737 | $ hg log -G |
|
739 | $ hg log -G | |
738 | @ 2:3816541e5485 (draft) [tip ] A |
|
740 | @ 2:3816541e5485 (draft) [tip ] A | |
739 |
|
741 | |||
740 | x 0:193e9254ce7e (draft) [visible ] A |
|
742 | x 0:193e9254ce7e (draft) [visible ] A | |
741 |
|
743 | |||
742 | Test that removing a local tag does not cause some commands to fail |
|
744 | Test that removing a local tag does not cause some commands to fail | |
743 |
|
745 | |||
744 | $ hg tag -l -r tip tiptag |
|
746 | $ hg tag -l -r tip tiptag | |
745 | $ hg tags |
|
747 | $ hg tags | |
746 | tiptag 2:3816541e5485 |
|
748 | tiptag 2:3816541e5485 | |
747 | tip 2:3816541e5485 |
|
749 | tip 2:3816541e5485 | |
748 | visible 0:193e9254ce7e |
|
750 | visible 0:193e9254ce7e | |
749 | $ hg --config extensions.strip= strip -r tip --no-backup |
|
751 | $ hg --config extensions.strip= strip -r tip --no-backup | |
750 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
752 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
751 | $ hg tags |
|
753 | $ hg tags | |
752 | visible 0:193e9254ce7e |
|
754 | visible 0:193e9254ce7e | |
753 | tip 0:193e9254ce7e |
|
755 | tip 0:193e9254ce7e |
@@ -1,1162 +1,1174 b'' | |||||
1 | $ HGENCODING=utf-8 |
|
1 | $ HGENCODING=utf-8 | |
2 | $ export HGENCODING |
|
2 | $ export HGENCODING | |
3 |
|
3 | |||
4 | $ try() { |
|
4 | $ try() { | |
5 | > hg debugrevspec --debug "$@" |
|
5 | > hg debugrevspec --debug "$@" | |
6 | > } |
|
6 | > } | |
7 |
|
7 | |||
8 | $ log() { |
|
8 | $ log() { | |
9 | > hg log --template '{rev}\n' -r "$1" |
|
9 | > hg log --template '{rev}\n' -r "$1" | |
10 | > } |
|
10 | > } | |
11 |
|
11 | |||
12 | $ hg init repo |
|
12 | $ hg init repo | |
13 | $ cd repo |
|
13 | $ cd repo | |
14 |
|
14 | |||
15 | $ echo a > a |
|
15 | $ echo a > a | |
16 | $ hg branch a |
|
16 | $ hg branch a | |
17 | marked working directory as branch a |
|
17 | marked working directory as branch a | |
18 | (branches are permanent and global, did you want a bookmark?) |
|
18 | (branches are permanent and global, did you want a bookmark?) | |
19 | $ hg ci -Aqm0 |
|
19 | $ hg ci -Aqm0 | |
20 |
|
20 | |||
21 | $ echo b > b |
|
21 | $ echo b > b | |
22 | $ hg branch b |
|
22 | $ hg branch b | |
23 | marked working directory as branch b |
|
23 | marked working directory as branch b | |
24 | (branches are permanent and global, did you want a bookmark?) |
|
24 | (branches are permanent and global, did you want a bookmark?) | |
25 | $ hg ci -Aqm1 |
|
25 | $ hg ci -Aqm1 | |
26 |
|
26 | |||
27 | $ rm a |
|
27 | $ rm a | |
28 | $ hg branch a-b-c- |
|
28 | $ hg branch a-b-c- | |
29 | marked working directory as branch a-b-c- |
|
29 | marked working directory as branch a-b-c- | |
30 | (branches are permanent and global, did you want a bookmark?) |
|
30 | (branches are permanent and global, did you want a bookmark?) | |
31 | $ hg ci -Aqm2 -u Bob |
|
31 | $ hg ci -Aqm2 -u Bob | |
32 |
|
32 | |||
33 | $ hg log -r "extra('branch', 'a-b-c-')" --template '{rev}\n' |
|
33 | $ hg log -r "extra('branch', 'a-b-c-')" --template '{rev}\n' | |
34 | 2 |
|
34 | 2 | |
35 | $ hg log -r "extra('branch')" --template '{rev}\n' |
|
35 | $ hg log -r "extra('branch')" --template '{rev}\n' | |
36 | 0 |
|
36 | 0 | |
37 | 1 |
|
37 | 1 | |
38 | 2 |
|
38 | 2 | |
39 | $ hg log -r "extra('branch', 're:a')" --template '{rev} {branch}\n' |
|
39 | $ hg log -r "extra('branch', 're:a')" --template '{rev} {branch}\n' | |
40 | 0 a |
|
40 | 0 a | |
41 | 2 a-b-c- |
|
41 | 2 a-b-c- | |
42 |
|
42 | |||
43 | $ hg co 1 |
|
43 | $ hg co 1 | |
44 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
44 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
45 | $ hg branch +a+b+c+ |
|
45 | $ hg branch +a+b+c+ | |
46 | marked working directory as branch +a+b+c+ |
|
46 | marked working directory as branch +a+b+c+ | |
47 | (branches are permanent and global, did you want a bookmark?) |
|
47 | (branches are permanent and global, did you want a bookmark?) | |
48 | $ hg ci -Aqm3 |
|
48 | $ hg ci -Aqm3 | |
49 |
|
49 | |||
50 | $ hg co 2 # interleave |
|
50 | $ hg co 2 # interleave | |
51 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
51 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
52 | $ echo bb > b |
|
52 | $ echo bb > b | |
53 | $ hg branch -- -a-b-c- |
|
53 | $ hg branch -- -a-b-c- | |
54 | marked working directory as branch -a-b-c- |
|
54 | marked working directory as branch -a-b-c- | |
55 | (branches are permanent and global, did you want a bookmark?) |
|
55 | (branches are permanent and global, did you want a bookmark?) | |
56 | $ hg ci -Aqm4 -d "May 12 2005" |
|
56 | $ hg ci -Aqm4 -d "May 12 2005" | |
57 |
|
57 | |||
58 | $ hg co 3 |
|
58 | $ hg co 3 | |
59 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
59 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
60 | $ hg branch !a/b/c/ |
|
60 | $ hg branch !a/b/c/ | |
61 | marked working directory as branch !a/b/c/ |
|
61 | marked working directory as branch !a/b/c/ | |
62 | (branches are permanent and global, did you want a bookmark?) |
|
62 | (branches are permanent and global, did you want a bookmark?) | |
63 | $ hg ci -Aqm"5 bug" |
|
63 | $ hg ci -Aqm"5 bug" | |
64 |
|
64 | |||
65 | $ hg merge 4 |
|
65 | $ hg merge 4 | |
66 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
66 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
67 | (branch merge, don't forget to commit) |
|
67 | (branch merge, don't forget to commit) | |
68 | $ hg branch _a_b_c_ |
|
68 | $ hg branch _a_b_c_ | |
69 | marked working directory as branch _a_b_c_ |
|
69 | marked working directory as branch _a_b_c_ | |
70 | (branches are permanent and global, did you want a bookmark?) |
|
70 | (branches are permanent and global, did you want a bookmark?) | |
71 | $ hg ci -Aqm"6 issue619" |
|
71 | $ hg ci -Aqm"6 issue619" | |
72 |
|
72 | |||
73 | $ hg branch .a.b.c. |
|
73 | $ hg branch .a.b.c. | |
74 | marked working directory as branch .a.b.c. |
|
74 | marked working directory as branch .a.b.c. | |
75 | (branches are permanent and global, did you want a bookmark?) |
|
75 | (branches are permanent and global, did you want a bookmark?) | |
76 | $ hg ci -Aqm7 |
|
76 | $ hg ci -Aqm7 | |
77 |
|
77 | |||
78 | $ hg branch all |
|
78 | $ hg branch all | |
79 | marked working directory as branch all |
|
79 | marked working directory as branch all | |
80 | (branches are permanent and global, did you want a bookmark?) |
|
80 | (branches are permanent and global, did you want a bookmark?) | |
81 |
|
81 | |||
82 | $ hg co 4 |
|
82 | $ hg co 4 | |
83 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
83 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
84 | $ hg branch Γ© |
|
84 | $ hg branch Γ© | |
85 | marked working directory as branch \xc3\xa9 (esc) |
|
85 | marked working directory as branch \xc3\xa9 (esc) | |
86 | (branches are permanent and global, did you want a bookmark?) |
|
86 | (branches are permanent and global, did you want a bookmark?) | |
87 | $ hg ci -Aqm9 |
|
87 | $ hg ci -Aqm9 | |
88 |
|
88 | |||
89 | $ hg tag -r6 1.0 |
|
89 | $ hg tag -r6 1.0 | |
90 |
|
90 | |||
91 | $ hg clone --quiet -U -r 7 . ../remote1 |
|
91 | $ hg clone --quiet -U -r 7 . ../remote1 | |
92 | $ hg clone --quiet -U -r 8 . ../remote2 |
|
92 | $ hg clone --quiet -U -r 8 . ../remote2 | |
93 | $ echo "[paths]" >> .hg/hgrc |
|
93 | $ echo "[paths]" >> .hg/hgrc | |
94 | $ echo "default = ../remote1" >> .hg/hgrc |
|
94 | $ echo "default = ../remote1" >> .hg/hgrc | |
95 |
|
95 | |||
96 | names that should work without quoting |
|
96 | names that should work without quoting | |
97 |
|
97 | |||
98 | $ try a |
|
98 | $ try a | |
99 | ('symbol', 'a') |
|
99 | ('symbol', 'a') | |
100 | 0 |
|
100 | 0 | |
101 | $ try b-a |
|
101 | $ try b-a | |
102 | (minus |
|
102 | (minus | |
103 | ('symbol', 'b') |
|
103 | ('symbol', 'b') | |
104 | ('symbol', 'a')) |
|
104 | ('symbol', 'a')) | |
105 | 1 |
|
105 | 1 | |
106 | $ try _a_b_c_ |
|
106 | $ try _a_b_c_ | |
107 | ('symbol', '_a_b_c_') |
|
107 | ('symbol', '_a_b_c_') | |
108 | 6 |
|
108 | 6 | |
109 | $ try _a_b_c_-a |
|
109 | $ try _a_b_c_-a | |
110 | (minus |
|
110 | (minus | |
111 | ('symbol', '_a_b_c_') |
|
111 | ('symbol', '_a_b_c_') | |
112 | ('symbol', 'a')) |
|
112 | ('symbol', 'a')) | |
113 | 6 |
|
113 | 6 | |
114 | $ try .a.b.c. |
|
114 | $ try .a.b.c. | |
115 | ('symbol', '.a.b.c.') |
|
115 | ('symbol', '.a.b.c.') | |
116 | 7 |
|
116 | 7 | |
117 | $ try .a.b.c.-a |
|
117 | $ try .a.b.c.-a | |
118 | (minus |
|
118 | (minus | |
119 | ('symbol', '.a.b.c.') |
|
119 | ('symbol', '.a.b.c.') | |
120 | ('symbol', 'a')) |
|
120 | ('symbol', 'a')) | |
121 | 7 |
|
121 | 7 | |
122 | $ try -- '-a-b-c-' # complains |
|
122 | $ try -- '-a-b-c-' # complains | |
123 | hg: parse error at 7: not a prefix: end |
|
123 | hg: parse error at 7: not a prefix: end | |
124 | [255] |
|
124 | [255] | |
125 | $ log -a-b-c- # succeeds with fallback |
|
125 | $ log -a-b-c- # succeeds with fallback | |
126 | 4 |
|
126 | 4 | |
127 |
|
127 | |||
128 | $ try -- -a-b-c--a # complains |
|
128 | $ try -- -a-b-c--a # complains | |
129 | (minus |
|
129 | (minus | |
130 | (minus |
|
130 | (minus | |
131 | (minus |
|
131 | (minus | |
132 | (negate |
|
132 | (negate | |
133 | ('symbol', 'a')) |
|
133 | ('symbol', 'a')) | |
134 | ('symbol', 'b')) |
|
134 | ('symbol', 'b')) | |
135 | ('symbol', 'c')) |
|
135 | ('symbol', 'c')) | |
136 | (negate |
|
136 | (negate | |
137 | ('symbol', 'a'))) |
|
137 | ('symbol', 'a'))) | |
138 | abort: unknown revision '-a'! |
|
138 | abort: unknown revision '-a'! | |
139 | [255] |
|
139 | [255] | |
140 | $ try Γ© |
|
140 | $ try Γ© | |
141 | ('symbol', '\xc3\xa9') |
|
141 | ('symbol', '\xc3\xa9') | |
142 | 9 |
|
142 | 9 | |
143 |
|
143 | |||
144 | no quoting needed |
|
144 | no quoting needed | |
145 |
|
145 | |||
146 | $ log ::a-b-c- |
|
146 | $ log ::a-b-c- | |
147 | 0 |
|
147 | 0 | |
148 | 1 |
|
148 | 1 | |
149 | 2 |
|
149 | 2 | |
150 |
|
150 | |||
151 | quoting needed |
|
151 | quoting needed | |
152 |
|
152 | |||
153 | $ try '"-a-b-c-"-a' |
|
153 | $ try '"-a-b-c-"-a' | |
154 | (minus |
|
154 | (minus | |
155 | ('string', '-a-b-c-') |
|
155 | ('string', '-a-b-c-') | |
156 | ('symbol', 'a')) |
|
156 | ('symbol', 'a')) | |
157 | 4 |
|
157 | 4 | |
158 |
|
158 | |||
159 | $ log '1 or 2' |
|
159 | $ log '1 or 2' | |
160 | 1 |
|
160 | 1 | |
161 | 2 |
|
161 | 2 | |
162 | $ log '1|2' |
|
162 | $ log '1|2' | |
163 | 1 |
|
163 | 1 | |
164 | 2 |
|
164 | 2 | |
165 | $ log '1 and 2' |
|
165 | $ log '1 and 2' | |
166 | $ log '1&2' |
|
166 | $ log '1&2' | |
167 | $ try '1&2|3' # precedence - and is higher |
|
167 | $ try '1&2|3' # precedence - and is higher | |
168 | (or |
|
168 | (or | |
169 | (and |
|
169 | (and | |
170 | ('symbol', '1') |
|
170 | ('symbol', '1') | |
171 | ('symbol', '2')) |
|
171 | ('symbol', '2')) | |
172 | ('symbol', '3')) |
|
172 | ('symbol', '3')) | |
173 | 3 |
|
173 | 3 | |
174 | $ try '1|2&3' |
|
174 | $ try '1|2&3' | |
175 | (or |
|
175 | (or | |
176 | ('symbol', '1') |
|
176 | ('symbol', '1') | |
177 | (and |
|
177 | (and | |
178 | ('symbol', '2') |
|
178 | ('symbol', '2') | |
179 | ('symbol', '3'))) |
|
179 | ('symbol', '3'))) | |
180 | 1 |
|
180 | 1 | |
181 | $ try '1&2&3' # associativity |
|
181 | $ try '1&2&3' # associativity | |
182 | (and |
|
182 | (and | |
183 | (and |
|
183 | (and | |
184 | ('symbol', '1') |
|
184 | ('symbol', '1') | |
185 | ('symbol', '2')) |
|
185 | ('symbol', '2')) | |
186 | ('symbol', '3')) |
|
186 | ('symbol', '3')) | |
187 | $ try '1|(2|3)' |
|
187 | $ try '1|(2|3)' | |
188 | (or |
|
188 | (or | |
189 | ('symbol', '1') |
|
189 | ('symbol', '1') | |
190 | (group |
|
190 | (group | |
191 | (or |
|
191 | (or | |
192 | ('symbol', '2') |
|
192 | ('symbol', '2') | |
193 | ('symbol', '3')))) |
|
193 | ('symbol', '3')))) | |
194 | 1 |
|
194 | 1 | |
195 | 2 |
|
195 | 2 | |
196 | 3 |
|
196 | 3 | |
197 | $ log '1.0' # tag |
|
197 | $ log '1.0' # tag | |
198 | 6 |
|
198 | 6 | |
199 | $ log 'a' # branch |
|
199 | $ log 'a' # branch | |
200 | 0 |
|
200 | 0 | |
201 | $ log '2785f51ee' |
|
201 | $ log '2785f51ee' | |
202 | 0 |
|
202 | 0 | |
203 | $ log 'date(2005)' |
|
203 | $ log 'date(2005)' | |
204 | 4 |
|
204 | 4 | |
205 | $ log 'date(this is a test)' |
|
205 | $ log 'date(this is a test)' | |
206 | hg: parse error at 10: unexpected token: symbol |
|
206 | hg: parse error at 10: unexpected token: symbol | |
207 | [255] |
|
207 | [255] | |
208 | $ log 'date()' |
|
208 | $ log 'date()' | |
209 | hg: parse error: date requires a string |
|
209 | hg: parse error: date requires a string | |
210 | [255] |
|
210 | [255] | |
211 | $ log 'date' |
|
211 | $ log 'date' | |
212 | hg: parse error: can't use date here |
|
212 | hg: parse error: can't use date here | |
213 | [255] |
|
213 | [255] | |
214 | $ log 'date(' |
|
214 | $ log 'date(' | |
215 | hg: parse error at 5: not a prefix: end |
|
215 | hg: parse error at 5: not a prefix: end | |
216 | [255] |
|
216 | [255] | |
217 | $ log 'date(tip)' |
|
217 | $ log 'date(tip)' | |
218 | abort: invalid date: 'tip' |
|
218 | abort: invalid date: 'tip' | |
219 | [255] |
|
219 | [255] | |
220 | $ log '"date"' |
|
220 | $ log '"date"' | |
221 | abort: unknown revision 'date'! |
|
221 | abort: unknown revision 'date'! | |
222 | [255] |
|
222 | [255] | |
223 | $ log 'date(2005) and 1::' |
|
223 | $ log 'date(2005) and 1::' | |
224 | 4 |
|
224 | 4 | |
225 |
|
225 | |||
226 | ancestor can accept 0 or more arguments |
|
226 | ancestor can accept 0 or more arguments | |
227 |
|
227 | |||
228 | $ log 'ancestor()' |
|
228 | $ log 'ancestor()' | |
229 | $ log 'ancestor(1)' |
|
229 | $ log 'ancestor(1)' | |
230 | 1 |
|
230 | 1 | |
231 | $ log 'ancestor(4,5)' |
|
231 | $ log 'ancestor(4,5)' | |
232 | 1 |
|
232 | 1 | |
233 | $ log 'ancestor(4,5) and 4' |
|
233 | $ log 'ancestor(4,5) and 4' | |
234 | $ log 'ancestor(0,0,1,3)' |
|
234 | $ log 'ancestor(0,0,1,3)' | |
235 | 0 |
|
235 | 0 | |
236 | $ log 'ancestor(3,1,5,3,5,1)' |
|
236 | $ log 'ancestor(3,1,5,3,5,1)' | |
237 | 1 |
|
237 | 1 | |
238 | $ log 'ancestor(0,1,3,5)' |
|
238 | $ log 'ancestor(0,1,3,5)' | |
239 | 0 |
|
239 | 0 | |
240 | $ log 'ancestor(1,2,3,4,5)' |
|
240 | $ log 'ancestor(1,2,3,4,5)' | |
241 | 1 |
|
241 | 1 | |
242 | $ log 'ancestors(5)' |
|
242 | $ log 'ancestors(5)' | |
243 | 0 |
|
243 | 0 | |
244 | 1 |
|
244 | 1 | |
245 | 3 |
|
245 | 3 | |
246 | 5 |
|
246 | 5 | |
247 | $ log 'ancestor(ancestors(5))' |
|
247 | $ log 'ancestor(ancestors(5))' | |
248 | 0 |
|
248 | 0 | |
249 | $ log 'author(bob)' |
|
249 | $ log 'author(bob)' | |
250 | 2 |
|
250 | 2 | |
251 | $ log 'author("re:bob|test")' |
|
251 | $ log 'author("re:bob|test")' | |
252 | 0 |
|
252 | 0 | |
253 | 1 |
|
253 | 1 | |
254 | 2 |
|
254 | 2 | |
255 | 3 |
|
255 | 3 | |
256 | 4 |
|
256 | 4 | |
257 | 5 |
|
257 | 5 | |
258 | 6 |
|
258 | 6 | |
259 | 7 |
|
259 | 7 | |
260 | 8 |
|
260 | 8 | |
261 | 9 |
|
261 | 9 | |
262 | $ log 'branch(Γ©)' |
|
262 | $ log 'branch(Γ©)' | |
263 | 8 |
|
263 | 8 | |
264 | 9 |
|
264 | 9 | |
265 | $ log 'branch(a)' |
|
265 | $ log 'branch(a)' | |
266 | 0 |
|
266 | 0 | |
267 | $ hg log -r 'branch("re:a")' --template '{rev} {branch}\n' |
|
267 | $ hg log -r 'branch("re:a")' --template '{rev} {branch}\n' | |
268 | 0 a |
|
268 | 0 a | |
269 | 2 a-b-c- |
|
269 | 2 a-b-c- | |
270 | 3 +a+b+c+ |
|
270 | 3 +a+b+c+ | |
271 | 4 -a-b-c- |
|
271 | 4 -a-b-c- | |
272 | 5 !a/b/c/ |
|
272 | 5 !a/b/c/ | |
273 | 6 _a_b_c_ |
|
273 | 6 _a_b_c_ | |
274 | 7 .a.b.c. |
|
274 | 7 .a.b.c. | |
275 | $ log 'children(ancestor(4,5))' |
|
275 | $ log 'children(ancestor(4,5))' | |
276 | 2 |
|
276 | 2 | |
277 | 3 |
|
277 | 3 | |
278 | $ log 'closed()' |
|
278 | $ log 'closed()' | |
279 | $ log 'contains(a)' |
|
279 | $ log 'contains(a)' | |
280 | 0 |
|
280 | 0 | |
281 | 1 |
|
281 | 1 | |
282 | 3 |
|
282 | 3 | |
283 | 5 |
|
283 | 5 | |
284 | $ log 'contains("../repo/a")' |
|
284 | $ log 'contains("../repo/a")' | |
285 | 0 |
|
285 | 0 | |
286 | 1 |
|
286 | 1 | |
287 | 3 |
|
287 | 3 | |
288 | 5 |
|
288 | 5 | |
289 | $ log 'desc(B)' |
|
289 | $ log 'desc(B)' | |
290 | 5 |
|
290 | 5 | |
291 | $ log 'descendants(2 or 3)' |
|
291 | $ log 'descendants(2 or 3)' | |
292 | 2 |
|
292 | 2 | |
293 | 3 |
|
293 | 3 | |
294 | 4 |
|
294 | 4 | |
295 | 5 |
|
295 | 5 | |
296 | 6 |
|
296 | 6 | |
297 | 7 |
|
297 | 7 | |
298 | 8 |
|
298 | 8 | |
299 | 9 |
|
299 | 9 | |
300 | $ log 'file("b*")' |
|
300 | $ log 'file("b*")' | |
301 | 1 |
|
301 | 1 | |
302 | 4 |
|
302 | 4 | |
303 | $ log 'filelog("b")' |
|
303 | $ log 'filelog("b")' | |
304 | 1 |
|
304 | 1 | |
305 | 4 |
|
305 | 4 | |
306 | $ log 'filelog("../repo/b")' |
|
306 | $ log 'filelog("../repo/b")' | |
307 | 1 |
|
307 | 1 | |
308 | 4 |
|
308 | 4 | |
309 | $ log 'follow()' |
|
309 | $ log 'follow()' | |
310 | 0 |
|
310 | 0 | |
311 | 1 |
|
311 | 1 | |
312 | 2 |
|
312 | 2 | |
313 | 4 |
|
313 | 4 | |
314 | 8 |
|
314 | 8 | |
315 | 9 |
|
315 | 9 | |
316 | $ log 'grep("issue\d+")' |
|
316 | $ log 'grep("issue\d+")' | |
317 | 6 |
|
317 | 6 | |
318 | $ try 'grep("(")' # invalid regular expression |
|
318 | $ try 'grep("(")' # invalid regular expression | |
319 | (func |
|
319 | (func | |
320 | ('symbol', 'grep') |
|
320 | ('symbol', 'grep') | |
321 | ('string', '(')) |
|
321 | ('string', '(')) | |
322 | hg: parse error: invalid match pattern: unbalanced parenthesis |
|
322 | hg: parse error: invalid match pattern: unbalanced parenthesis | |
323 | [255] |
|
323 | [255] | |
324 | $ try 'grep("\bissue\d+")' |
|
324 | $ try 'grep("\bissue\d+")' | |
325 | (func |
|
325 | (func | |
326 | ('symbol', 'grep') |
|
326 | ('symbol', 'grep') | |
327 | ('string', '\x08issue\\d+')) |
|
327 | ('string', '\x08issue\\d+')) | |
328 | $ try 'grep(r"\bissue\d+")' |
|
328 | $ try 'grep(r"\bissue\d+")' | |
329 | (func |
|
329 | (func | |
330 | ('symbol', 'grep') |
|
330 | ('symbol', 'grep') | |
331 | ('string', '\\bissue\\d+')) |
|
331 | ('string', '\\bissue\\d+')) | |
332 | 6 |
|
332 | 6 | |
333 | $ try 'grep(r"\")' |
|
333 | $ try 'grep(r"\")' | |
334 | hg: parse error at 7: unterminated string |
|
334 | hg: parse error at 7: unterminated string | |
335 | [255] |
|
335 | [255] | |
336 | $ log 'head()' |
|
336 | $ log 'head()' | |
337 | 0 |
|
337 | 0 | |
338 | 1 |
|
338 | 1 | |
339 | 2 |
|
339 | 2 | |
340 | 3 |
|
340 | 3 | |
341 | 4 |
|
341 | 4 | |
342 | 5 |
|
342 | 5 | |
343 | 6 |
|
343 | 6 | |
344 | 7 |
|
344 | 7 | |
345 | 9 |
|
345 | 9 | |
346 | $ log 'heads(6::)' |
|
346 | $ log 'heads(6::)' | |
347 | 7 |
|
347 | 7 | |
348 | $ log 'keyword(issue)' |
|
348 | $ log 'keyword(issue)' | |
349 | 6 |
|
349 | 6 | |
350 | $ log 'keyword("test a")' |
|
350 | $ log 'keyword("test a")' | |
351 | $ log 'limit(head(), 1)' |
|
351 | $ log 'limit(head(), 1)' | |
352 | 0 |
|
352 | 0 | |
353 | $ log 'matching(6)' |
|
353 | $ log 'matching(6)' | |
354 | 6 |
|
354 | 6 | |
355 | $ log 'matching(6:7, "phase parents user date branch summary files description substate")' |
|
355 | $ log 'matching(6:7, "phase parents user date branch summary files description substate")' | |
356 | 6 |
|
356 | 6 | |
357 | 7 |
|
357 | 7 | |
358 |
|
358 | |||
359 | Testing min and max |
|
359 | Testing min and max | |
360 |
|
360 | |||
361 | max: simple |
|
361 | max: simple | |
362 |
|
362 | |||
363 | $ log 'max(contains(a))' |
|
363 | $ log 'max(contains(a))' | |
364 | 5 |
|
364 | 5 | |
365 |
|
365 | |||
366 | max: simple on unordered set) |
|
366 | max: simple on unordered set) | |
367 |
|
367 | |||
368 | $ log 'max((4+0+2+5+7) and contains(a))' |
|
368 | $ log 'max((4+0+2+5+7) and contains(a))' | |
369 | 5 |
|
369 | 5 | |
370 |
|
370 | |||
371 | max: no result |
|
371 | max: no result | |
372 |
|
372 | |||
373 | $ log 'max(contains(stringthatdoesnotappearanywhere))' |
|
373 | $ log 'max(contains(stringthatdoesnotappearanywhere))' | |
374 |
|
374 | |||
375 | max: no result on unordered set |
|
375 | max: no result on unordered set | |
376 |
|
376 | |||
377 | $ log 'max((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))' |
|
377 | $ log 'max((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))' | |
378 |
|
378 | |||
379 | min: simple |
|
379 | min: simple | |
380 |
|
380 | |||
381 | $ log 'min(contains(a))' |
|
381 | $ log 'min(contains(a))' | |
382 | 0 |
|
382 | 0 | |
383 |
|
383 | |||
384 | min: simple on unordered set |
|
384 | min: simple on unordered set | |
385 |
|
385 | |||
386 | $ log 'min((4+0+2+5+7) and contains(a))' |
|
386 | $ log 'min((4+0+2+5+7) and contains(a))' | |
387 | 0 |
|
387 | 0 | |
388 |
|
388 | |||
389 | min: empty |
|
389 | min: empty | |
390 |
|
390 | |||
391 | $ log 'min(contains(stringthatdoesnotappearanywhere))' |
|
391 | $ log 'min(contains(stringthatdoesnotappearanywhere))' | |
392 |
|
392 | |||
393 | min: empty on unordered set |
|
393 | min: empty on unordered set | |
394 |
|
394 | |||
395 | $ log 'min((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))' |
|
395 | $ log 'min((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))' | |
396 |
|
396 | |||
397 |
|
397 | |||
398 | $ log 'merge()' |
|
398 | $ log 'merge()' | |
399 | 6 |
|
399 | 6 | |
400 | $ log 'branchpoint()' |
|
400 | $ log 'branchpoint()' | |
401 | 1 |
|
401 | 1 | |
402 | 4 |
|
402 | 4 | |
403 | $ log 'modifies(b)' |
|
403 | $ log 'modifies(b)' | |
404 | 4 |
|
404 | 4 | |
405 | $ log 'modifies("path:b")' |
|
405 | $ log 'modifies("path:b")' | |
406 | 4 |
|
406 | 4 | |
407 | $ log 'modifies("*")' |
|
407 | $ log 'modifies("*")' | |
408 | 4 |
|
408 | 4 | |
409 | 6 |
|
409 | 6 | |
410 | $ log 'modifies("set:modified()")' |
|
410 | $ log 'modifies("set:modified()")' | |
411 | 4 |
|
411 | 4 | |
412 | $ log 'id(5)' |
|
412 | $ log 'id(5)' | |
413 | 2 |
|
413 | 2 | |
414 | $ log 'only(9)' |
|
414 | $ log 'only(9)' | |
415 | 8 |
|
415 | 8 | |
416 | 9 |
|
416 | 9 | |
417 | $ log 'only(8)' |
|
417 | $ log 'only(8)' | |
418 | 8 |
|
418 | 8 | |
419 | $ log 'only(9, 5)' |
|
419 | $ log 'only(9, 5)' | |
420 | 2 |
|
420 | 2 | |
421 | 4 |
|
421 | 4 | |
422 | 8 |
|
422 | 8 | |
423 | 9 |
|
423 | 9 | |
424 | $ log 'only(7 + 9, 5 + 2)' |
|
424 | $ log 'only(7 + 9, 5 + 2)' | |
425 | 4 |
|
425 | 4 | |
426 | 6 |
|
426 | 6 | |
427 | 7 |
|
427 | 7 | |
428 | 8 |
|
428 | 8 | |
429 | 9 |
|
429 | 9 | |
430 |
|
430 | |||
431 | Test empty set input |
|
431 | Test empty set input | |
432 | $ log 'only(p2())' |
|
432 | $ log 'only(p2())' | |
433 | $ log 'only(p1(), p2())' |
|
433 | $ log 'only(p1(), p2())' | |
434 | 0 |
|
434 | 0 | |
435 | 1 |
|
435 | 1 | |
436 | 2 |
|
436 | 2 | |
437 | 4 |
|
437 | 4 | |
438 | 8 |
|
438 | 8 | |
439 | 9 |
|
439 | 9 | |
|
440 | ||||
|
441 | Test explicit numeric revision | |||
|
442 | $ log 'rev(-1)' | |||
|
443 | $ log 'rev(0)' | |||
|
444 | 0 | |||
|
445 | $ log 'rev(9)' | |||
|
446 | 9 | |||
|
447 | $ log 'rev(10)' | |||
|
448 | $ log 'rev(tip)' | |||
|
449 | hg: parse error: rev expects a number | |||
|
450 | [255] | |||
|
451 | ||||
440 | $ log 'outgoing()' |
|
452 | $ log 'outgoing()' | |
441 | 8 |
|
453 | 8 | |
442 | 9 |
|
454 | 9 | |
443 | $ log 'outgoing("../remote1")' |
|
455 | $ log 'outgoing("../remote1")' | |
444 | 8 |
|
456 | 8 | |
445 | 9 |
|
457 | 9 | |
446 | $ log 'outgoing("../remote2")' |
|
458 | $ log 'outgoing("../remote2")' | |
447 | 3 |
|
459 | 3 | |
448 | 5 |
|
460 | 5 | |
449 | 6 |
|
461 | 6 | |
450 | 7 |
|
462 | 7 | |
451 | 9 |
|
463 | 9 | |
452 | $ log 'p1(merge())' |
|
464 | $ log 'p1(merge())' | |
453 | 5 |
|
465 | 5 | |
454 | $ log 'p2(merge())' |
|
466 | $ log 'p2(merge())' | |
455 | 4 |
|
467 | 4 | |
456 | $ log 'parents(merge())' |
|
468 | $ log 'parents(merge())' | |
457 | 4 |
|
469 | 4 | |
458 | 5 |
|
470 | 5 | |
459 | $ log 'p1(branchpoint())' |
|
471 | $ log 'p1(branchpoint())' | |
460 | 0 |
|
472 | 0 | |
461 | 2 |
|
473 | 2 | |
462 | $ log 'p2(branchpoint())' |
|
474 | $ log 'p2(branchpoint())' | |
463 | $ log 'parents(branchpoint())' |
|
475 | $ log 'parents(branchpoint())' | |
464 | 0 |
|
476 | 0 | |
465 | 2 |
|
477 | 2 | |
466 | $ log 'removes(a)' |
|
478 | $ log 'removes(a)' | |
467 | 2 |
|
479 | 2 | |
468 | 6 |
|
480 | 6 | |
469 | $ log 'roots(all())' |
|
481 | $ log 'roots(all())' | |
470 | 0 |
|
482 | 0 | |
471 | $ log 'reverse(2 or 3 or 4 or 5)' |
|
483 | $ log 'reverse(2 or 3 or 4 or 5)' | |
472 | 5 |
|
484 | 5 | |
473 | 4 |
|
485 | 4 | |
474 | 3 |
|
486 | 3 | |
475 | 2 |
|
487 | 2 | |
476 | $ log 'reverse(all())' |
|
488 | $ log 'reverse(all())' | |
477 | 9 |
|
489 | 9 | |
478 | 8 |
|
490 | 8 | |
479 | 7 |
|
491 | 7 | |
480 | 6 |
|
492 | 6 | |
481 | 5 |
|
493 | 5 | |
482 | 4 |
|
494 | 4 | |
483 | 3 |
|
495 | 3 | |
484 | 2 |
|
496 | 2 | |
485 | 1 |
|
497 | 1 | |
486 | 0 |
|
498 | 0 | |
487 | $ log 'rev(5)' |
|
499 | $ log 'rev(5)' | |
488 | 5 |
|
500 | 5 | |
489 | $ log 'sort(limit(reverse(all()), 3))' |
|
501 | $ log 'sort(limit(reverse(all()), 3))' | |
490 | 7 |
|
502 | 7 | |
491 | 8 |
|
503 | 8 | |
492 | 9 |
|
504 | 9 | |
493 | $ log 'sort(2 or 3 or 4 or 5, date)' |
|
505 | $ log 'sort(2 or 3 or 4 or 5, date)' | |
494 | 2 |
|
506 | 2 | |
495 | 3 |
|
507 | 3 | |
496 | 5 |
|
508 | 5 | |
497 | 4 |
|
509 | 4 | |
498 | $ log 'tagged()' |
|
510 | $ log 'tagged()' | |
499 | 6 |
|
511 | 6 | |
500 | $ log 'tag()' |
|
512 | $ log 'tag()' | |
501 | 6 |
|
513 | 6 | |
502 | $ log 'tag(1.0)' |
|
514 | $ log 'tag(1.0)' | |
503 | 6 |
|
515 | 6 | |
504 | $ log 'tag(tip)' |
|
516 | $ log 'tag(tip)' | |
505 | 9 |
|
517 | 9 | |
506 |
|
518 | |||
507 | test sort revset |
|
519 | test sort revset | |
508 | -------------------------------------------- |
|
520 | -------------------------------------------- | |
509 |
|
521 | |||
510 | test when adding two unordered revsets |
|
522 | test when adding two unordered revsets | |
511 |
|
523 | |||
512 | $ log 'sort(keyword(issue) or modifies(b))' |
|
524 | $ log 'sort(keyword(issue) or modifies(b))' | |
513 | 4 |
|
525 | 4 | |
514 | 6 |
|
526 | 6 | |
515 |
|
527 | |||
516 | test when sorting a reversed collection in the same way it is |
|
528 | test when sorting a reversed collection in the same way it is | |
517 |
|
529 | |||
518 | $ log 'sort(reverse(all()), -rev)' |
|
530 | $ log 'sort(reverse(all()), -rev)' | |
519 | 9 |
|
531 | 9 | |
520 | 8 |
|
532 | 8 | |
521 | 7 |
|
533 | 7 | |
522 | 6 |
|
534 | 6 | |
523 | 5 |
|
535 | 5 | |
524 | 4 |
|
536 | 4 | |
525 | 3 |
|
537 | 3 | |
526 | 2 |
|
538 | 2 | |
527 | 1 |
|
539 | 1 | |
528 | 0 |
|
540 | 0 | |
529 |
|
541 | |||
530 | test when sorting a reversed collection |
|
542 | test when sorting a reversed collection | |
531 |
|
543 | |||
532 | $ log 'sort(reverse(all()), rev)' |
|
544 | $ log 'sort(reverse(all()), rev)' | |
533 | 0 |
|
545 | 0 | |
534 | 1 |
|
546 | 1 | |
535 | 2 |
|
547 | 2 | |
536 | 3 |
|
548 | 3 | |
537 | 4 |
|
549 | 4 | |
538 | 5 |
|
550 | 5 | |
539 | 6 |
|
551 | 6 | |
540 | 7 |
|
552 | 7 | |
541 | 8 |
|
553 | 8 | |
542 | 9 |
|
554 | 9 | |
543 |
|
555 | |||
544 |
|
556 | |||
545 | test sorting two sorted collections in different orders |
|
557 | test sorting two sorted collections in different orders | |
546 |
|
558 | |||
547 | $ log 'sort(outgoing() or reverse(removes(a)), rev)' |
|
559 | $ log 'sort(outgoing() or reverse(removes(a)), rev)' | |
548 | 2 |
|
560 | 2 | |
549 | 6 |
|
561 | 6 | |
550 | 8 |
|
562 | 8 | |
551 | 9 |
|
563 | 9 | |
552 |
|
564 | |||
553 | test sorting two sorted collections in different orders backwards |
|
565 | test sorting two sorted collections in different orders backwards | |
554 |
|
566 | |||
555 | $ log 'sort(outgoing() or reverse(removes(a)), -rev)' |
|
567 | $ log 'sort(outgoing() or reverse(removes(a)), -rev)' | |
556 | 9 |
|
568 | 9 | |
557 | 8 |
|
569 | 8 | |
558 | 6 |
|
570 | 6 | |
559 | 2 |
|
571 | 2 | |
560 |
|
572 | |||
561 | test subtracting something from an addset |
|
573 | test subtracting something from an addset | |
562 |
|
574 | |||
563 | $ log '(outgoing() or removes(a)) - removes(a)' |
|
575 | $ log '(outgoing() or removes(a)) - removes(a)' | |
564 | 8 |
|
576 | 8 | |
565 | 9 |
|
577 | 9 | |
566 |
|
578 | |||
567 | test intersecting something with an addset |
|
579 | test intersecting something with an addset | |
568 |
|
580 | |||
569 | $ log 'parents(outgoing() or removes(a))' |
|
581 | $ log 'parents(outgoing() or removes(a))' | |
570 | 1 |
|
582 | 1 | |
571 | 4 |
|
583 | 4 | |
572 | 5 |
|
584 | 5 | |
573 | 8 |
|
585 | 8 | |
574 |
|
586 | |||
575 | test that `or` operation combines elements in the right order: |
|
587 | test that `or` operation combines elements in the right order: | |
576 |
|
588 | |||
577 | $ log '3:4 or 2:5' |
|
589 | $ log '3:4 or 2:5' | |
578 | 3 |
|
590 | 3 | |
579 | 4 |
|
591 | 4 | |
580 | 2 |
|
592 | 2 | |
581 | 5 |
|
593 | 5 | |
582 | $ log '3:4 or 5:2' |
|
594 | $ log '3:4 or 5:2' | |
583 | 3 |
|
595 | 3 | |
584 | 4 |
|
596 | 4 | |
585 | 5 |
|
597 | 5 | |
586 | 2 |
|
598 | 2 | |
587 | $ log 'sort(3:4 or 2:5)' |
|
599 | $ log 'sort(3:4 or 2:5)' | |
588 | 2 |
|
600 | 2 | |
589 | 3 |
|
601 | 3 | |
590 | 4 |
|
602 | 4 | |
591 | 5 |
|
603 | 5 | |
592 | $ log 'sort(3:4 or 5:2)' |
|
604 | $ log 'sort(3:4 or 5:2)' | |
593 | 2 |
|
605 | 2 | |
594 | 3 |
|
606 | 3 | |
595 | 4 |
|
607 | 4 | |
596 | 5 |
|
608 | 5 | |
597 |
|
609 | |||
598 | check that conversion to only works |
|
610 | check that conversion to only works | |
599 | $ try --optimize '::3 - ::1' |
|
611 | $ try --optimize '::3 - ::1' | |
600 | (minus |
|
612 | (minus | |
601 | (dagrangepre |
|
613 | (dagrangepre | |
602 | ('symbol', '3')) |
|
614 | ('symbol', '3')) | |
603 | (dagrangepre |
|
615 | (dagrangepre | |
604 | ('symbol', '1'))) |
|
616 | ('symbol', '1'))) | |
605 | * optimized: |
|
617 | * optimized: | |
606 | (func |
|
618 | (func | |
607 | ('symbol', 'only') |
|
619 | ('symbol', 'only') | |
608 | (list |
|
620 | (list | |
609 | ('symbol', '3') |
|
621 | ('symbol', '3') | |
610 | ('symbol', '1'))) |
|
622 | ('symbol', '1'))) | |
611 | 3 |
|
623 | 3 | |
612 | $ try --optimize 'ancestors(1) - ancestors(3)' |
|
624 | $ try --optimize 'ancestors(1) - ancestors(3)' | |
613 | (minus |
|
625 | (minus | |
614 | (func |
|
626 | (func | |
615 | ('symbol', 'ancestors') |
|
627 | ('symbol', 'ancestors') | |
616 | ('symbol', '1')) |
|
628 | ('symbol', '1')) | |
617 | (func |
|
629 | (func | |
618 | ('symbol', 'ancestors') |
|
630 | ('symbol', 'ancestors') | |
619 | ('symbol', '3'))) |
|
631 | ('symbol', '3'))) | |
620 | * optimized: |
|
632 | * optimized: | |
621 | (func |
|
633 | (func | |
622 | ('symbol', 'only') |
|
634 | ('symbol', 'only') | |
623 | (list |
|
635 | (list | |
624 | ('symbol', '1') |
|
636 | ('symbol', '1') | |
625 | ('symbol', '3'))) |
|
637 | ('symbol', '3'))) | |
626 | $ try --optimize 'not ::2 and ::6' |
|
638 | $ try --optimize 'not ::2 and ::6' | |
627 | (and |
|
639 | (and | |
628 | (not |
|
640 | (not | |
629 | (dagrangepre |
|
641 | (dagrangepre | |
630 | ('symbol', '2'))) |
|
642 | ('symbol', '2'))) | |
631 | (dagrangepre |
|
643 | (dagrangepre | |
632 | ('symbol', '6'))) |
|
644 | ('symbol', '6'))) | |
633 | * optimized: |
|
645 | * optimized: | |
634 | (func |
|
646 | (func | |
635 | ('symbol', 'only') |
|
647 | ('symbol', 'only') | |
636 | (list |
|
648 | (list | |
637 | ('symbol', '6') |
|
649 | ('symbol', '6') | |
638 | ('symbol', '2'))) |
|
650 | ('symbol', '2'))) | |
639 | 3 |
|
651 | 3 | |
640 | 4 |
|
652 | 4 | |
641 | 5 |
|
653 | 5 | |
642 | 6 |
|
654 | 6 | |
643 | $ try --optimize 'ancestors(6) and not ancestors(4)' |
|
655 | $ try --optimize 'ancestors(6) and not ancestors(4)' | |
644 | (and |
|
656 | (and | |
645 | (func |
|
657 | (func | |
646 | ('symbol', 'ancestors') |
|
658 | ('symbol', 'ancestors') | |
647 | ('symbol', '6')) |
|
659 | ('symbol', '6')) | |
648 | (not |
|
660 | (not | |
649 | (func |
|
661 | (func | |
650 | ('symbol', 'ancestors') |
|
662 | ('symbol', 'ancestors') | |
651 | ('symbol', '4')))) |
|
663 | ('symbol', '4')))) | |
652 | * optimized: |
|
664 | * optimized: | |
653 | (func |
|
665 | (func | |
654 | ('symbol', 'only') |
|
666 | ('symbol', 'only') | |
655 | (list |
|
667 | (list | |
656 | ('symbol', '6') |
|
668 | ('symbol', '6') | |
657 | ('symbol', '4'))) |
|
669 | ('symbol', '4'))) | |
658 | 3 |
|
670 | 3 | |
659 | 5 |
|
671 | 5 | |
660 | 6 |
|
672 | 6 | |
661 |
|
673 | |||
662 | we can use patterns when searching for tags |
|
674 | we can use patterns when searching for tags | |
663 |
|
675 | |||
664 | $ log 'tag("1..*")' |
|
676 | $ log 'tag("1..*")' | |
665 | abort: tag '1..*' does not exist |
|
677 | abort: tag '1..*' does not exist | |
666 | [255] |
|
678 | [255] | |
667 | $ log 'tag("re:1..*")' |
|
679 | $ log 'tag("re:1..*")' | |
668 | 6 |
|
680 | 6 | |
669 | $ log 'tag("re:[0-9].[0-9]")' |
|
681 | $ log 'tag("re:[0-9].[0-9]")' | |
670 | 6 |
|
682 | 6 | |
671 | $ log 'tag("literal:1.0")' |
|
683 | $ log 'tag("literal:1.0")' | |
672 | 6 |
|
684 | 6 | |
673 | $ log 'tag("re:0..*")' |
|
685 | $ log 'tag("re:0..*")' | |
674 |
|
686 | |||
675 | $ log 'tag(unknown)' |
|
687 | $ log 'tag(unknown)' | |
676 | abort: tag 'unknown' does not exist |
|
688 | abort: tag 'unknown' does not exist | |
677 | [255] |
|
689 | [255] | |
678 | $ log 'branch(unknown)' |
|
690 | $ log 'branch(unknown)' | |
679 | abort: unknown revision 'unknown'! |
|
691 | abort: unknown revision 'unknown'! | |
680 | [255] |
|
692 | [255] | |
681 | $ log 'user(bob)' |
|
693 | $ log 'user(bob)' | |
682 | 2 |
|
694 | 2 | |
683 |
|
695 | |||
684 | $ log '4::8' |
|
696 | $ log '4::8' | |
685 | 4 |
|
697 | 4 | |
686 | 8 |
|
698 | 8 | |
687 | $ log '4:8' |
|
699 | $ log '4:8' | |
688 | 4 |
|
700 | 4 | |
689 | 5 |
|
701 | 5 | |
690 | 6 |
|
702 | 6 | |
691 | 7 |
|
703 | 7 | |
692 | 8 |
|
704 | 8 | |
693 |
|
705 | |||
694 | $ log 'sort(!merge() & (modifies(b) | user(bob) | keyword(bug) | keyword(issue) & 1::9), "-date")' |
|
706 | $ log 'sort(!merge() & (modifies(b) | user(bob) | keyword(bug) | keyword(issue) & 1::9), "-date")' | |
695 | 4 |
|
707 | 4 | |
696 | 2 |
|
708 | 2 | |
697 | 5 |
|
709 | 5 | |
698 |
|
710 | |||
699 | $ log 'not 0 and 0:2' |
|
711 | $ log 'not 0 and 0:2' | |
700 | 1 |
|
712 | 1 | |
701 | 2 |
|
713 | 2 | |
702 | $ log 'not 1 and 0:2' |
|
714 | $ log 'not 1 and 0:2' | |
703 | 0 |
|
715 | 0 | |
704 | 2 |
|
716 | 2 | |
705 | $ log 'not 2 and 0:2' |
|
717 | $ log 'not 2 and 0:2' | |
706 | 0 |
|
718 | 0 | |
707 | 1 |
|
719 | 1 | |
708 | $ log '(1 and 2)::' |
|
720 | $ log '(1 and 2)::' | |
709 | $ log '(1 and 2):' |
|
721 | $ log '(1 and 2):' | |
710 | $ log '(1 and 2):3' |
|
722 | $ log '(1 and 2):3' | |
711 | $ log 'sort(head(), -rev)' |
|
723 | $ log 'sort(head(), -rev)' | |
712 | 9 |
|
724 | 9 | |
713 | 7 |
|
725 | 7 | |
714 | 6 |
|
726 | 6 | |
715 | 5 |
|
727 | 5 | |
716 | 4 |
|
728 | 4 | |
717 | 3 |
|
729 | 3 | |
718 | 2 |
|
730 | 2 | |
719 | 1 |
|
731 | 1 | |
720 | 0 |
|
732 | 0 | |
721 | $ log '4::8 - 8' |
|
733 | $ log '4::8 - 8' | |
722 | 4 |
|
734 | 4 | |
723 | $ log 'matching(1 or 2 or 3) and (2 or 3 or 1)' |
|
735 | $ log 'matching(1 or 2 or 3) and (2 or 3 or 1)' | |
724 | 2 |
|
736 | 2 | |
725 | 3 |
|
737 | 3 | |
726 | 1 |
|
738 | 1 | |
727 |
|
739 | |||
728 | issue2437 |
|
740 | issue2437 | |
729 |
|
741 | |||
730 | $ log '3 and p1(5)' |
|
742 | $ log '3 and p1(5)' | |
731 | 3 |
|
743 | 3 | |
732 | $ log '4 and p2(6)' |
|
744 | $ log '4 and p2(6)' | |
733 | 4 |
|
745 | 4 | |
734 | $ log '1 and parents(:2)' |
|
746 | $ log '1 and parents(:2)' | |
735 | 1 |
|
747 | 1 | |
736 | $ log '2 and children(1:)' |
|
748 | $ log '2 and children(1:)' | |
737 | 2 |
|
749 | 2 | |
738 | $ log 'roots(all()) or roots(all())' |
|
750 | $ log 'roots(all()) or roots(all())' | |
739 | 0 |
|
751 | 0 | |
740 | $ hg debugrevspec 'roots(all()) or roots(all())' |
|
752 | $ hg debugrevspec 'roots(all()) or roots(all())' | |
741 | 0 |
|
753 | 0 | |
742 | $ log 'heads(branch(Γ©)) or heads(branch(Γ©))' |
|
754 | $ log 'heads(branch(Γ©)) or heads(branch(Γ©))' | |
743 | 9 |
|
755 | 9 | |
744 | $ log 'ancestors(8) and (heads(branch("-a-b-c-")) or heads(branch(Γ©)))' |
|
756 | $ log 'ancestors(8) and (heads(branch("-a-b-c-")) or heads(branch(Γ©)))' | |
745 | 4 |
|
757 | 4 | |
746 |
|
758 | |||
747 | issue2654: report a parse error if the revset was not completely parsed |
|
759 | issue2654: report a parse error if the revset was not completely parsed | |
748 |
|
760 | |||
749 | $ log '1 OR 2' |
|
761 | $ log '1 OR 2' | |
750 | hg: parse error at 2: invalid token |
|
762 | hg: parse error at 2: invalid token | |
751 | [255] |
|
763 | [255] | |
752 |
|
764 | |||
753 | or operator should preserve ordering: |
|
765 | or operator should preserve ordering: | |
754 | $ log 'reverse(2::4) or tip' |
|
766 | $ log 'reverse(2::4) or tip' | |
755 | 4 |
|
767 | 4 | |
756 | 2 |
|
768 | 2 | |
757 | 9 |
|
769 | 9 | |
758 |
|
770 | |||
759 | parentrevspec |
|
771 | parentrevspec | |
760 |
|
772 | |||
761 | $ log 'merge()^0' |
|
773 | $ log 'merge()^0' | |
762 | 6 |
|
774 | 6 | |
763 | $ log 'merge()^' |
|
775 | $ log 'merge()^' | |
764 | 5 |
|
776 | 5 | |
765 | $ log 'merge()^1' |
|
777 | $ log 'merge()^1' | |
766 | 5 |
|
778 | 5 | |
767 | $ log 'merge()^2' |
|
779 | $ log 'merge()^2' | |
768 | 4 |
|
780 | 4 | |
769 | $ log 'merge()^^' |
|
781 | $ log 'merge()^^' | |
770 | 3 |
|
782 | 3 | |
771 | $ log 'merge()^1^' |
|
783 | $ log 'merge()^1^' | |
772 | 3 |
|
784 | 3 | |
773 | $ log 'merge()^^^' |
|
785 | $ log 'merge()^^^' | |
774 | 1 |
|
786 | 1 | |
775 |
|
787 | |||
776 | $ log 'merge()~0' |
|
788 | $ log 'merge()~0' | |
777 | 6 |
|
789 | 6 | |
778 | $ log 'merge()~1' |
|
790 | $ log 'merge()~1' | |
779 | 5 |
|
791 | 5 | |
780 | $ log 'merge()~2' |
|
792 | $ log 'merge()~2' | |
781 | 3 |
|
793 | 3 | |
782 | $ log 'merge()~2^1' |
|
794 | $ log 'merge()~2^1' | |
783 | 1 |
|
795 | 1 | |
784 | $ log 'merge()~3' |
|
796 | $ log 'merge()~3' | |
785 | 1 |
|
797 | 1 | |
786 |
|
798 | |||
787 | $ log '(-3:tip)^' |
|
799 | $ log '(-3:tip)^' | |
788 | 4 |
|
800 | 4 | |
789 | 6 |
|
801 | 6 | |
790 | 8 |
|
802 | 8 | |
791 |
|
803 | |||
792 | $ log 'tip^foo' |
|
804 | $ log 'tip^foo' | |
793 | hg: parse error: ^ expects a number 0, 1, or 2 |
|
805 | hg: parse error: ^ expects a number 0, 1, or 2 | |
794 | [255] |
|
806 | [255] | |
795 |
|
807 | |||
796 | multiple revspecs |
|
808 | multiple revspecs | |
797 |
|
809 | |||
798 | $ hg log -r 'tip~1:tip' -r 'tip~2:tip~1' --template '{rev}\n' |
|
810 | $ hg log -r 'tip~1:tip' -r 'tip~2:tip~1' --template '{rev}\n' | |
799 | 8 |
|
811 | 8 | |
800 | 9 |
|
812 | 9 | |
801 | 4 |
|
813 | 4 | |
802 | 5 |
|
814 | 5 | |
803 | 6 |
|
815 | 6 | |
804 | 7 |
|
816 | 7 | |
805 |
|
817 | |||
806 | test usage in revpair (with "+") |
|
818 | test usage in revpair (with "+") | |
807 |
|
819 | |||
808 | (real pair) |
|
820 | (real pair) | |
809 |
|
821 | |||
810 | $ hg diff -r 'tip^^' -r 'tip' |
|
822 | $ hg diff -r 'tip^^' -r 'tip' | |
811 | diff -r 2326846efdab -r 24286f4ae135 .hgtags |
|
823 | diff -r 2326846efdab -r 24286f4ae135 .hgtags | |
812 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
824 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
813 | +++ b/.hgtags Thu Jan 01 00:00:00 1970 +0000 |
|
825 | +++ b/.hgtags Thu Jan 01 00:00:00 1970 +0000 | |
814 | @@ -0,0 +1,1 @@ |
|
826 | @@ -0,0 +1,1 @@ | |
815 | +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0 |
|
827 | +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0 | |
816 | $ hg diff -r 'tip^^::tip' |
|
828 | $ hg diff -r 'tip^^::tip' | |
817 | diff -r 2326846efdab -r 24286f4ae135 .hgtags |
|
829 | diff -r 2326846efdab -r 24286f4ae135 .hgtags | |
818 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
830 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
819 | +++ b/.hgtags Thu Jan 01 00:00:00 1970 +0000 |
|
831 | +++ b/.hgtags Thu Jan 01 00:00:00 1970 +0000 | |
820 | @@ -0,0 +1,1 @@ |
|
832 | @@ -0,0 +1,1 @@ | |
821 | +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0 |
|
833 | +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0 | |
822 |
|
834 | |||
823 | (single rev) |
|
835 | (single rev) | |
824 |
|
836 | |||
825 | $ hg diff -r 'tip^' -r 'tip^' |
|
837 | $ hg diff -r 'tip^' -r 'tip^' | |
826 | $ hg diff -r 'tip^::tip^ or tip^' |
|
838 | $ hg diff -r 'tip^::tip^ or tip^' | |
827 |
|
839 | |||
828 | (single rev that does not looks like a range) |
|
840 | (single rev that does not looks like a range) | |
829 |
|
841 | |||
830 | $ hg diff -r 'tip^ or tip^' |
|
842 | $ hg diff -r 'tip^ or tip^' | |
831 | diff -r d5d0dcbdc4d9 .hgtags |
|
843 | diff -r d5d0dcbdc4d9 .hgtags | |
832 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
844 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
833 | +++ b/.hgtags * (glob) |
|
845 | +++ b/.hgtags * (glob) | |
834 | @@ -0,0 +1,1 @@ |
|
846 | @@ -0,0 +1,1 @@ | |
835 | +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0 |
|
847 | +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0 | |
836 |
|
848 | |||
837 | (no rev) |
|
849 | (no rev) | |
838 |
|
850 | |||
839 | $ hg diff -r 'author("babar") or author("celeste")' |
|
851 | $ hg diff -r 'author("babar") or author("celeste")' | |
840 | abort: empty revision range |
|
852 | abort: empty revision range | |
841 | [255] |
|
853 | [255] | |
842 |
|
854 | |||
843 | aliases: |
|
855 | aliases: | |
844 |
|
856 | |||
845 | $ echo '[revsetalias]' >> .hg/hgrc |
|
857 | $ echo '[revsetalias]' >> .hg/hgrc | |
846 | $ echo 'm = merge()' >> .hg/hgrc |
|
858 | $ echo 'm = merge()' >> .hg/hgrc | |
847 | $ echo 'sincem = descendants(m)' >> .hg/hgrc |
|
859 | $ echo 'sincem = descendants(m)' >> .hg/hgrc | |
848 | $ echo 'd($1) = reverse(sort($1, date))' >> .hg/hgrc |
|
860 | $ echo 'd($1) = reverse(sort($1, date))' >> .hg/hgrc | |
849 | $ echo 'rs(ARG1, ARG2) = reverse(sort(ARG1, ARG2))' >> .hg/hgrc |
|
861 | $ echo 'rs(ARG1, ARG2) = reverse(sort(ARG1, ARG2))' >> .hg/hgrc | |
850 | $ echo 'rs4(ARG1, ARGA, ARGB, ARG2) = reverse(sort(ARG1, ARG2))' >> .hg/hgrc |
|
862 | $ echo 'rs4(ARG1, ARGA, ARGB, ARG2) = reverse(sort(ARG1, ARG2))' >> .hg/hgrc | |
851 |
|
863 | |||
852 | $ try m |
|
864 | $ try m | |
853 | ('symbol', 'm') |
|
865 | ('symbol', 'm') | |
854 | (func |
|
866 | (func | |
855 | ('symbol', 'merge') |
|
867 | ('symbol', 'merge') | |
856 | None) |
|
868 | None) | |
857 | 6 |
|
869 | 6 | |
858 |
|
870 | |||
859 | test alias recursion |
|
871 | test alias recursion | |
860 |
|
872 | |||
861 | $ try sincem |
|
873 | $ try sincem | |
862 | ('symbol', 'sincem') |
|
874 | ('symbol', 'sincem') | |
863 | (func |
|
875 | (func | |
864 | ('symbol', 'descendants') |
|
876 | ('symbol', 'descendants') | |
865 | (func |
|
877 | (func | |
866 | ('symbol', 'merge') |
|
878 | ('symbol', 'merge') | |
867 | None)) |
|
879 | None)) | |
868 | 6 |
|
880 | 6 | |
869 | 7 |
|
881 | 7 | |
870 |
|
882 | |||
871 | test infinite recursion |
|
883 | test infinite recursion | |
872 |
|
884 | |||
873 | $ echo 'recurse1 = recurse2' >> .hg/hgrc |
|
885 | $ echo 'recurse1 = recurse2' >> .hg/hgrc | |
874 | $ echo 'recurse2 = recurse1' >> .hg/hgrc |
|
886 | $ echo 'recurse2 = recurse1' >> .hg/hgrc | |
875 | $ try recurse1 |
|
887 | $ try recurse1 | |
876 | ('symbol', 'recurse1') |
|
888 | ('symbol', 'recurse1') | |
877 | hg: parse error: infinite expansion of revset alias "recurse1" detected |
|
889 | hg: parse error: infinite expansion of revset alias "recurse1" detected | |
878 | [255] |
|
890 | [255] | |
879 |
|
891 | |||
880 | $ echo 'level1($1, $2) = $1 or $2' >> .hg/hgrc |
|
892 | $ echo 'level1($1, $2) = $1 or $2' >> .hg/hgrc | |
881 | $ echo 'level2($1, $2) = level1($2, $1)' >> .hg/hgrc |
|
893 | $ echo 'level2($1, $2) = level1($2, $1)' >> .hg/hgrc | |
882 | $ try "level2(level1(1, 2), 3)" |
|
894 | $ try "level2(level1(1, 2), 3)" | |
883 | (func |
|
895 | (func | |
884 | ('symbol', 'level2') |
|
896 | ('symbol', 'level2') | |
885 | (list |
|
897 | (list | |
886 | (func |
|
898 | (func | |
887 | ('symbol', 'level1') |
|
899 | ('symbol', 'level1') | |
888 | (list |
|
900 | (list | |
889 | ('symbol', '1') |
|
901 | ('symbol', '1') | |
890 | ('symbol', '2'))) |
|
902 | ('symbol', '2'))) | |
891 | ('symbol', '3'))) |
|
903 | ('symbol', '3'))) | |
892 | (or |
|
904 | (or | |
893 | ('symbol', '3') |
|
905 | ('symbol', '3') | |
894 | (or |
|
906 | (or | |
895 | ('symbol', '1') |
|
907 | ('symbol', '1') | |
896 | ('symbol', '2'))) |
|
908 | ('symbol', '2'))) | |
897 | 3 |
|
909 | 3 | |
898 | 1 |
|
910 | 1 | |
899 | 2 |
|
911 | 2 | |
900 |
|
912 | |||
901 | test nesting and variable passing |
|
913 | test nesting and variable passing | |
902 |
|
914 | |||
903 | $ echo 'nested($1) = nested2($1)' >> .hg/hgrc |
|
915 | $ echo 'nested($1) = nested2($1)' >> .hg/hgrc | |
904 | $ echo 'nested2($1) = nested3($1)' >> .hg/hgrc |
|
916 | $ echo 'nested2($1) = nested3($1)' >> .hg/hgrc | |
905 | $ echo 'nested3($1) = max($1)' >> .hg/hgrc |
|
917 | $ echo 'nested3($1) = max($1)' >> .hg/hgrc | |
906 | $ try 'nested(2:5)' |
|
918 | $ try 'nested(2:5)' | |
907 | (func |
|
919 | (func | |
908 | ('symbol', 'nested') |
|
920 | ('symbol', 'nested') | |
909 | (range |
|
921 | (range | |
910 | ('symbol', '2') |
|
922 | ('symbol', '2') | |
911 | ('symbol', '5'))) |
|
923 | ('symbol', '5'))) | |
912 | (func |
|
924 | (func | |
913 | ('symbol', 'max') |
|
925 | ('symbol', 'max') | |
914 | (range |
|
926 | (range | |
915 | ('symbol', '2') |
|
927 | ('symbol', '2') | |
916 | ('symbol', '5'))) |
|
928 | ('symbol', '5'))) | |
917 | 5 |
|
929 | 5 | |
918 |
|
930 | |||
919 | test variable isolation, variable placeholders are rewritten as string |
|
931 | test variable isolation, variable placeholders are rewritten as string | |
920 | then parsed and matched again as string. Check they do not leak too |
|
932 | then parsed and matched again as string. Check they do not leak too | |
921 | far away. |
|
933 | far away. | |
922 |
|
934 | |||
923 | $ echo 'injectparamasstring = max("$1")' >> .hg/hgrc |
|
935 | $ echo 'injectparamasstring = max("$1")' >> .hg/hgrc | |
924 | $ echo 'callinjection($1) = descendants(injectparamasstring)' >> .hg/hgrc |
|
936 | $ echo 'callinjection($1) = descendants(injectparamasstring)' >> .hg/hgrc | |
925 | $ try 'callinjection(2:5)' |
|
937 | $ try 'callinjection(2:5)' | |
926 | (func |
|
938 | (func | |
927 | ('symbol', 'callinjection') |
|
939 | ('symbol', 'callinjection') | |
928 | (range |
|
940 | (range | |
929 | ('symbol', '2') |
|
941 | ('symbol', '2') | |
930 | ('symbol', '5'))) |
|
942 | ('symbol', '5'))) | |
931 | (func |
|
943 | (func | |
932 | ('symbol', 'descendants') |
|
944 | ('symbol', 'descendants') | |
933 | (func |
|
945 | (func | |
934 | ('symbol', 'max') |
|
946 | ('symbol', 'max') | |
935 | ('string', '$1'))) |
|
947 | ('string', '$1'))) | |
936 | abort: unknown revision '$1'! |
|
948 | abort: unknown revision '$1'! | |
937 | [255] |
|
949 | [255] | |
938 |
|
950 | |||
939 | $ echo 'injectparamasstring2 = max(_aliasarg("$1"))' >> .hg/hgrc |
|
951 | $ echo 'injectparamasstring2 = max(_aliasarg("$1"))' >> .hg/hgrc | |
940 | $ echo 'callinjection2($1) = descendants(injectparamasstring2)' >> .hg/hgrc |
|
952 | $ echo 'callinjection2($1) = descendants(injectparamasstring2)' >> .hg/hgrc | |
941 | $ try 'callinjection2(2:5)' |
|
953 | $ try 'callinjection2(2:5)' | |
942 | (func |
|
954 | (func | |
943 | ('symbol', 'callinjection2') |
|
955 | ('symbol', 'callinjection2') | |
944 | (range |
|
956 | (range | |
945 | ('symbol', '2') |
|
957 | ('symbol', '2') | |
946 | ('symbol', '5'))) |
|
958 | ('symbol', '5'))) | |
947 | hg: parse error: not a function: _aliasarg |
|
959 | hg: parse error: not a function: _aliasarg | |
948 | [255] |
|
960 | [255] | |
949 | >>> data = file('.hg/hgrc', 'rb').read() |
|
961 | >>> data = file('.hg/hgrc', 'rb').read() | |
950 | >>> file('.hg/hgrc', 'wb').write(data.replace('_aliasarg', '')) |
|
962 | >>> file('.hg/hgrc', 'wb').write(data.replace('_aliasarg', '')) | |
951 |
|
963 | |||
952 | $ try 'd(2:5)' |
|
964 | $ try 'd(2:5)' | |
953 | (func |
|
965 | (func | |
954 | ('symbol', 'd') |
|
966 | ('symbol', 'd') | |
955 | (range |
|
967 | (range | |
956 | ('symbol', '2') |
|
968 | ('symbol', '2') | |
957 | ('symbol', '5'))) |
|
969 | ('symbol', '5'))) | |
958 | (func |
|
970 | (func | |
959 | ('symbol', 'reverse') |
|
971 | ('symbol', 'reverse') | |
960 | (func |
|
972 | (func | |
961 | ('symbol', 'sort') |
|
973 | ('symbol', 'sort') | |
962 | (list |
|
974 | (list | |
963 | (range |
|
975 | (range | |
964 | ('symbol', '2') |
|
976 | ('symbol', '2') | |
965 | ('symbol', '5')) |
|
977 | ('symbol', '5')) | |
966 | ('symbol', 'date')))) |
|
978 | ('symbol', 'date')))) | |
967 | 4 |
|
979 | 4 | |
968 | 5 |
|
980 | 5 | |
969 | 3 |
|
981 | 3 | |
970 | 2 |
|
982 | 2 | |
971 | $ try 'rs(2 or 3, date)' |
|
983 | $ try 'rs(2 or 3, date)' | |
972 | (func |
|
984 | (func | |
973 | ('symbol', 'rs') |
|
985 | ('symbol', 'rs') | |
974 | (list |
|
986 | (list | |
975 | (or |
|
987 | (or | |
976 | ('symbol', '2') |
|
988 | ('symbol', '2') | |
977 | ('symbol', '3')) |
|
989 | ('symbol', '3')) | |
978 | ('symbol', 'date'))) |
|
990 | ('symbol', 'date'))) | |
979 | (func |
|
991 | (func | |
980 | ('symbol', 'reverse') |
|
992 | ('symbol', 'reverse') | |
981 | (func |
|
993 | (func | |
982 | ('symbol', 'sort') |
|
994 | ('symbol', 'sort') | |
983 | (list |
|
995 | (list | |
984 | (or |
|
996 | (or | |
985 | ('symbol', '2') |
|
997 | ('symbol', '2') | |
986 | ('symbol', '3')) |
|
998 | ('symbol', '3')) | |
987 | ('symbol', 'date')))) |
|
999 | ('symbol', 'date')))) | |
988 | 3 |
|
1000 | 3 | |
989 | 2 |
|
1001 | 2 | |
990 | $ try 'rs()' |
|
1002 | $ try 'rs()' | |
991 | (func |
|
1003 | (func | |
992 | ('symbol', 'rs') |
|
1004 | ('symbol', 'rs') | |
993 | None) |
|
1005 | None) | |
994 | hg: parse error: invalid number of arguments: 0 |
|
1006 | hg: parse error: invalid number of arguments: 0 | |
995 | [255] |
|
1007 | [255] | |
996 | $ try 'rs(2)' |
|
1008 | $ try 'rs(2)' | |
997 | (func |
|
1009 | (func | |
998 | ('symbol', 'rs') |
|
1010 | ('symbol', 'rs') | |
999 | ('symbol', '2')) |
|
1011 | ('symbol', '2')) | |
1000 | hg: parse error: invalid number of arguments: 1 |
|
1012 | hg: parse error: invalid number of arguments: 1 | |
1001 | [255] |
|
1013 | [255] | |
1002 | $ try 'rs(2, data, 7)' |
|
1014 | $ try 'rs(2, data, 7)' | |
1003 | (func |
|
1015 | (func | |
1004 | ('symbol', 'rs') |
|
1016 | ('symbol', 'rs') | |
1005 | (list |
|
1017 | (list | |
1006 | (list |
|
1018 | (list | |
1007 | ('symbol', '2') |
|
1019 | ('symbol', '2') | |
1008 | ('symbol', 'data')) |
|
1020 | ('symbol', 'data')) | |
1009 | ('symbol', '7'))) |
|
1021 | ('symbol', '7'))) | |
1010 | hg: parse error: invalid number of arguments: 3 |
|
1022 | hg: parse error: invalid number of arguments: 3 | |
1011 | [255] |
|
1023 | [255] | |
1012 | $ try 'rs4(2 or 3, x, x, date)' |
|
1024 | $ try 'rs4(2 or 3, x, x, date)' | |
1013 | (func |
|
1025 | (func | |
1014 | ('symbol', 'rs4') |
|
1026 | ('symbol', 'rs4') | |
1015 | (list |
|
1027 | (list | |
1016 | (list |
|
1028 | (list | |
1017 | (list |
|
1029 | (list | |
1018 | (or |
|
1030 | (or | |
1019 | ('symbol', '2') |
|
1031 | ('symbol', '2') | |
1020 | ('symbol', '3')) |
|
1032 | ('symbol', '3')) | |
1021 | ('symbol', 'x')) |
|
1033 | ('symbol', 'x')) | |
1022 | ('symbol', 'x')) |
|
1034 | ('symbol', 'x')) | |
1023 | ('symbol', 'date'))) |
|
1035 | ('symbol', 'date'))) | |
1024 | (func |
|
1036 | (func | |
1025 | ('symbol', 'reverse') |
|
1037 | ('symbol', 'reverse') | |
1026 | (func |
|
1038 | (func | |
1027 | ('symbol', 'sort') |
|
1039 | ('symbol', 'sort') | |
1028 | (list |
|
1040 | (list | |
1029 | (or |
|
1041 | (or | |
1030 | ('symbol', '2') |
|
1042 | ('symbol', '2') | |
1031 | ('symbol', '3')) |
|
1043 | ('symbol', '3')) | |
1032 | ('symbol', 'date')))) |
|
1044 | ('symbol', 'date')))) | |
1033 | 3 |
|
1045 | 3 | |
1034 | 2 |
|
1046 | 2 | |
1035 |
|
1047 | |||
1036 | issue2549 - correct optimizations |
|
1048 | issue2549 - correct optimizations | |
1037 |
|
1049 | |||
1038 | $ log 'limit(1 or 2 or 3, 2) and not 2' |
|
1050 | $ log 'limit(1 or 2 or 3, 2) and not 2' | |
1039 | 1 |
|
1051 | 1 | |
1040 | $ log 'max(1 or 2) and not 2' |
|
1052 | $ log 'max(1 or 2) and not 2' | |
1041 | $ log 'min(1 or 2) and not 1' |
|
1053 | $ log 'min(1 or 2) and not 1' | |
1042 | $ log 'last(1 or 2, 1) and not 2' |
|
1054 | $ log 'last(1 or 2, 1) and not 2' | |
1043 |
|
1055 | |||
1044 | issue4289 - ordering of built-ins |
|
1056 | issue4289 - ordering of built-ins | |
1045 | $ hg log -M -q -r 3:2 |
|
1057 | $ hg log -M -q -r 3:2 | |
1046 | 3:8528aa5637f2 |
|
1058 | 3:8528aa5637f2 | |
1047 | 2:5ed5505e9f1c |
|
1059 | 2:5ed5505e9f1c | |
1048 |
|
1060 | |||
1049 | test revsets started with 40-chars hash (issue3669) |
|
1061 | test revsets started with 40-chars hash (issue3669) | |
1050 |
|
1062 | |||
1051 | $ ISSUE3669_TIP=`hg tip --template '{node}'` |
|
1063 | $ ISSUE3669_TIP=`hg tip --template '{node}'` | |
1052 | $ hg log -r "${ISSUE3669_TIP}" --template '{rev}\n' |
|
1064 | $ hg log -r "${ISSUE3669_TIP}" --template '{rev}\n' | |
1053 | 9 |
|
1065 | 9 | |
1054 | $ hg log -r "${ISSUE3669_TIP}^" --template '{rev}\n' |
|
1066 | $ hg log -r "${ISSUE3669_TIP}^" --template '{rev}\n' | |
1055 | 8 |
|
1067 | 8 | |
1056 |
|
1068 | |||
1057 | test or-ed indirect predicates (issue3775) |
|
1069 | test or-ed indirect predicates (issue3775) | |
1058 |
|
1070 | |||
1059 | $ log '6 or 6^1' | sort |
|
1071 | $ log '6 or 6^1' | sort | |
1060 | 5 |
|
1072 | 5 | |
1061 | 6 |
|
1073 | 6 | |
1062 | $ log '6^1 or 6' | sort |
|
1074 | $ log '6^1 or 6' | sort | |
1063 | 5 |
|
1075 | 5 | |
1064 | 6 |
|
1076 | 6 | |
1065 | $ log '4 or 4~1' | sort |
|
1077 | $ log '4 or 4~1' | sort | |
1066 | 2 |
|
1078 | 2 | |
1067 | 4 |
|
1079 | 4 | |
1068 | $ log '4~1 or 4' | sort |
|
1080 | $ log '4~1 or 4' | sort | |
1069 | 2 |
|
1081 | 2 | |
1070 | 4 |
|
1082 | 4 | |
1071 | $ log '(0 or 2):(4 or 6) or 0 or 6' | sort |
|
1083 | $ log '(0 or 2):(4 or 6) or 0 or 6' | sort | |
1072 | 0 |
|
1084 | 0 | |
1073 | 1 |
|
1085 | 1 | |
1074 | 2 |
|
1086 | 2 | |
1075 | 3 |
|
1087 | 3 | |
1076 | 4 |
|
1088 | 4 | |
1077 | 5 |
|
1089 | 5 | |
1078 | 6 |
|
1090 | 6 | |
1079 | $ log '0 or 6 or (0 or 2):(4 or 6)' | sort |
|
1091 | $ log '0 or 6 or (0 or 2):(4 or 6)' | sort | |
1080 | 0 |
|
1092 | 0 | |
1081 | 1 |
|
1093 | 1 | |
1082 | 2 |
|
1094 | 2 | |
1083 | 3 |
|
1095 | 3 | |
1084 | 4 |
|
1096 | 4 | |
1085 | 5 |
|
1097 | 5 | |
1086 | 6 |
|
1098 | 6 | |
1087 |
|
1099 | |||
1088 | tests for 'remote()' predicate: |
|
1100 | tests for 'remote()' predicate: | |
1089 | #. (csets in remote) (id) (remote) |
|
1101 | #. (csets in remote) (id) (remote) | |
1090 | 1. less than local current branch "default" |
|
1102 | 1. less than local current branch "default" | |
1091 | 2. same with local specified "default" |
|
1103 | 2. same with local specified "default" | |
1092 | 3. more than local specified specified |
|
1104 | 3. more than local specified specified | |
1093 |
|
1105 | |||
1094 | $ hg clone --quiet -U . ../remote3 |
|
1106 | $ hg clone --quiet -U . ../remote3 | |
1095 | $ cd ../remote3 |
|
1107 | $ cd ../remote3 | |
1096 | $ hg update -q 7 |
|
1108 | $ hg update -q 7 | |
1097 | $ echo r > r |
|
1109 | $ echo r > r | |
1098 | $ hg ci -Aqm 10 |
|
1110 | $ hg ci -Aqm 10 | |
1099 | $ log 'remote()' |
|
1111 | $ log 'remote()' | |
1100 | 7 |
|
1112 | 7 | |
1101 | $ log 'remote("a-b-c-")' |
|
1113 | $ log 'remote("a-b-c-")' | |
1102 | 2 |
|
1114 | 2 | |
1103 | $ cd ../repo |
|
1115 | $ cd ../repo | |
1104 | $ log 'remote(".a.b.c.", "../remote3")' |
|
1116 | $ log 'remote(".a.b.c.", "../remote3")' | |
1105 |
|
1117 | |||
1106 | $ cd .. |
|
1118 | $ cd .. | |
1107 |
|
1119 | |||
1108 | test author/desc/keyword in problematic encoding |
|
1120 | test author/desc/keyword in problematic encoding | |
1109 | # unicode: cp932: |
|
1121 | # unicode: cp932: | |
1110 | # u30A2 0x83 0x41(= 'A') |
|
1122 | # u30A2 0x83 0x41(= 'A') | |
1111 | # u30C2 0x83 0x61(= 'a') |
|
1123 | # u30C2 0x83 0x61(= 'a') | |
1112 |
|
1124 | |||
1113 | $ hg init problematicencoding |
|
1125 | $ hg init problematicencoding | |
1114 | $ cd problematicencoding |
|
1126 | $ cd problematicencoding | |
1115 |
|
1127 | |||
1116 | $ python > setup.sh <<EOF |
|
1128 | $ python > setup.sh <<EOF | |
1117 | > print u''' |
|
1129 | > print u''' | |
1118 | > echo a > text |
|
1130 | > echo a > text | |
1119 | > hg add text |
|
1131 | > hg add text | |
1120 | > hg --encoding utf-8 commit -u '\u30A2' -m none |
|
1132 | > hg --encoding utf-8 commit -u '\u30A2' -m none | |
1121 | > echo b > text |
|
1133 | > echo b > text | |
1122 | > hg --encoding utf-8 commit -u '\u30C2' -m none |
|
1134 | > hg --encoding utf-8 commit -u '\u30C2' -m none | |
1123 | > echo c > text |
|
1135 | > echo c > text | |
1124 | > hg --encoding utf-8 commit -u none -m '\u30A2' |
|
1136 | > hg --encoding utf-8 commit -u none -m '\u30A2' | |
1125 | > echo d > text |
|
1137 | > echo d > text | |
1126 | > hg --encoding utf-8 commit -u none -m '\u30C2' |
|
1138 | > hg --encoding utf-8 commit -u none -m '\u30C2' | |
1127 | > '''.encode('utf-8') |
|
1139 | > '''.encode('utf-8') | |
1128 | > EOF |
|
1140 | > EOF | |
1129 | $ sh < setup.sh |
|
1141 | $ sh < setup.sh | |
1130 |
|
1142 | |||
1131 | test in problematic encoding |
|
1143 | test in problematic encoding | |
1132 | $ python > test.sh <<EOF |
|
1144 | $ python > test.sh <<EOF | |
1133 | > print u''' |
|
1145 | > print u''' | |
1134 | > hg --encoding cp932 log --template '{rev}\\n' -r 'author(\u30A2)' |
|
1146 | > hg --encoding cp932 log --template '{rev}\\n' -r 'author(\u30A2)' | |
1135 | > echo ==== |
|
1147 | > echo ==== | |
1136 | > hg --encoding cp932 log --template '{rev}\\n' -r 'author(\u30C2)' |
|
1148 | > hg --encoding cp932 log --template '{rev}\\n' -r 'author(\u30C2)' | |
1137 | > echo ==== |
|
1149 | > echo ==== | |
1138 | > hg --encoding cp932 log --template '{rev}\\n' -r 'desc(\u30A2)' |
|
1150 | > hg --encoding cp932 log --template '{rev}\\n' -r 'desc(\u30A2)' | |
1139 | > echo ==== |
|
1151 | > echo ==== | |
1140 | > hg --encoding cp932 log --template '{rev}\\n' -r 'desc(\u30C2)' |
|
1152 | > hg --encoding cp932 log --template '{rev}\\n' -r 'desc(\u30C2)' | |
1141 | > echo ==== |
|
1153 | > echo ==== | |
1142 | > hg --encoding cp932 log --template '{rev}\\n' -r 'keyword(\u30A2)' |
|
1154 | > hg --encoding cp932 log --template '{rev}\\n' -r 'keyword(\u30A2)' | |
1143 | > echo ==== |
|
1155 | > echo ==== | |
1144 | > hg --encoding cp932 log --template '{rev}\\n' -r 'keyword(\u30C2)' |
|
1156 | > hg --encoding cp932 log --template '{rev}\\n' -r 'keyword(\u30C2)' | |
1145 | > '''.encode('cp932') |
|
1157 | > '''.encode('cp932') | |
1146 | > EOF |
|
1158 | > EOF | |
1147 | $ sh < test.sh |
|
1159 | $ sh < test.sh | |
1148 | 0 |
|
1160 | 0 | |
1149 | ==== |
|
1161 | ==== | |
1150 | 1 |
|
1162 | 1 | |
1151 | ==== |
|
1163 | ==== | |
1152 | 2 |
|
1164 | 2 | |
1153 | ==== |
|
1165 | ==== | |
1154 | 3 |
|
1166 | 3 | |
1155 | ==== |
|
1167 | ==== | |
1156 | 0 |
|
1168 | 0 | |
1157 | 2 |
|
1169 | 2 | |
1158 | ==== |
|
1170 | ==== | |
1159 | 1 |
|
1171 | 1 | |
1160 | 3 |
|
1172 | 3 | |
1161 |
|
1173 | |||
1162 | $ cd .. |
|
1174 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now