##// END OF EJS Templates
revset: change ancestor to accept 0 or more arguments (issue3750)...
Paul Cavallaro -
r18536:ae645d4f default
parent child Browse files
Show More
@@ -277,20 +277,32 b' def adds(repo, subset, x):'
277 277 return checkstatus(repo, subset, pat, 1)
278 278
279 279 def ancestor(repo, subset, x):
280 """``ancestor(single, single)``
281 Greatest common ancestor of the two changesets.
280 """``ancestor(*changeset)``
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 287 # i18n: "ancestor" is a keyword
284 l = getargs(x, 2, 2, _("ancestor requires two arguments"))
285 r = list(repo)
286 a = getset(repo, r, l[0])
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()]
288 l = getlist(x)
289 rl = list(repo)
290 anc = None
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 307 def _ancestors(repo, subset, x, followfirst=False):
296 308 args = getset(repo, list(repo), x)
@@ -218,17 +218,29 b' quoting needed'
218 218 $ log 'date(2005) and 1::'
219 219 4
220 220
221 ancestor can accept 0 or more arguments
222
223 $ log 'ancestor()'
221 224 $ log 'ancestor(1)'
222 hg: parse error: ancestor requires two arguments
223 [255]
225 1
224 226 $ log 'ancestor(4,5)'
225 227 1
226 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 237 $ log 'ancestors(5)'
228 238 0
229 239 1
230 240 3
231 241 5
242 $ log 'ancestor(ancestors(5))'
243 0
232 244 $ log 'author(bob)'
233 245 2
234 246 $ log 'author("re:bob|test")'
General Comments 0
You need to be logged in to leave comments. Login now