comparison mercurial/revset.py @ 26053:b68c9d232db6

reachableroots: use internal "revstates" array to test if rev is a root The main goal of this patch series is to reduce the use of PyXxx() function that is likely to require ugly error handling and inc/decref. Plus, this is faster than using PySet_Contains(). revset #0: 0::tip 0) 0.004168 1) 0.003678 88% This patch ignores out-of-range roots as they are in the pure implementation. Because reachable sets are calculated from heads, and out-of-range heads raise IndexError, we can just take out-of-range roots as unreachable. Otherwise, the test of "hg log -Gr '. + wdir()'" would fail. "heads" argument is changed to a list. Should we have to rename the C function as its signature is changed?
author Yuya Nishihara <yuya@tcha.org>
date Fri, 14 Aug 2015 15:43:29 +0900
parents 1ffd97cbf9a2
children 4ee2af2194d4
comparison
equal deleted inserted replaced
26052:b970418bbafe 26053:b68c9d232db6
92 92
93 If includepath is True, return (<roots>::<heads>).""" 93 If includepath is True, return (<roots>::<heads>)."""
94 if not roots: 94 if not roots:
95 return baseset() 95 return baseset()
96 parentrevs = repo.changelog.parentrevs 96 parentrevs = repo.changelog.parentrevs
97 roots = set(roots)
97 visit = list(heads) 98 visit = list(heads)
98 reachable = set() 99 reachable = set()
99 seen = {} 100 seen = {}
100 # prefetch all the things! (because python is slow) 101 # prefetch all the things! (because python is slow)
101 reached = reachable.add 102 reached = reachable.add
131 if not roots: 132 if not roots:
132 return baseset() 133 return baseset()
133 # XXX this should be 'parentset.min()' assuming 'parentset' is a smartset 134 # XXX this should be 'parentset.min()' assuming 'parentset' is a smartset
134 # (and if it is not, it should.) 135 # (and if it is not, it should.)
135 minroot = min(roots) 136 minroot = min(roots)
136 roots = set(roots) 137 roots = list(roots)
137 heads = list(heads) 138 heads = list(heads)
138 try: 139 try:
139 return repo.changelog.reachableroots(minroot, heads, roots, includepath) 140 return repo.changelog.reachableroots(minroot, heads, roots, includepath)
140 except AttributeError: 141 except AttributeError:
141 return reachablerootspure(repo, minroot, roots, heads, includepath) 142 return reachablerootspure(repo, minroot, roots, heads, includepath)