Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/utils/urlutil.py @ 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 | c029b35565dd |
comparison
equal
deleted
inserted
replaced
46963:0d8541e53e46 | 46964:221f8585e985 |
---|---|
528 return parseurl(url, default_branches) | 528 return parseurl(url, default_branches) |
529 | 529 |
530 | 530 |
531 def get_clone_path(ui, source, default_branches=()): | 531 def get_clone_path(ui, source, default_branches=()): |
532 """return the `(origsource, path, branch)` selected as clone source""" | 532 """return the `(origsource, path, branch)` selected as clone source""" |
533 url = ui.expandpath(source) | 533 if source is None: |
534 path, branch = parseurl(url, default_branches) | 534 if b'default' in ui.paths: |
535 return url, path, branch | 535 url = ui.paths[b'default'].rawloc |
536 else: | |
537 # XXX this is the historical default behavior, but that is not | |
538 # great, consider breaking BC on this. | |
539 url = b'default' | |
540 else: | |
541 if source in ui.paths: | |
542 url = ui.paths[source].rawloc | |
543 else: | |
544 # Try to resolve as a local path or URI. | |
545 try: | |
546 # we pass the ui instance are warning might need to be issued | |
547 url = path(ui, None, rawloc=source).rawloc | |
548 except ValueError: | |
549 url = source | |
550 clone_path, branch = parseurl(url, default_branches) | |
551 return url, clone_path, branch | |
536 | 552 |
537 | 553 |
538 def parseurl(path, branches=None): | 554 def parseurl(path, branches=None): |
539 '''parse url#branch, returning (url, (branch, branches))''' | 555 '''parse url#branch, returning (url, (branch, branches))''' |
540 u = url(path) | 556 u = url(path) |