Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 17786:72c234081ae1
branchpoint: remove useless intermediate set creation
We don't need to compute the set of all branchpoints. We can just check the
number of children that element of subset have. The extra work did not seems to
had particular performance impact but the code is simpler this way.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Mon, 15 Oct 2012 17:43:05 +0200 |
parents | ac5c9c8046f7 |
children | 5a511d255301 |
comparison
equal
deleted
inserted
replaced
17785:ac5c9c8046f7 | 17786:72c234081ae1 |
---|---|
931 parentscount = [0]*(len(repo) - baserev) | 931 parentscount = [0]*(len(repo) - baserev) |
932 for r in cl.revs(start=baserev + 1): | 932 for r in cl.revs(start=baserev + 1): |
933 for p in cl.parentrevs(r): | 933 for p in cl.parentrevs(r): |
934 if p >= baserev: | 934 if p >= baserev: |
935 parentscount[p - baserev] += 1 | 935 parentscount[p - baserev] += 1 |
936 branchpoints = set((baserev + i) for i in xrange(len(parentscount)) | 936 return [r for r in subset if (parentscount[r - baserev] > 1)] |
937 if parentscount[i] > 1) | |
938 return [r for r in subset if r in branchpoints] | |
939 | 937 |
940 def minrev(repo, subset, x): | 938 def minrev(repo, subset, x): |
941 """``min(set)`` | 939 """``min(set)`` |
942 Changeset with lowest revision number in set. | 940 Changeset with lowest revision number in set. |
943 """ | 941 """ |