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.
--- a/mercurial/utils/urlutil.py Tue Nov 29 22:22:18 2022 +0100
+++ b/mercurial/utils/urlutil.py Thu Dec 01 01:27:47 2022 +0100
@@ -864,6 +864,24 @@
if not rawloc:
raise ValueError(b'rawloc must be defined')
+ self.name = name
+
+ # set by path variant to point to their "non-push" version
+ self._setup_url(rawloc)
+
+ if validate_path:
+ self._validate_path()
+
+ _path, sub_opts = ui.configsuboptions(b'paths', b'*')
+ self._own_sub_opts = {}
+ if suboptions is not None:
+ self._own_sub_opts = suboptions.copy()
+ sub_opts.update(suboptions)
+ self._all_sub_opts = sub_opts.copy()
+
+ self._apply_suboptions(ui, sub_opts)
+
+ def _setup_url(self, rawloc):
# Locations may define branches via syntax <base>#<branch>.
u = url(rawloc)
branch = None
@@ -876,22 +894,9 @@
self.raw_url = u.copy()
self.branch = branch
- self.name = name
self.rawloc = rawloc
self.loc = b'%s' % u
- if validate_path:
- self._validate_path()
-
- _path, sub_opts = ui.configsuboptions(b'paths', b'*')
- self._own_sub_opts = {}
- if suboptions is not None:
- self._own_sub_opts = suboptions.copy()
- sub_opts.update(suboptions)
- self._all_sub_opts = sub_opts.copy()
-
- self._apply_suboptions(ui, sub_opts)
-
def copy(self):
"""make a copy of this path object"""
new = self.__class__()