comparison mercurial/setdiscovery.py @ 39176:fec01c69b0f0

setdiscovery: use revset for resolving DAG heads in a subset This was the final use of dagutil in setdiscovery! For reasons I didn't investigate, feeding a set with nullrev into the heads() revset resulted in a bunch of tests failing. Filtering out nullrev from the input set fixes things. Differential Revision: https://phab.mercurial-scm.org/D4324
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 17 Aug 2018 18:23:47 +0000
parents 71d83b315778
children 274acf379dbb
comparison
equal deleted inserted replaced
39175:bbb855c412c6 39176:fec01c69b0f0
49 from .node import ( 49 from .node import (
50 nullid, 50 nullid,
51 nullrev, 51 nullrev,
52 ) 52 )
53 from . import ( 53 from . import (
54 dagutil,
55 error, 54 error,
56 util, 55 util,
57 ) 56 )
58 57
59 def _updatesample(revs, heads, sample, parentfn, quicksamplesize=0): 58 def _updatesample(revs, heads, sample, parentfn, quicksamplesize=0):
156 if ancestorsof is not None: 155 if ancestorsof is not None:
157 ownheads = [clrev(n) for n in ancestorsof] 156 ownheads = [clrev(n) for n in ancestorsof]
158 else: 157 else:
159 ownheads = [rev for rev in cl.headrevs() if rev != nullrev] 158 ownheads = [rev for rev in cl.headrevs() if rev != nullrev]
160 159
161 dag = dagutil.revlogdag(cl)
162
163 # early exit if we know all the specified remote heads already 160 # early exit if we know all the specified remote heads already
164 ui.debug("query 1; heads\n") 161 ui.debug("query 1; heads\n")
165 roundtrips += 1 162 roundtrips += 1
166 sample = _limitsample(ownheads, initialsamplesize) 163 sample = _limitsample(ownheads, initialsamplesize)
167 # indices between sample and externalized version must match 164 # indices between sample and externalized version must match
271 common.addbases(commoninsample) 268 common.addbases(commoninsample)
272 common.removeancestorsfrom(undecided) 269 common.removeancestorsfrom(undecided)
273 270
274 # heads(common) == heads(common.bases) since common represents common.bases 271 # heads(common) == heads(common.bases) since common represents common.bases
275 # and all its ancestors 272 # and all its ancestors
276 result = dag.headsetofconnecteds(common.bases) 273 # The presence of nullrev will confuse heads(). So filter it out.
277 # common.bases can include nullrev, but our contract requires us to not 274 result = set(local.revs('heads(%ld)', common.bases - {nullrev}))
278 # return any heads in that case, so discard that
279 result.discard(nullrev)
280 elapsed = util.timer() - start 275 elapsed = util.timer() - start
281 progress.complete() 276 progress.complete()
282 ui.debug("%d total queries in %.4fs\n" % (roundtrips, elapsed)) 277 ui.debug("%d total queries in %.4fs\n" % (roundtrips, elapsed))
283 msg = ('found %d common and %d unknown server heads,' 278 msg = ('found %d common and %d unknown server heads,'
284 ' %d roundtrips in %.4fs\n') 279 ' %d roundtrips in %.4fs\n')