Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/utils/urlutil.py @ 46934:ebb13f9a9ba8
urlutil: add a `get_clone_path` function
We add a new function with a semantic focussed on `clone` operation (so without
an existing repository). I am not certain the return type is the best, but this
is what we need for now. Once all caller are migrated we might start thinking
about that the API should be. For now that will do.
Differential Revision: https://phab.mercurial-scm.org/D10401
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 14 Apr 2021 10:35:40 +0200 |
parents | 93c224dc099b |
children | 1998a8311c48 |
comparison
equal
deleted
inserted
replaced
46933:9519312ecd81 | 46934:ebb13f9a9ba8 |
---|---|
469 for source in sources: | 469 for source in sources: |
470 url = ui.expandpath(source) | 470 url = ui.expandpath(source) |
471 yield parseurl(url, default_branches) | 471 yield parseurl(url, default_branches) |
472 | 472 |
473 | 473 |
474 def get_clone_path(ui, source, default_branches=()): | |
475 """return the `(origsource, path, branch)` selected as clone source""" | |
476 url = ui.expandpath(source) | |
477 path, branch = parseurl(url, default_branches) | |
478 return url, path, branch | |
479 | |
480 | |
474 def parseurl(path, branches=None): | 481 def parseurl(path, branches=None): |
475 '''parse url#branch, returning (url, (branch, branches))''' | 482 '''parse url#branch, returning (url, (branch, branches))''' |
476 u = url(path) | 483 u = url(path) |
477 branch = None | 484 branch = None |
478 if u.fragment: | 485 if u.fragment: |