mercurial/utils/urlutil.py
changeset 47185 a2632ce1f15b
parent 47030 c2b5365aa827
child 47186 26b3953ba1b0
equal deleted inserted replaced
47184:9c4d30b079e0 47185:a2632ce1f15b
   705 
   705 
   706 
   706 
   707 class path(object):
   707 class path(object):
   708     """Represents an individual path and its configuration."""
   708     """Represents an individual path and its configuration."""
   709 
   709 
   710     def __init__(self, ui, name, rawloc=None, suboptions=None):
   710     def __init__(self, ui=None, name=None, rawloc=None, suboptions=None):
   711         """Construct a path from its config options.
   711         """Construct a path from its config options.
   712 
   712 
   713         ``ui`` is the ``ui`` instance the path is coming from.
   713         ``ui`` is the ``ui`` instance the path is coming from.
   714         ``name`` is the symbolic name of the path.
   714         ``name`` is the symbolic name of the path.
   715         ``rawloc`` is the raw location, as defined in the config.
   715         ``rawloc`` is the raw location, as defined in the config.
   717 
   717 
   718         If ``name`` is not defined, we require that the location be a) a local
   718         If ``name`` is not defined, we require that the location be a) a local
   719         filesystem path with a .hg directory or b) a URL. If not,
   719         filesystem path with a .hg directory or b) a URL. If not,
   720         ``ValueError`` is raised.
   720         ``ValueError`` is raised.
   721         """
   721         """
       
   722         if ui is None:
       
   723             # used in copy
       
   724             assert name is None
       
   725             assert rawloc is None
       
   726             assert suboptions is None
       
   727             return
       
   728 
   722         if not rawloc:
   729         if not rawloc:
   723             raise ValueError(b'rawloc must be defined')
   730             raise ValueError(b'rawloc must be defined')
   724 
   731 
   725         # Locations may define branches via syntax <base>#<branch>.
   732         # Locations may define branches via syntax <base>#<branch>.
   726         u = url(rawloc)
   733         u = url(rawloc)
   772                 self.rawloc = b'%s#%s' % (base, self.branch)
   779                 self.rawloc = b'%s#%s' % (base, self.branch)
   773             suboptions = subpath._all_sub_opts.copy()
   780             suboptions = subpath._all_sub_opts.copy()
   774             suboptions.update(self._own_sub_opts)
   781             suboptions.update(self._own_sub_opts)
   775             self._apply_suboptions(ui, suboptions)
   782             self._apply_suboptions(ui, suboptions)
   776 
   783 
       
   784     def copy(self):
       
   785         """make a copy of this path object"""
       
   786         new = self.__class__()
       
   787         for k, v in self.__dict__.items():
       
   788             new_copy = getattr(v, 'copy', None)
       
   789             if new_copy is not None:
       
   790                 v = new_copy()
       
   791             new.__dict__[k] = v
       
   792         return new
       
   793 
   777     def _validate_path(self):
   794     def _validate_path(self):
   778         # When given a raw location but not a symbolic name, validate the
   795         # When given a raw location but not a symbolic name, validate the
   779         # location is valid.
   796         # location is valid.
   780         if (
   797         if (
   781             not self.name
   798             not self.name