From patchwork Thu Aug 7 18:08:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3,of,3] repoview: add optional hiddencache verification From: David Soria Parra X-Patchwork-Id: 5313 Message-Id: <5dd7cb3ba93256f916a9.1407434927@dev544.prn1.facebook.com> To: Date: Thu, 7 Aug 2014 11:08:47 -0700 # HG changeset patch # User David Soria Parra # Date 1407430439 25200 # Thu Aug 07 09:53:59 2014 -0700 # Node ID 5dd7cb3ba93256f916a970a4dc1f1b7e178e4176 # Parent 3da6820d38112cddfc21e2b99ab02957f93d80cf repoview: add optional hiddencache verification To ensure our cache approach is correct and users aren't affected, we are verifying the cache by default. If we don't encounter any user reports of an invalid cache we will remove the verification and the internal variable. diff --git a/mercurial/repoview.py b/mercurial/repoview.py --- a/mercurial/repoview.py +++ b/mercurial/repoview.py @@ -86,11 +86,19 @@ if iscachevalid(repo, hideable): data = repo.vfs.read(cachefile) hidden = frozenset(struct.unpack('%sI' % (len(data) / 4), data)) + # internal: don't document as it will be removed in the future. + if repo.ui.configbool('repoview', 'verifycache', True): + blocked = cl.ancestors(_gethiddenblockers(repo), inclusive=True) + computed = frozenset(r for r in hideable if r not in blocked) + if computed != hidden: + invalidatecache(repo) + repo.ui.warn(_('Cache inconsistency detected. Please ' + + 'open an issue on http://bz.selenic.com.\n')) + hidden = computed else: # recompute cache blocked = cl.ancestors(_gethiddenblockers(repo), inclusive=True) hidden = frozenset(r for r in hideable if r not in blocked) - # write cache to file try: data = struct.pack('%sI' % len(hidden), *hidden)