comparison mercurial/subrepo.py @ 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
comparison
equal deleted inserted replaced
24671:98ab035e9332 24672:dd0b86f740ef
550 return [] 550 return []
551 551
552 def shortid(self, revid): 552 def shortid(self, revid):
553 return revid 553 return revid
554 554
555 @propertycache
556 def wvfs(self):
557 """return vfs to access the working directory of this subrepository
558 """
559 return scmutil.vfs(self._ctx.repo().wvfs.join(self._path))
560
555 class hgsubrepo(abstractsubrepo): 561 class hgsubrepo(abstractsubrepo):
556 def __init__(self, ctx, path, state): 562 def __init__(self, ctx, path, state):
557 super(hgsubrepo, self).__init__(ctx, path) 563 super(hgsubrepo, self).__init__(ctx, path)
558 self._state = state 564 self._state = state
559 r = ctx.repo() 565 r = ctx.repo()
941 pats = [] 947 pats = []
942 cmdutil.revert(self.ui, self._repo, ctx, parents, *pats, **opts) 948 cmdutil.revert(self.ui, self._repo, ctx, parents, *pats, **opts)
943 949
944 def shortid(self, revid): 950 def shortid(self, revid):
945 return revid[:12] 951 return revid[:12]
952
953 @propertycache
954 def wvfs(self):
955 """return own wvfs for efficiency and consitency
956 """
957 return self._repo.wvfs
946 958
947 class svnsubrepo(abstractsubrepo): 959 class svnsubrepo(abstractsubrepo):
948 def __init__(self, ctx, path, state): 960 def __init__(self, ctx, path, state):
949 super(svnsubrepo, self).__init__(ctx, path) 961 super(svnsubrepo, self).__init__(ctx, path)
950 self._state = state 962 self._state = state