path: add a `get_clone_path_obj` function
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 02 Dec 2022 16:30:48 +0100
changeset 49740 53ad92b20556
parent 49739 ffe8dd945f19
child 49741 2aaa5d1e57e9
path: add a `get_clone_path_obj` function Same logic as the `get_unique_pull_path_obj` function, this give access to the `path` object directly.
mercurial/utils/urlutil.py
--- a/mercurial/utils/urlutil.py	Fri Dec 02 03:56:23 2022 +0100
+++ b/mercurial/utils/urlutil.py	Fri Dec 02 16:30:48 2022 +0100
@@ -581,13 +581,20 @@
     return parseurl(path.rawloc, default_branches)
 
 
+def get_clone_path_obj(ui, source):
+    """return the `(origsource, url, branch)` selected as clone source"""
+    if source == b'':
+        return None
+    return get_unique_pull_path_obj(b'clone', ui, source=source)
+
+
 def get_clone_path(ui, source, default_branches=None):
     """return the `(origsource, url, branch)` selected as clone source"""
+    path = get_clone_path_obj(ui, source)
+    if path is None:
+        return (b'', b'', (None, default_branches))
     if default_branches is None:
         default_branches = []
-    if source == b'':
-        return (b'', b'', (None, default_branches))
-    path = get_unique_pull_path_obj(b'clone', ui, source=source)
     branches = (path.branch, default_branches)
     return path.rawloc, path.loc, branches