Patchwork [evolve-ext] directaccess: use cached filteredrevs

login
register
mail settings
Submitter Laurent Charignon
Date June 15, 2015, 4:14 p.m.
Message ID <96c191101d08412b2c1d.1434384893@dev919.prn2.facebook.com>
Download mbox | patch
Permalink /patch/9635/
State Accepted
Headers show

Comments

Laurent Charignon - June 15, 2015, 4:14 p.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@fb.com>
# Date 1434219247 25200
#      Sat Jun 13 11:14:07 2015 -0700
# Node ID 96c191101d08412b2c1d5371710bef544f8a41dc
# Parent  043e5ca9322fc92cd90b9ff3dc462bcbfbd3c095
directaccess: use cached filteredrevs

Before this patch we were calling directly repoview.computehidden(repo) to
compute the revisions visible with direct access, without going through the
caching mechanism for the filtered revisions.

There was two issues with that:
(1) Performance: We were not leverating the cached values of the 'visible' revs
(2) Stability: If there were to be a cache inconsistency with the computation of
'visible' we would crash in the branchmap consistency check partial.validfor.
Consider the scenario of rebase with bookmarks:
- when we delete a bookmark on an obsolete changeset (like what rebase
  does when moving the bookmark after rebasing the changesets)
- then this changes the value returned by repoview.computehidden(repo) as
  bookmarks are used as dynamic blockers in repoview.computehidden(repo)
- as of now, we don't invalidate the cache in the case of bookmark change
- if we have a cached value from before the bookmark change,
  repoview.filterrevs(repo, 'visible') considers the cached value correct and
  returns something different than repoview.computehidden(repo)
- in turn, if we use repoview.computehidden(repo) in directaccess, the subset
  relationship is broken and the cache consistency assertion (parial.validfor)
  fails if branchmap.updatecache is called in this time window

This patch leverages the caching infrastructure in place to speed up the
computation of the filteredrevs for visible-directaccess-nowarn and
visible-directaccess-warn. Incidentally it prevents the bug discussed in (2)
from crashing when running a rebase with a bookmark. Note that there still
needs to be a fix in core for the case discussed in (2).

The test for this side of the fix (not core's fix for (2) is very hard to
implement without introducing a lot of dependencies and does not belong
here. It is much easier to have the test of the fix for the scenario (2) in
core along with the fix.
Pierre-Yves David - June 15, 2015, 7:08 p.m.
On 06/15/2015 09:14 AM, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon@fb.com>
> # Date 1434219247 25200
> #      Sat Jun 13 11:14:07 2015 -0700
> # Node ID 96c191101d08412b2c1d5371710bef544f8a41dc
> # Parent  043e5ca9322fc92cd90b9ff3dc462bcbfbd3c095
> directaccess: use cached filteredrevs

Pushed to evolve-main, thanks.

Patch

diff --git a/hgext/directaccess.py b/hgext/directaccess.py
--- a/hgext/directaccess.py
+++ b/hgext/directaccess.py
@@ -30,7 +30,7 @@ 
     repo._explicitaccess = set()
 
 def _computehidden(repo):
-    hidden = repoview.computehidden(repo)
+    hidden = repoview.filterrevs(repo, 'visible')
     cl = repo.changelog
     dynamic = hidden & repo._explicitaccess
     if dynamic: