changeset 49756:d979c76d6e54

path: allow to copy a path while adjusting the url This will be used by `scheme` in the next changesets.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 02 Dec 2022 18:18:57 +0100
parents 2d11a98db799
children 5f71fff8dc74
files mercurial/utils/urlutil.py
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/utils/urlutil.py	Sat Dec 03 00:19:23 2022 +0100
+++ b/mercurial/utils/urlutil.py	Fri Dec 02 18:18:57 2022 +0100
@@ -878,14 +878,20 @@
         self.rawloc = rawloc
         self.loc = b'%s' % u
 
-    def copy(self):
-        """make a copy of this path object"""
+    def copy(self, new_raw_location=None):
+        """make a copy of this path object
+
+        When `new_raw_location` is set, the new path will point to it.
+        This is used by the scheme extension so expand the scheme.
+        """
         new = self.__class__()
         for k, v in self.__dict__.items():
             new_copy = getattr(v, 'copy', None)
             if new_copy is not None:
                 v = new_copy()
             new.__dict__[k] = v
+        if new_raw_location is not None:
+            new._setup_url(new_raw_location)
         return new
 
     @property