Patchwork [8,of,8] share: share 'cachevfs' with the source clone (issue5108)

login
register
mail settings
Submitter Boris Feld
Date July 16, 2017, 8:47 a.m.
Message ID <18baeb5c7d7358d87097.1500194873@FB>
Download mbox | patch
Permalink /patch/22432/
State Accepted
Headers show

Comments

Boris Feld - July 16, 2017, 8:47 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1500155362 -7200
#      Sat Jul 15 23:49:22 2017 +0200
# Node ID 18baeb5c7d7358d87097fbee9b5b370ff4a55f76
# Parent  ade3b656f808205bbe66f8a18bef34d545ad03f3
# EXP-Topic cachevfs
share: share 'cachevfs' with the source clone (issue5108)

Share extension now also share caches reads and writes. Not sharing caches
results in costly caches recomputations which can takes up to minutes when
using shares on large repositories.

There are a couple of file in the '.hg/cache/' that depends of the current
visibility. Visibility can be affected by the working copy location, something
which is specific to each share. We ignores them for this series because they:

* are the minority,
* already have a good fallback to other precomputed caches,
* are only affected when people use the experimental evolution feature.
Augie Fackler - July 17, 2017, 2:31 p.m.
On Sun, Jul 16, 2017 at 10:47:53AM +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1500155362 -7200
> #      Sat Jul 15 23:49:22 2017 +0200
> # Node ID 18baeb5c7d7358d87097fbee9b5b370ff4a55f76
> # Parent  ade3b656f808205bbe66f8a18bef34d545ad03f3
> # EXP-Topic cachevfs
> share: share 'cachevfs' with the source clone (issue5108)

queued, thanks

Very nice.

Patch

diff -r ade3b656f808 -r 18baeb5c7d73 mercurial/localrepo.py
--- a/mercurial/localrepo.py	Sat Jul 15 23:05:15 2017 +0200
+++ b/mercurial/localrepo.py	Sat Jul 15 23:49:22 2017 +0200
@@ -402,12 +402,14 @@ 
                 if inst.errno != errno.ENOENT:
                     raise
 
+        cachepath = self.vfs.join('cache')
         self.sharedpath = self.path
         try:
             sharedpath = self.vfs.read("sharedpath").rstrip('\n')
             if 'relshared' in self.requirements:
                 sharedpath = self.vfs.join(sharedpath)
             vfs = vfsmod.vfs(sharedpath, realpath=True)
+            cachepath = vfs.join('cache')
             s = vfs.base
             if not vfs.exists():
                 raise error.RepoError(
@@ -423,7 +425,7 @@ 
         self.svfs = self.store.vfs
         self.sjoin = self.store.join
         self.vfs.createmode = self.store.createmode
-        self.cachevfs = vfsmod.vfs(self.vfs.join('cache'))
+        self.cachevfs = vfsmod.vfs(cachepath)
         self.cachevfs.createmode = self.store.createmode
         if (self.ui.configbool('devel', 'all-warnings') or
             self.ui.configbool('devel', 'check-locks')):
diff -r ade3b656f808 -r 18baeb5c7d73 tests/test-share.t
--- a/tests/test-share.t	Sat Jul 15 23:05:15 2017 +0200
+++ b/tests/test-share.t	Sat Jul 15 23:49:22 2017 +0200
@@ -24,6 +24,20 @@ 
   $ test -d .hg/store
   [1]
 
+share shouldn't have a cache dir, original repo should
+
+  $ hg branches
+  default                        0:d3873e73d99e
+  $ hg tags
+  tip                                0:d3873e73d99e
+  $ test -d .hg/cache
+  [1]
+  $ ls -1 ../repo1/.hg/cache
+  branch2-served
+  rbc-names-v1
+  rbc-revs-v1
+  tags2-visible
+
 Some sed versions appends newline, some don't, and some just fails
 
   $ cat .hg/sharedpath; echo