Patchwork [2,of,3,STABLE] localrepo: grab mixedrepostorecache class from 526750cdd02d

login
register
mail settings
Submitter Pierre-Yves David
Date May 20, 2019, 9:05 a.m.
Message ID <9718a6d6c37cd2789361.1558343106@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/40143/
State Accepted
Headers show

Comments

Pierre-Yves David - May 20, 2019, 9:05 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1558339697 -7200
#      Mon May 20 10:08:17 2019 +0200
# Branch stable
# Node ID 9718a6d6c37cd2789361943d9b0ba5d81f97427a
# Parent  6ae29f52d1f01cf5d603fcee713bc08ab4840d3c
# EXP-Topic book-race
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 9718a6d6c37c
localrepo: grab mixedrepostorecache class from 526750cdd02d

On default, Martin von Zweigbergk <martinvonz@google.com> introduced a more
advance filecache decorator. I need this decorator to fix a bug on stable. So I
am grafting the relevant part of 526750cdd02d.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -122,6 +122,25 @@  class storecache(_basefilecache):
     def join(self, obj, fname):
         return obj.sjoin(fname)
 
+class mixedrepostorecache(_basefilecache):
+    """filecache for a mix files in .hg/store and outside"""
+    def __init__(self, *pathsandlocations):
+        # scmutil.filecache only uses the path for passing back into our
+        # join(), so we can safely pass a list of paths and locations
+        super(mixedrepostorecache, self).__init__(*pathsandlocations)
+        for path, location in pathsandlocations:
+            _cachedfiles.update(pathsandlocations)
+
+    def join(self, obj, fnameandlocation):
+        fname, location = fnameandlocation
+        if location == '':
+            return obj.vfs.join(fname)
+        else:
+            if location != 'store':
+                raise error.ProgrammingError('unexpected location: %s' %
+                                             location)
+            return obj.sjoin(fname)
+
 def isfilecached(repo, name):
     """check if a repo has already cached "name" filecache-ed property