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 |