Patchwork [1,of,4] check-exec: write file in 'wcache' instead of 'cache'

login
register
mail settings
Submitter Boris Feld
Date Dec. 3, 2018, 8:46 a.m.
Message ID <82bb348c50f81208bc58.1543826817@pc62.home>
Download mbox | patch
Permalink /patch/36912/
State Accepted
Headers show

Comments

Boris Feld - Dec. 3, 2018, 8:46 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1542298103 -3600
#      Thu Nov 15 17:08:23 2018 +0100
# Node ID 82bb348c50f81208bc58d85b1c9057eb091867a0
# Parent  0800d9e6e216b2ca59f05788b288685b8d7b2d93
# EXP-Topic wcache
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 82bb348c50f8
check-exec: write file in 'wcache' instead of 'cache'

Some cache are relevant or affected by the working copy used. So the `.hg/cache`
directory is not the best place for them because multiple shared repository can
end up fighting over them.

To address this issue, we introduce a new 'wcache' directory to host this kind
of cache.

The first user are the `checkisexec` type file. These files describe property of
the working copy and fit the use-case well.

Patch

diff --git a/mercurial/posix.py b/mercurial/posix.py
--- a/mercurial/posix.py
+++ b/mercurial/posix.py
@@ -182,7 +182,7 @@  def checkexec(path):
     try:
         EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
         basedir = os.path.join(path, '.hg')
-        cachedir = os.path.join(basedir, 'cache')
+        cachedir = os.path.join(basedir, 'wcache')
         storedir = os.path.join(basedir, 'store')
         if not os.path.exists(cachedir):
             try:
@@ -255,7 +255,7 @@  def checklink(path):
     # mktemp is not racy because symlink creation will fail if the
     # file already exists
     while True:
-        cachedir = os.path.join(path, '.hg', 'cache')
+        cachedir = os.path.join(path, '.hg', 'wcache')
         checklink = os.path.join(cachedir, 'checklink')
         # try fast path, read only
         if os.path.islink(checklink):
diff --git a/tests/test-clone.t b/tests/test-clone.t
--- a/tests/test-clone.t
+++ b/tests/test-clone.t
@@ -43,10 +43,6 @@  Trigger branchcache creation:
   default                       10:a7949464abda
   $ ls .hg/cache
   branch2-served
-  checkisexec (execbit !)
-  checklink (symlink !)
-  checklink-target (symlink !)
-  checknoexec (execbit !)
   manifestfulltextcache (reporevlogstore !)
   rbc-names-v1
   rbc-revs-v1
@@ -62,9 +58,6 @@  Ensure branchcache got copied over:
 
   $ ls .hg/cache
   branch2-served
-  checkisexec (execbit !)
-  checklink (symlink !)
-  checklink-target (symlink !)
   rbc-names-v1
   rbc-revs-v1
 
diff --git a/tests/test-fncache.t b/tests/test-fncache.t
--- a/tests/test-fncache.t
+++ b/tests/test-fncache.t
@@ -88,9 +88,6 @@  Non store repo:
   .hg/00manifest.i
   .hg/cache
   .hg/cache/branch2-served
-  .hg/cache/checkisexec (execbit !)
-  .hg/cache/checklink (symlink !)
-  .hg/cache/checklink-target (symlink !)
   .hg/cache/manifestfulltextcache (reporevlogstore !)
   .hg/cache/rbc-names-v1
   .hg/cache/rbc-revs-v1
@@ -110,6 +107,10 @@  Non store repo:
   .hg/undo.desc
   .hg/undo.dirstate
   .hg/undo.phaseroots
+  .hg/wcache
+  .hg/wcache/checkisexec
+  .hg/wcache/checklink
+  .hg/wcache/checklink-target
   $ cd ..
 
 Non fncache repo:
@@ -125,9 +126,6 @@  Non fncache repo:
   .hg/00changelog.i
   .hg/cache
   .hg/cache/branch2-served
-  .hg/cache/checkisexec (execbit !)
-  .hg/cache/checklink (symlink !)
-  .hg/cache/checklink-target (symlink !)
   .hg/cache/manifestfulltextcache (reporevlogstore !)
   .hg/cache/rbc-names-v1
   .hg/cache/rbc-revs-v1
@@ -150,6 +148,10 @@  Non fncache repo:
   .hg/undo.branch
   .hg/undo.desc
   .hg/undo.dirstate
+  .hg/wcache
+  .hg/wcache/checkisexec
+  .hg/wcache/checklink
+  .hg/wcache/checklink-target
   $ cd ..
 
 Encoding of reserved / long paths in the store
