Show More
@@ -277,20 +277,32 b' def adds(repo, subset, x):' | |||||
277 | return checkstatus(repo, subset, pat, 1) |
|
277 | return checkstatus(repo, subset, pat, 1) | |
278 |
|
278 | |||
279 | def ancestor(repo, subset, x): |
|
279 | def ancestor(repo, subset, x): | |
280 |
"""``ancestor( |
|
280 | """``ancestor(*changeset)`` | |
281 |
Greatest common ancestor of the |
|
281 | Greatest common ancestor of the changesets. | |
|
282 | ||||
|
283 | Accepts 0 or more changesets. | |||
|
284 | Will return empty list when passed no args. | |||
|
285 | Greatest common ancestor of a single changeset is that changeset. | |||
282 | """ |
|
286 | """ | |
283 | # i18n: "ancestor" is a keyword |
|
287 | # i18n: "ancestor" is a keyword | |
284 | l = getargs(x, 2, 2, _("ancestor requires two arguments")) |
|
288 | l = getlist(x) | |
285 | r = list(repo) |
|
289 | rl = list(repo) | |
286 | a = getset(repo, r, l[0]) |
|
290 | anc = None | |
287 | b = getset(repo, r, l[1]) |
|
|||
288 | if len(a) != 1 or len(b) != 1: |
|
|||
289 | # i18n: "ancestor" is a keyword |
|
|||
290 | raise error.ParseError(_("ancestor arguments must be single revisions")) |
|
|||
291 | an = [repo[a[0]].ancestor(repo[b[0]]).rev()] |
|
|||
292 |
|
291 | |||
293 | return [r for r in an if r in subset] |
|
292 | # (getset(repo, rl, i) for i in l) generates a list of lists | |
|
293 | rev = repo.changelog.rev | |||
|
294 | ancestor = repo.changelog.ancestor | |||
|
295 | node = repo.changelog.node | |||
|
296 | for revs in (getset(repo, rl, i) for i in l): | |||
|
297 | for r in revs: | |||
|
298 | if anc is None: | |||
|
299 | anc = r | |||
|
300 | else: | |||
|
301 | anc = rev(ancestor(node(anc), node(r))) | |||
|
302 | ||||
|
303 | if anc is not None and anc in subset: | |||
|
304 | return [anc] | |||
|
305 | return [] | |||
294 |
|
306 | |||
295 | def _ancestors(repo, subset, x, followfirst=False): |
|
307 | def _ancestors(repo, subset, x, followfirst=False): | |
296 | args = getset(repo, list(repo), x) |
|
308 | args = getset(repo, list(repo), x) |
@@ -218,17 +218,29 b' quoting needed' | |||||
218 | $ log 'date(2005) and 1::' |
|
218 | $ log 'date(2005) and 1::' | |
219 | 4 |
|
219 | 4 | |
220 |
|
220 | |||
|
221 | ancestor can accept 0 or more arguments | |||
|
222 | ||||
|
223 | $ log 'ancestor()' | |||
221 | $ log 'ancestor(1)' |
|
224 | $ log 'ancestor(1)' | |
222 | hg: parse error: ancestor requires two arguments |
|
225 | 1 | |
223 | [255] |
|
|||
224 | $ log 'ancestor(4,5)' |
|
226 | $ log 'ancestor(4,5)' | |
225 | 1 |
|
227 | 1 | |
226 | $ log 'ancestor(4,5) and 4' |
|
228 | $ log 'ancestor(4,5) and 4' | |
|
229 | $ log 'ancestor(0,0,1,3)' | |||
|
230 | 0 | |||
|
231 | $ log 'ancestor(3,1,5,3,5,1)' | |||
|
232 | 1 | |||
|
233 | $ log 'ancestor(0,1,3,5)' | |||
|
234 | 0 | |||
|
235 | $ log 'ancestor(1,2,3,4,5)' | |||
|
236 | 1 | |||
227 | $ log 'ancestors(5)' |
|
237 | $ log 'ancestors(5)' | |
228 | 0 |
|
238 | 0 | |
229 | 1 |
|
239 | 1 | |
230 | 3 |
|
240 | 3 | |
231 | 5 |
|
241 | 5 | |
|
242 | $ log 'ancestor(ancestors(5))' | |||
|
243 | 0 | |||
232 | $ log 'author(bob)' |
|
244 | $ log 'author(bob)' | |
233 | 2 |
|
245 | 2 | |
234 | $ log 'author("re:bob|test")' |
|
246 | $ log 'author("re:bob|test")' |
General Comments 0
You need to be logged in to leave comments.
Login now