From patchwork Wed Sep 7 14:10:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: revset: cleanup of algorithm used in `destination()` predicate From: Hannes Oldenburg X-Patchwork-Id: 16570 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Wed, 07 Sep 2016 14:10:29 +0000 # HG changeset patch # User Hannes Oldenburg # Date 1473247581 0 # Wed Sep 07 11:26:21 2016 +0000 # Node ID dacd359aca5a1094d830958ab853bf83b5ca6631 # Parent f148bfa40489269be2e48046734f81065129847a revset: cleanup of algorithm used in `destination()` predicate diff -r f148bfa40489 -r dacd359aca5a mercurial/revset.py --- a/mercurial/revset.py Tue Jul 05 09:37:07 2016 +0200 +++ b/mercurial/revset.py Wed Sep 07 11:26:21 2016 +0000 @@ -851,28 +851,20 @@ # transitive transplants and rebases to yield the same results as transitive # grafts. for r in subset: - src = _getrevsource(repo, r) - lineage = None - - while src is not None: - if lineage is None: - lineage = list() - + lineage = list() + found = False + while r is not None and not found: lineage.append(r) - + r = _getrevsource(repo, r) # The visited lineage is a match if the current source is in the arg # set. Since every candidate dest is visited by way of iterating # subset, any dests further back in the lineage will be tested by a # different iteration over subset. Likewise, if the src was already # selected, the current lineage can be selected without going back # further. - if src in sources or src in dests: - dests.update(lineage) - break - - r = src - src = _getrevsource(repo, r) - + found = r in sources or r in dests + if found: + dests.update(lineage) return subset.filter(dests.__contains__, condrepr=lambda: '' % sorted(dests))