diff --git a/tests/test-hardlinks.t b/tests/test-hardlinks.t
--- a/tests/test-hardlinks.t
+++ b/tests/test-hardlinks.t
@@ -239,9 +239,6 @@  r4 has hardlinks in the working dir (not
   2 r4/.hg/branch
   2 r4/.hg/cache/branch2-base
   2 r4/.hg/cache/branch2-served
-  2 r4/.hg/cache/checkisexec (execbit !)
-  ? r4/.hg/cache/checklink-target (glob) (symlink !)
-  2 r4/.hg/cache/checknoexec (execbit !)
   2 r4/.hg/cache/manifestfulltextcache (reporevlogstore !)
   2 r4/.hg/cache/rbc-names-v1
   2 r4/.hg/cache/rbc-revs-v1
@@ -268,6 +265,9 @@  r4 has hardlinks in the working dir (not
   2 r4/.hg/undo.branch
   2 r4/.hg/undo.desc
   [24] r4/\.hg/undo\.dirstate (re)
+  2 r4/.hg/wcache/checkisexec
+  2 r4/.hg/wcache/checklink-target
+  2 r4/.hg/wcache/checknoexec
   2 r4/d1/data1
   2 r4/d1/f2
   2 r4/f1
@@ -290,9 +290,6 @@  Update back to revision 12 in r4 should 
   1 r4/.hg/branch
   2 r4/.hg/cache/branch2-base
   2 r4/.hg/cache/branch2-served
-  2 r4/.hg/cache/checkisexec (execbit !)
-  2 r4/.hg/cache/checklink-target (symlink !)
-  2 r4/.hg/cache/checknoexec (execbit !)
   2 r4/.hg/cache/manifestfulltextcache (reporevlogstore !)
   2 r4/.hg/cache/rbc-names-v1
   2 r4/.hg/cache/rbc-revs-v1
@@ -319,6 +316,9 @@  Update back to revision 12 in r4 should 
   2 r4/.hg/undo.branch
   2 r4/.hg/undo.desc
   [24] r4/\.hg/undo\.dirstate (re)
+  2 r4/.hg/wcache/checkisexec
+  2 r4/.hg/wcache/checklink-target
+  2 r4/.hg/wcache/checknoexec
   2 r4/d1/data1
   2 r4/d1/f2
   1 r4/f1
diff --git a/tests/test-inherit-mode.t b/tests/test-inherit-mode.t
--- a/tests/test-inherit-mode.t
+++ b/tests/test-inherit-mode.t
@@ -69,9 +69,6 @@  new directories are setgid
   00600 ./.hg/00changelog.i
   00770 ./.hg/cache/
   00660 ./.hg/cache/branch2-served
-  00711 ./.hg/cache/checkisexec
-  00777 ./.hg/cache/checklink
-  00600 ./.hg/cache/checklink-target
   00660 ./.hg/cache/manifestfulltextcache (reporevlogstore !)
   00660 ./.hg/cache/rbc-names-v1
   00660 ./.hg/cache/rbc-revs-v1
@@ -102,6 +99,10 @@  new directories are setgid
   00660 ./.hg/undo.branch
   00660 ./.hg/undo.desc
   00660 ./.hg/undo.dirstate
+  00770 ./.hg/wcache/
+  00711 ./.hg/wcache/checkisexec
+  00777 ./.hg/wcache/checklink
+  00600 ./.hg/wcache/checklink-target
   00700 ./dir/
   00600 ./dir/bar
   00600 ./foo
diff --git a/tests/test-share.t b/tests/test-share.t
--- a/tests/test-share.t
+++ b/tests/test-share.t
@@ -28,16 +28,15 @@  share shouldn't have a full cache dir, o
   default                        0:d3873e73d99e
   $ hg tags
   tip                                0:d3873e73d99e
-  $ ls -1 .hg/cache || true
-  ls: .hg/cache: $ENOENT$ (no-execbit no-symlink !)
+  $ test -d .hg/cache
+  [1]
+  $ ls -1 .hg/wcache || true
+  ls: .hg/wcache: $ENOENT$ (no-execbit no-symlink !)
   checkisexec (execbit !)
   checklink (symlink !)
   checklink-target (symlink !)
   $ ls -1 ../repo1/.hg/cache
   branch2-served
-  checkisexec (execbit !)
-  checklink (symlink !)
-  checklink-target (symlink !)
   manifestfulltextcache (reporevlogstore !)
   rbc-names-v1
   rbc-revs-v1
diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
--- a/tests/test-subrepo.t
+++ b/tests/test-subrepo.t
@@ -1246,15 +1246,16 @@  Check that share works with subrepo
   ../shared/subrepo-2/.hg
   ../shared/subrepo-2/.hg/branch
   ../shared/subrepo-2/.hg/cache
-  ../shared/subrepo-2/.hg/cache/checkisexec (execbit !)
-  ../shared/subrepo-2/.hg/cache/checklink (symlink !)
-  ../shared/subrepo-2/.hg/cache/checklink-target (symlink !)
   ../shared/subrepo-2/.hg/cache/storehash
   ../shared/subrepo-2/.hg/cache/storehash/* (glob)
   ../shared/subrepo-2/.hg/dirstate
   ../shared/subrepo-2/.hg/hgrc
   ../shared/subrepo-2/.hg/requires
   ../shared/subrepo-2/.hg/sharedpath
+  ../shared/subrepo-2/.hg/wcache
+  ../shared/subrepo-2/.hg/wcache/checkisexec
+  ../shared/subrepo-2/.hg/wcache/checklink
+  ../shared/subrepo-2/.hg/wcache/checklink-target
   ../shared/subrepo-2/file
   $ hg -R ../shared in
   abort: repository default not found!
diff --git a/tests/test-tags.t b/tests/test-tags.t
--- a/tests/test-tags.t
+++ b/tests/test-tags.t
@@ -698,9 +698,6 @@  Missing tags2* files means the cache was
 
   $ ls tagsclient/.hg/cache
   branch2-base
-  checkisexec (execbit !)
-  checklink (symlink !)
-  checklink-target (symlink !)
   hgtagsfnodes1
   rbc-names-v1
   rbc-revs-v1
@@ -725,9 +722,6 @@  Running hg tags should produce tags2* fi
 
   $ ls tagsclient/.hg/cache
   branch2-base
-  checkisexec (execbit !)
-  checklink (symlink !)
-  checklink-target (symlink !)
   hgtagsfnodes1
   rbc-names-v1
   rbc-revs-v1