localrepo: grab mixedrepostorecache class from 526750cdd02d stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 20 May 2019 10:08:17 +0200
branchstable
changeset 42323 c2b83c957621
parent 42322 d2c871b78c36
child 42324 2338bdea4474
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.
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Mon May 20 10:06:53 2019 +0200
+++ b/mercurial/localrepo.py	Mon May 20 10:08:17 2019 +0200
@@ -122,6 +122,25 @@
     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