changeset 24672:dd0b86f740ef

subrepo: add wvfs field to access the working directory via vfs This patch doesn't create vfs object in "abstractsubrepo.__init__()" but adds propertycache-ed "wvfs" field, because the latter can: - delay vfs instantiation until it is actually needed - allow to use "hgsubrepo._repo.wvfs" as "wvfs" "hgsubrepo._repo" is initialized after "abstractsubrepo.__init__()" invocation, and passing "hgsubrepo._repo.wvfs" to "abstractsubrepo.__init__()" is difficult.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Fri, 10 Apr 2015 00:36:42 +0900
parents 98ab035e9332
children 105758d1b37b
files mercurial/subrepo.py
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Fri Apr 10 00:36:42 2015 +0900
+++ b/mercurial/subrepo.py	Fri Apr 10 00:36:42 2015 +0900
@@ -552,6 +552,12 @@
     def shortid(self, revid):
         return revid
 
+    @propertycache
+    def wvfs(self):
+        """return vfs to access the working directory of this subrepository
+        """
+        return scmutil.vfs(self._ctx.repo().wvfs.join(self._path))
+
 class hgsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):
         super(hgsubrepo, self).__init__(ctx, path)
@@ -944,6 +950,12 @@
     def shortid(self, revid):
         return revid[:12]
 
+    @propertycache
+    def wvfs(self):
+        """return own wvfs for efficiency and consitency
+        """
+        return self._repo.wvfs
+
 class svnsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):
         super(svnsubrepo, self).__init__(ctx, path)