comparison mercurial/branchmap.py @ 48719:02e9ad08999b

branchmap: split a long condition in branchcache.validfor(), add comments Differential Revision: https://phab.mercurial-scm.org/D12138
author Anton Shestakov <av6@dwimlabs.net>
date Mon, 07 Feb 2022 13:24:30 +0300
parents 8b393f40a5e6
children 6000f5b25c9b
comparison
equal deleted inserted replaced
48718:8b393f40a5e6 48719:02e9ad08999b
350 if repo.filtername: 350 if repo.filtername:
351 filename = b'%s-%s' % (filename, repo.filtername) 351 filename = b'%s-%s' % (filename, repo.filtername)
352 return filename 352 return filename
353 353
354 def validfor(self, repo): 354 def validfor(self, repo):
355 """Is the cache content valid regarding a repo 355 """check that cache contents are valid for (a subset of) this repo
356 356
357 - False when cached tipnode is unknown or if we detect a strip. 357 - False when the order of changesets changed or if we detect a strip.
358 - True when cache is up to date or a subset of current repo.""" 358 - True when cache is up-to-date for the current repo or its subset."""
359 try: 359 try:
360 return (self.tipnode == repo.changelog.node(self.tiprev)) and ( 360 node = repo.changelog.node(self.tiprev)
361 self.filteredhash
362 == scmutil.filteredhash(repo, self.tiprev, needobsolete=True)
363 )
364 except IndexError: 361 except IndexError:
362 # changesets were stripped and now we don't even have enough to
363 # find tiprev
365 return False 364 return False
365 if self.tipnode != node:
366 # tiprev doesn't correspond to tipnode: repo was stripped, or this
367 # repo has a different order of changesets
368 return False
369 tiphash = scmutil.filteredhash(repo, self.tiprev, needobsolete=True)
370 # hashes don't match if this repo view has a different set of filtered
371 # revisions (e.g. due to phase changes) or obsolete revisions (e.g.
372 # history was rewritten)
373 return self.filteredhash == tiphash
366 374
367 def _branchtip(self, heads): 375 def _branchtip(self, heads):
368 """Return tuple with last open head in heads and false, 376 """Return tuple with last open head in heads and false,
369 otherwise return last closed head and true.""" 377 otherwise return last closed head and true."""
370 tip = heads[-1] 378 tip = heads[-1]