mercurial/revset.py
changeset 20991 a05d694599f9
parent 20895 f52e4ca93529
child 21024 7731a2281cf0
equal deleted inserted replaced
20990:d9e211a658eb 20991:a05d694599f9
   318     pat = getstring(x, _("adds requires a pattern"))
   318     pat = getstring(x, _("adds requires a pattern"))
   319     return checkstatus(repo, subset, pat, 1)
   319     return checkstatus(repo, subset, pat, 1)
   320 
   320 
   321 def ancestor(repo, subset, x):
   321 def ancestor(repo, subset, x):
   322     """``ancestor(*changeset)``
   322     """``ancestor(*changeset)``
   323     Greatest common ancestor of the changesets.
   323     A greatest common ancestor of the changesets.
   324 
   324 
   325     Accepts 0 or more changesets.
   325     Accepts 0 or more changesets.
   326     Will return empty list when passed no args.
   326     Will return empty list when passed no args.
   327     Greatest common ancestor of a single changeset is that changeset.
   327     Greatest common ancestor of a single changeset is that changeset.
   328     """
   328     """
   330     l = getlist(x)
   330     l = getlist(x)
   331     rl = spanset(repo)
   331     rl = spanset(repo)
   332     anc = None
   332     anc = None
   333 
   333 
   334     # (getset(repo, rl, i) for i in l) generates a list of lists
   334     # (getset(repo, rl, i) for i in l) generates a list of lists
   335     rev = repo.changelog.rev
       
   336     ancestor = repo.changelog.ancestor
       
   337     node = repo.changelog.node
       
   338     for revs in (getset(repo, rl, i) for i in l):
   335     for revs in (getset(repo, rl, i) for i in l):
   339         for r in revs:
   336         for r in revs:
   340             if anc is None:
   337             if anc is None:
   341                 anc = r
   338                 anc = repo[r]
   342             else:
   339             else:
   343                 anc = rev(ancestor(node(anc), node(r)))
   340                 anc = anc.ancestor(repo[r])
   344 
   341 
   345     if anc is not None and anc in subset:
   342     if anc is not None and anc.rev() in subset:
   346         return baseset([anc])
   343         return baseset([anc.rev()])
   347     return baseset([])
   344     return baseset([])
   348 
   345 
   349 def _ancestors(repo, subset, x, followfirst=False):
   346 def _ancestors(repo, subset, x, followfirst=False):
   350     args = getset(repo, spanset(repo), x)
   347     args = getset(repo, spanset(repo), x)
   351     if not args:
   348     if not args: