Patchwork [1,of,3,V2] localrepo: warn if we are writing to cache without a lock

login
register
mail settings
Submitter Pulkit Goyal
Date Sept. 10, 2020, 8:08 a.m.
Message ID <5ecbecdc0aa49eb6a387.1599725288@workspace>
Download mbox | patch
Permalink /patch/47121/
State Accepted
Headers show

Comments

Pulkit Goyal - Sept. 10, 2020, 8:08 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1599570961 -19800
#      Tue Sep 08 18:46:01 2020 +0530
# Node ID 5ecbecdc0aa49eb6a3878e01f8aa99417602b957
# Parent  0babbc33baec093b9119be36ec535edb8a12b3b8
# EXP-Topic tags-fix
localrepo: warn if we are writing to cache without a lock

From quite sometime we have two types of cache, `cache` and `wcache`. The later
one is a working copy cache and the first one is a store cache.

Let's add a check for warning if we are missing store lock while writing to
these caches.

This is inspired from some tag cache breakage which is observed when multiple
shares are in play.

The interesting part is that although we are still taking wlock to write store
caches at many places, but still the test pases.

Differential Revision: https://phab.mercurial-scm.org/D9000

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1250,7 +1250,12 @@  class localrepository(object):
                 msg = b'accessing cache with vfs instead of cachevfs: "%s"'
                 repo.ui.develwarn(msg % path, stacklevel=3, config=b"cache-vfs")
             # path prefixes covered by 'lock'
-            vfs_path_prefixes = (b'journal.', b'undo.', b'strip-backup/')
+            vfs_path_prefixes = (
+                b'journal.',
+                b'undo.',
+                b'strip-backup/',
+                b'cache/',
+            )
             if any(path.startswith(prefix) for prefix in vfs_path_prefixes):
                 if repo._currentlock(repo._lockref) is None:
                     repo.ui.develwarn(