mercurial/subrepo.py
changeset 24673 105758d1b37b
parent 24672 dd0b86f740ef
child 24674 93b0e0db7929
--- a/mercurial/subrepo.py	Fri Apr 10 00:36:42 2015 +0900
+++ b/mercurial/subrepo.py	Fri Apr 10 00:36:42 2015 +0900
@@ -280,11 +280,7 @@
 
 def subrelpath(sub):
     """return path to this subrepo as seen from outermost repo"""
-    if util.safehasattr(sub, '_relpath'):
-        return sub._relpath
-    if not util.safehasattr(sub, '_repo'):
-        return sub._path
-    return reporelpath(sub._repo)
+    return sub._relpath
 
 def _abssource(repo, push=False, abort=True):
     """return pull/push path of repo - either based on parent repo .hgsub info
@@ -558,6 +554,12 @@
         """
         return scmutil.vfs(self._ctx.repo().wvfs.join(self._path))
 
+    @propertycache
+    def _relpath(self):
+        """return path to this subrepository as seen from outermost repository
+        """
+        return self.wvfs.reljoin(reporelpath(self._ctx.repo()), self._path)
+
 class hgsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):
         super(hgsubrepo, self).__init__(ctx, path)
@@ -1188,7 +1190,6 @@
     def __init__(self, ctx, path, state):
         super(gitsubrepo, self).__init__(ctx, path)
         self._state = state
-        self._relpath = os.path.join(reporelpath(ctx.repo()), path)
         self._abspath = ctx.repo().wjoin(path)
         self._subparent = ctx.repo()
         self._ensuregit()