Mercurial > public > mercurial-scm > hg
comparison mercurial/posix.py @ 40670:bd0874977a5e stable
checkexec: create destination directory if necessary
Since 460733327640, a "share" use the cache of the source repository. A side
effect is that no `.hg/cache` directory exists in the "share" anymore. As a
result, the checkexec logic can't use it to create its temporary file and have
to use the working copy for that.
This is suboptimal, it pollutes the working copy and prevents them to keep the
file around in cache. We do not want to use the cache directory for the share
target, it might be on a different file system.
So instead, we (try to) create the directory if it is missing. This is a
simple change that fixes the current behavior regression on stable.
On default, we should probably ensure the proper directories are created when
initializing the repository. We should also introduce a 'wcache' directory to
hold cache file related to the working copy. This would clarify the cache
situation regarding shares.
The tests catch a couple of other affected cases.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Thu, 15 Nov 2018 03:09:23 +0100 |
parents | 5fe0b880200e |
children | 47e3f554df35 |
comparison
equal
deleted
inserted
replaced
40656:3bc2e550f2bd | 40670:bd0874977a5e |
---|---|
179 # a FS remount. Frequently we can detect it if files are created | 179 # a FS remount. Frequently we can detect it if files are created |
180 # with exec bit on. | 180 # with exec bit on. |
181 | 181 |
182 try: | 182 try: |
183 EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH | 183 EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH |
184 cachedir = os.path.join(path, '.hg', 'cache') | 184 basedir = os.path.join(path, '.hg') |
185 cachedir = os.path.join(basedir, 'cache') | |
186 storedir = os.path.join(basedir, 'store') | |
187 if not os.path.exists(cachedir): | |
188 try: | |
189 # we want to create the 'cache' directory, not the '.hg' one. | |
190 # Automatically creating '.hg' directory could silently spawn | |
191 # invalid Mercurial repositories. That seems like a bad idea. | |
192 os.mkdir(cachedir) | |
193 if os.path.exists(storedir): | |
194 copymode(storedir, cachedir) | |
195 else: | |
196 copymode(basedir, cachedir) | |
197 except (IOError, OSError): | |
198 # we other fallback logic triggers | |
199 pass | |
185 if os.path.isdir(cachedir): | 200 if os.path.isdir(cachedir): |
186 checkisexec = os.path.join(cachedir, 'checkisexec') | 201 checkisexec = os.path.join(cachedir, 'checkisexec') |
187 checknoexec = os.path.join(cachedir, 'checknoexec') | 202 checknoexec = os.path.join(cachedir, 'checknoexec') |
188 | 203 |
189 try: | 204 try: |