Mercurial > hg
changeset 46964:221f8585e985
urlutil: remove usage of `ui.expandpath` in `get_clone_path`
We want to deprecate `ui.expandpath` and simplify the code before adding more
complexity in the form of `[paths]` entry pointing to multiple url. So we inline
the relevant bits.
Differential Revision: https://phab.mercurial-scm.org/D10431
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 14 Apr 2021 21:29:27 +0200 |
parents | 0d8541e53e46 |
children | b03527bdac01 |
files | mercurial/utils/urlutil.py |
diffstat | 1 files changed, 19 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/utils/urlutil.py Wed Apr 14 21:27:00 2021 +0200 +++ b/mercurial/utils/urlutil.py Wed Apr 14 21:29:27 2021 +0200 @@ -530,9 +530,25 @@ def get_clone_path(ui, source, default_branches=()): """return the `(origsource, path, branch)` selected as clone source""" - url = ui.expandpath(source) - path, branch = parseurl(url, default_branches) - return url, path, branch + if source is None: + if b'default' in ui.paths: + url = ui.paths[b'default'].rawloc + else: + # XXX this is the historical default behavior, but that is not + # great, consider breaking BC on this. + url = b'default' + else: + if source in ui.paths: + url = ui.paths[source].rawloc + else: + # Try to resolve as a local path or URI. + try: + # we pass the ui instance are warning might need to be issued + url = path(ui, None, rawloc=source).rawloc + except ValueError: + url = source + clone_path, branch = parseurl(url, default_branches) + return url, clone_path, branch def parseurl(path, branches=None):