Mercurial > public > mercurial-scm > hg
comparison mercurial/utils/urlutil.py @ 49694:dd62eb4d2ea5
path: move the url parsing and related attribute setting to a method
This will make it simpler to reuse this logic in the next changeset.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 01 Dec 2022 01:27:47 +0100 |
parents | 642e31cb55f0 |
children | 0acefbbcc82a |
comparison
equal
deleted
inserted
replaced
49693:c4731eee1c8f | 49694:dd62eb4d2ea5 |
---|---|
862 return | 862 return |
863 | 863 |
864 if not rawloc: | 864 if not rawloc: |
865 raise ValueError(b'rawloc must be defined') | 865 raise ValueError(b'rawloc must be defined') |
866 | 866 |
867 self.name = name | |
868 | |
869 # set by path variant to point to their "non-push" version | |
870 self._setup_url(rawloc) | |
871 | |
872 if validate_path: | |
873 self._validate_path() | |
874 | |
875 _path, sub_opts = ui.configsuboptions(b'paths', b'*') | |
876 self._own_sub_opts = {} | |
877 if suboptions is not None: | |
878 self._own_sub_opts = suboptions.copy() | |
879 sub_opts.update(suboptions) | |
880 self._all_sub_opts = sub_opts.copy() | |
881 | |
882 self._apply_suboptions(ui, sub_opts) | |
883 | |
884 def _setup_url(self, rawloc): | |
867 # Locations may define branches via syntax <base>#<branch>. | 885 # Locations may define branches via syntax <base>#<branch>. |
868 u = url(rawloc) | 886 u = url(rawloc) |
869 branch = None | 887 branch = None |
870 if u.fragment: | 888 if u.fragment: |
871 branch = u.fragment | 889 branch = u.fragment |
874 self.url = u | 892 self.url = u |
875 # the url from the config/command line before dealing with `path://` | 893 # the url from the config/command line before dealing with `path://` |
876 self.raw_url = u.copy() | 894 self.raw_url = u.copy() |
877 self.branch = branch | 895 self.branch = branch |
878 | 896 |
879 self.name = name | |
880 self.rawloc = rawloc | 897 self.rawloc = rawloc |
881 self.loc = b'%s' % u | 898 self.loc = b'%s' % u |
882 | |
883 if validate_path: | |
884 self._validate_path() | |
885 | |
886 _path, sub_opts = ui.configsuboptions(b'paths', b'*') | |
887 self._own_sub_opts = {} | |
888 if suboptions is not None: | |
889 self._own_sub_opts = suboptions.copy() | |
890 sub_opts.update(suboptions) | |
891 self._all_sub_opts = sub_opts.copy() | |
892 | |
893 self._apply_suboptions(ui, sub_opts) | |
894 | 899 |
895 def copy(self): | 900 def copy(self): |
896 """make a copy of this path object""" | 901 """make a copy of this path object""" |
897 new = self.__class__() | 902 new = self.__class__() |
898 for k, v in self.__dict__.items(): | 903 for k, v in self.__dict__.items(): |