Submitter | Hannes Oldenburg |
---|---|
Date | Sept. 7, 2016, 2:10 p.m. |
Message ID | <dacd359aca5a1094d830.1473257429@localhost.localdomain> |
Download | mbox | patch |
Permalink | /patch/16570/ |
State | Changes Requested |
Headers | show |
Comments
On 09/07/2016 04:10 PM, Hannes Oldenburg wrote: > # HG changeset patch > # User Hannes Oldenburg <hannes.christian.oldenburg@gmail.com> > # Date 1473247581 0 > # Wed Sep 07 11:26:21 2016 +0000 > # Node ID dacd359aca5a1094d830958ab853bf83b5ca6631 > # Parent f148bfa40489269be2e48046734f81065129847a > revset: cleanup of algorithm used in `destination()` predicate Can you include a bit more details in the changeset description about what this cleanup is about and why it is correct ? > 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: '<destination %r>' % sorted(dests)) > > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel >
Patch
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: '<destination %r>' % sorted(dests))