comparison mercurial/utils/urlutil.py @ 49868: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 53ad92b20556
children 20f262ab6fd3
comparison
equal deleted inserted replaced
49867:2d11a98db799 49868:d979c76d6e54
876 self.branch = branch 876 self.branch = branch
877 877
878 self.rawloc = rawloc 878 self.rawloc = rawloc
879 self.loc = b'%s' % u 879 self.loc = b'%s' % u
880 880
881 def copy(self): 881 def copy(self, new_raw_location=None):
882 """make a copy of this path object""" 882 """make a copy of this path object
883
884 When `new_raw_location` is set, the new path will point to it.
885 This is used by the scheme extension so expand the scheme.
886 """
883 new = self.__class__() 887 new = self.__class__()
884 for k, v in self.__dict__.items(): 888 for k, v in self.__dict__.items():
885 new_copy = getattr(v, 'copy', None) 889 new_copy = getattr(v, 'copy', None)
886 if new_copy is not None: 890 if new_copy is not None:
887 v = new_copy() 891 v = new_copy()
888 new.__dict__[k] = v 892 new.__dict__[k] = v
893 if new_raw_location is not None:
894 new._setup_url(new_raw_location)
889 return new 895 return new
890 896
891 @property 897 @property
892 def is_push_variant(self): 898 def is_push_variant(self):
893 """is this a path variant to be used for pushing""" 899 """is this a path variant to be used for pushing"""