[PATCH 05 of 11] subrepo: add "_cachestorehashvfs" to handle cache store hash files via vfs

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Wed Nov 19 03:41:50 CST 2014


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1416389714 -32400
#      Wed Nov 19 18:35:14 2014 +0900
# Node ID 911845cbabc2d44a434b3974b2534d8593615b35
# Parent  0db575d944ee18c3614b68741c2a7dc45fd38920
subrepo: add "_cachestorehashvfs" to handle cache store hash files via vfs

This "vfs" object will be used by subsequent patches to handle cache
store hash files without direct file APIs.

This patch decorates "_cachestorehashvfs" with "@propertycache" to
delay vfs creation, because it is used only for cooperation with other
repositories.

In this patch, "/" is used as the path separator, even though
"self._repo.join" uses platform specific path separator (e.g. "\\" on
Windows). But it is reasonable enough, because "store" and other
management file handling already include such implementation, and they
work well.

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -566,6 +566,10 @@ class hgsubrepo(abstractsubrepo):
         return self._repo.join(os.path.join(
             'cache', 'storehash', _getstorehashcachename(remotepath)))
 
+    @propertycache
+    def _cachestorehashvfs(self):
+        return scmutil.vfs(self._repo.join('cache/storehash'))
+
     def _readstorehashcache(self, remotepath):
         '''read the store hash cache for a given remote repository'''
         cachefile = self._getstorehashcachepath(remotepath)


More information about the Mercurial-devel mailing list