Patchwork [2,of,4] cache: create `cache` directory at init time

login
register
mail settings
Submitter Boris Feld
Date Dec. 3, 2018, 8:46 a.m.
Message ID <fd281df3f7f069f59933.1543826818@pc62.home>
Download mbox | patch
Permalink /patch/36911/
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 1542245935 -3600
#      Thu Nov 15 02:38:55 2018 +0100
# Node ID fd281df3f7f069f599335220414e2a5bd712fb1d
# Parent  82bb348c50f81208bc58d85b1c9057eb091867a0
# EXP-Topic wcache
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r fd281df3f7f0
cache: create `cache` directory at init time

The cache directory will be needed very quickly, so it seems simpler to create
it early to make sure it has the same owner and permission than the other
directory in the repository.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -3009,6 +3009,8 @@  def createrepository(ui, path, createopt
         wdirvfs.makedirs()
 
     hgvfs.makedir(notindexed=True)
+    if 'sharedrepo' not in createopts:
+        hgvfs.mkdir(b'cache')
 
     if b'store' in requirements and 'sharedrepo' not in createopts:
         hgvfs.mkdir(b'store')
diff --git a/tests/test-empty.t b/tests/test-empty.t
--- a/tests/test-empty.t
+++ b/tests/test-empty.t
@@ -20,6 +20,7 @@  Check the basic files created:
 
   $ ls .hg
   00changelog.i
+  cache
   requires
   store
 
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
@@ -42,7 +42,7 @@  just in case somebody has a strange $TMP
   $ hg init repo
   $ cd repo
 
-  $ chmod 0770 .hg/store
+  $ chmod 0770 .hg/store .hg/cache
 
 before commit
 store can be written by the group, other files cannot
@@ -51,6 +51,7 @@  store is setgid
   $ "$PYTHON" ../printmodes.py .
   00700 ./.hg/
   00600 ./.hg/00changelog.i
+  00770 ./.hg/cache/
   00600 ./.hg/requires
   00770 ./.hg/store/
 
@@ -116,6 +117,7 @@  group can write everything
   $ "$PYTHON" ../printmodes.py ../push
   00770 ../push/.hg/
   00660 ../push/.hg/00changelog.i
+  00770 ../push/.hg/cache/
   00660 ../push/.hg/requires
   00770 ../push/.hg/store/