mercurial/subrepoutil.py
changeset 46929 5a59a0ed0a37
parent 46907 ffd3e823a7e5
child 47629 5cf2059d2647
--- a/mercurial/subrepoutil.py	Wed Apr 14 22:50:41 2021 -0400
+++ b/mercurial/subrepoutil.py	Thu Apr 15 09:23:19 2021 +0200
@@ -383,6 +383,24 @@
     return subs, commitsubs, newstate
 
 
+def repo_rel_or_abs_source(repo):
+    """return the source of this repo
+
+    Either absolute or relative the outermost repo"""
+    parent = repo
+    chunks = []
+    while util.safehasattr(parent, b'_subparent'):
+        source = urlutil.url(parent._subsource)
+        chunks.append(bytes(source))
+        if source.isabs():
+            break
+        parent = parent._subparent
+
+    chunks.reverse()
+    path = posixpath.join(*chunks)
+    return posixpath.normpath(path)
+
+
 def reporelpath(repo):
     # type: (localrepo.localrepository) -> bytes
     """return path to this (sub)repo as seen from outermost repo"""