changeset 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 c4731eee1c8f
children 0acefbbcc82a
files mercurial/utils/urlutil.py
diffstat 1 files changed, 18 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- 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__()