[Updated] D12138: branchmap: split a long condition in branchcache.validfor(), add comments
av6 (Anton Shestakov)
phabricator at mercurial-scm.org
Mon Feb 7 14:05:13 UTC 2022
Closed by commit rHG02e9ad08999b: branchmap: split a long condition in branchcache.validfor(), add comments (authored by av6).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D12138?vs=32082&id=32085
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D12138/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D12138
AFFECTED FILES
mercurial/branchmap.py
CHANGE DETAILS
diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -352,17 +352,25 @@
return filename
def validfor(self, repo):
- """Is the cache content valid regarding a repo
+ """check that cache contents are valid for (a subset of) this repo
- - False when cached tipnode is unknown or if we detect a strip.
- - True when cache is up to date or a subset of current repo."""
+ - False when the order of changesets changed or if we detect a strip.
+ - True when cache is up-to-date for the current repo or its subset."""
try:
- return (self.tipnode == repo.changelog.node(self.tiprev)) and (
- self.filteredhash
- == scmutil.filteredhash(repo, self.tiprev, needobsolete=True)
- )
+ node = repo.changelog.node(self.tiprev)
except IndexError:
+ # changesets were stripped and now we don't even have enough to
+ # find tiprev
return False
+ if self.tipnode != node:
+ # tiprev doesn't correspond to tipnode: repo was stripped, or this
+ # repo has a different order of changesets
+ return False
+ tiphash = scmutil.filteredhash(repo, self.tiprev, needobsolete=True)
+ # hashes don't match if this repo view has a different set of filtered
+ # revisions (e.g. due to phase changes) or obsolete revisions (e.g.
+ # history was rewritten)
+ return self.filteredhash == tiphash
def _branchtip(self, heads):
"""Return tuple with last open head in heads and false,
To: av6, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20220207/0bb0e94a/attachment-0002.html>
More information about the Mercurial-patches
mailing list