comparison mercurial/branchmap.py @ 51535:03247e37ccf7

branchcache: move the processing of the new data in a dedicated method In a future changeset, this will allow the V3 of the branch cache to use a fast path when possible.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 06 Mar 2024 16:18:03 +0100
parents 767b62cb728e
children 718f28ea3af4
comparison
equal deleted inserted replaced
51534:767b62cb728e 51535:03247e37ccf7
305 new_closed.add(r) 305 new_closed.add(r)
306 if max_rev < 0: 306 if max_rev < 0:
307 msg = "running branchcache.update without revision to update" 307 msg = "running branchcache.update without revision to update"
308 raise error.ProgrammingError(msg) 308 raise error.ProgrammingError(msg)
309 309
310 self._process_new(
311 repo,
312 newbranches,
313 new_closed,
314 obs_ignored,
315 max_rev,
316 )
317
318 self._closednodes.update(cl.node(rev) for rev in new_closed)
319
320 duration = util.timer() - starttime
321 repo.ui.log(
322 b'branchcache',
323 b'updated %s in %.4f seconds\n',
324 _branchcachedesc(repo),
325 duration,
326 )
327 return max_rev
328
329 def _process_new(
330 self,
331 repo,
332 newbranches,
333 new_closed,
334 obs_ignored,
335 max_rev,
336 ):
337 """update the branchmap from a set of new information"""
310 # Delay fetching the topological heads until they are needed. 338 # Delay fetching the topological heads until they are needed.
311 # A repository without non-continous branches can skip this part. 339 # A repository without non-continous branches can skip this part.
312 topoheads = None 340 topoheads = None
313 341
342 cl = repo.changelog
343 getbranchinfo = repo.revbranchcache().branchinfo
344 # Faster than using ctx.obsolete()
345 obsrevs = obsolete.getrevs(repo, b'obsolete')
346
314 # If a changeset is visible, its parents must be visible too, so 347 # If a changeset is visible, its parents must be visible too, so
315 # use the faster unfiltered parent accessor. 348 # use the faster unfiltered parent accessor.
316 parentrevs = repo.unfiltered().changelog.parentrevs 349 parentrevs = cl._uncheckedparentrevs
317 350
318 for branch, newheadrevs in newbranches.items(): 351 for branch, newheadrevs in newbranches.items():
319 # For every branch, compute the new branchheads. 352 # For every branch, compute the new branchheads.
320 # A branchhead is a revision such that no descendant is on 353 # A branchhead is a revision such that no descendant is on
321 # the same branch. 354 # the same branch.
390 ancestors = set(cl.ancestors(uncertain, floorrev)) 423 ancestors = set(cl.ancestors(uncertain, floorrev))
391 bheadset -= ancestors 424 bheadset -= ancestors
392 if bheadset: 425 if bheadset:
393 self[branch] = [cl.node(rev) for rev in sorted(bheadset)] 426 self[branch] = [cl.node(rev) for rev in sorted(bheadset)]
394 427
395 self._closednodes.update(cl.node(rev) for rev in new_closed)
396
397 duration = util.timer() - starttime
398 repo.ui.log(
399 b'branchcache',
400 b'updated %s in %.4f seconds\n',
401 _branchcachedesc(repo),
402 duration,
403 )
404 return max_rev
405
406 428
407 STATE_CLEAN = 1 429 STATE_CLEAN = 1
408 STATE_INHERITED = 2 430 STATE_INHERITED = 2
409 STATE_DIRTY = 3 431 STATE_DIRTY = 3
410 432