mercurial/subrepoutil.py
branchstable
changeset 51508 08913487ae80
parent 51286 7bd7fcc711f2
child 51743 586759be47dc
--- a/mercurial/subrepoutil.py	Sat Mar 16 18:37:07 2024 -0300
+++ b/mercurial/subrepoutil.py	Sat Mar 16 21:02:19 2024 -0300
@@ -421,7 +421,18 @@
 
     chunks.reverse()
     path = posixpath.join(*chunks)
-    return posixpath.normpath(path)
+    matchscheme = re.compile(b'^[a-zA-Z0-9+.\\-]+:').match
+    if matchscheme(path):
+        scheme, path = path.split(b':', 1)
+        if path.startswith(b'//'):
+            path = path[2:]
+            sep = b'//'
+        else:
+            sep = b''
+        normalized_path = scheme + b':' + sep + posixpath.normpath(path)
+    else:
+        normalized_path = posixpath.normpath(path)
+    return normalized_path
 
 
 def reporelpath(repo: "localrepo.localrepository") -> bytes: