mercurial/revset.py
changeset 17186 a3da6f298592
parent 17185 2c7c4824969e
child 17244 483aa765f6c4
equal deleted inserted replaced
17185:2c7c4824969e 17186:a3da6f298592
   559 def _firstdescendants(repo, subset, x):
   559 def _firstdescendants(repo, subset, x):
   560     # ``_firstdescendants(set)``
   560     # ``_firstdescendants(set)``
   561     # Like ``descendants(set)`` but follows only the first parents.
   561     # Like ``descendants(set)`` but follows only the first parents.
   562     return _descendants(repo, subset, x, followfirst=True)
   562     return _descendants(repo, subset, x, followfirst=True)
   563 
   563 
       
   564 def destination(repo, subset, x):
       
   565     """``destination([set])``
       
   566     Changesets that were created by a graft, transplant or rebase operation,
       
   567     with the given revisions specified as the source.  Omitting the optional set
       
   568     is the same as passing all().
       
   569     """
       
   570     if x is not None:
       
   571         args = set(getset(repo, range(len(repo)), x))
       
   572     else:
       
   573         args = set(getall(repo, range(len(repo)), x))
       
   574 
       
   575     dests = set()
       
   576 
       
   577     # subset contains all of the possible destinations that can be returned, so
       
   578     # iterate over them and see if their source(s) were provided in the args.
       
   579     # Even if the immediate src of r is not in the args, src's source (or
       
   580     # further back) may be.  Scanning back further than the immediate src allows
       
   581     # transitive transplants and rebases to yield the same results as transitive
       
   582     # grafts.
       
   583     for r in subset:
       
   584         src = _getrevsource(repo, r)
       
   585         lineage = None
       
   586 
       
   587         while src is not None:
       
   588             if lineage is None:
       
   589                 lineage = list()
       
   590 
       
   591             lineage.append(r)
       
   592 
       
   593             # The visited lineage is a match if the current source is in the arg
       
   594             # set.  Since every candidate dest is visited by way of iterating
       
   595             # subset, any dests futher back in the lineage will be tested by a
       
   596             # different iteration over subset.  Likewise, if the src was already
       
   597             # selected, the current lineage can be selected without going back
       
   598             # further.
       
   599             if src in args or src in dests:
       
   600                 dests.update(lineage)
       
   601                 break
       
   602 
       
   603             r = src
       
   604             src = _getrevsource(repo, r)
       
   605 
       
   606     return [r for r in subset if r in dests]
       
   607 
   564 def draft(repo, subset, x):
   608 def draft(repo, subset, x):
   565     """``draft()``
   609     """``draft()``
   566     Changeset in draft phase."""
   610     Changeset in draft phase."""
   567     getargs(x, 0, 0, _("draft takes no arguments"))
   611     getargs(x, 0, 0, _("draft takes no arguments"))
   568     pc = repo._phasecache
   612     pc = repo._phasecache
  1397     "converted": converted,
  1441     "converted": converted,
  1398     "date": date,
  1442     "date": date,
  1399     "desc": desc,
  1443     "desc": desc,
  1400     "descendants": descendants,
  1444     "descendants": descendants,
  1401     "_firstdescendants": _firstdescendants,
  1445     "_firstdescendants": _firstdescendants,
       
  1446     "destination": destination,
  1402     "draft": draft,
  1447     "draft": draft,
  1403     "extinct": extinct,
  1448     "extinct": extinct,
  1404     "extra": extra,
  1449     "extra": extra,
  1405     "file": hasfile,
  1450     "file": hasfile,
  1406     "filelog": filelog,
  1451     "filelog": filelog,