# HG changeset patch # User Pierre-Yves David # Date 2022-12-02 17:18:57 # Node ID d979c76d6e542dd058de6a47ce39cb2aac979d41 # Parent 2d11a98db79981623fba9e2d4c76d73828f5fff4 path: allow to copy a path while adjusting the url This will be used by `scheme` in the next changesets. diff --git a/mercurial/utils/urlutil.py b/mercurial/utils/urlutil.py --- a/mercurial/utils/urlutil.py +++ b/mercurial/utils/urlutil.py @@ -878,14 +878,20 @@ class path: 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