From patchwork Sun Jul 9 17:55:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [14, of, 14] obscache: skip updating outdated obscache obscache for readonly operation From: Boris Feld X-Patchwork-Id: 22175 Message-Id: <59528ec2969e10de1c3e.1499622926@FB> To: mercurial-devel@mercurial-scm.org Cc: boris.feld@octobus.net Date: Sun, 09 Jul 2017 19:55:26 +0200 # HG changeset patch # User Boris Feld # Date 1496358960 -7200 # Fri Jun 02 01:16:00 2017 +0200 # Node ID 59528ec2969e10de1c3eec16149b483083b89218 # Parent 7774ff78ef2e7433368184e7de743342b771b91c # EXP-Topic obs-cache obscache: skip updating outdated obscache obscache for readonly operation During read only operation, we fallback to the old way of computing obsolescence markers when we detect that the obscache is behind/invalid. This might happen when both old and new clients touch the same repository. This is a simple way to avoiding paying extra cache warming overhead without making the cache write pattern more complex. diff -r 7774ff78ef2e -r 59528ec2969e mercurial/obsolete.py --- a/mercurial/obsolete.py Sun Jul 09 03:56:12 2017 +0200 +++ b/mercurial/obsolete.py Fri Jun 02 01:16:00 2017 +0200 @@ -1125,9 +1125,14 @@ # good old version (parsing markers and checking them). We could add some # logic to fall back to the old way in these cases. obscache = repo.obsstore.obscache - obscache.update(repo) # ensure it is up to date: - isobs = obscache.get - + if obscache.uptodate(repo) and repo.currenttransaction() is None: + hasnode = repo.obsstore.successors.__contains__ + node = repo.changelog.node + def isobs(rev): + return hasnode(node(rev)) + else: + obscache.update(repo) # ensure it is up to date: + isobs = obscache.get return set(r for r in notpublic if isobs(r)) @cachefor('unstable')