subrepo: backout 93b0e0db7929 to restore reporelpath()
authorMatt Harbison <matt_harbison@yahoo.com>
Wed, 15 Apr 2015 11:23:26 -0400
changeset 24785 39f519be5e65
parent 24784 59406b8b1303
child 24786 56e15db9109f
subrepo: backout 93b0e0db7929 to restore reporelpath() The path for hgsubrepo needs to be calculated slightly differently from other subrepo types, but can reuse this. See the next patch for details.
mercurial/subrepo.py
--- a/mercurial/subrepo.py	Thu Apr 16 18:48:20 2015 -0500
+++ b/mercurial/subrepo.py	Wed Apr 15 11:23:26 2015 -0400
@@ -271,6 +271,13 @@
                % (subrelpath(sub), local, remote))
     return ui.promptchoice(msg, 0)
 
+def reporelpath(repo):
+    """return path to this (sub)repo as seen from outermost repo"""
+    parent = repo
+    while util.safehasattr(parent, '_subparent'):
+        parent = parent._subparent
+    return repo.root[len(pathutil.normasprefix(parent.root)):]
+
 def subrelpath(sub):
     """return path to this subrepo as seen from outermost repo"""
     return sub._relpath
@@ -551,13 +558,7 @@
     def _relpath(self):
         """return path to this subrepository as seen from outermost repository
         """
-        repo = self._ctx.repo()
-        parent = repo
-        while util.safehasattr(parent, '_subparent'):
-            parent = parent._subparent
-        reporelpath = repo.root[len(pathutil.normasprefix(parent.root)):]
-
-        return self.wvfs.reljoin(reporelpath, self._path)
+        return self.wvfs.reljoin(reporelpath(self._ctx.repo()), self._path)
 
 class hgsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):