# HG changeset patch # User Pierre-Yves David # Date 1618391754 -7200 # Node ID 1998a8311c4873d2e3ee6290f903ee0e680ca82e # Parent ae4c0f279282cc8838555fef56eaf615df2f6b3b urlutil: add a new `get_unique_pull_path` This function is dedicated to call that needs a single destination. Currently most caller actually need that since few actually support multiple destinations (the most importants `hg push` and `hg outgoing` do). So having a clear API point for that will be important when the time comes to have a single `[paths]` alias resolving to multiple urls. Differential Revision: https://phab.mercurial-scm.org/D10403 diff -r ae4c0f279282 -r 1998a8311c48 mercurial/utils/urlutil.py --- a/mercurial/utils/urlutil.py Wed Apr 14 10:51:31 2021 +0200 +++ b/mercurial/utils/urlutil.py Wed Apr 14 11:15:54 2021 +0200 @@ -471,6 +471,22 @@ yield parseurl(url, default_branches) +def get_unique_pull_path(action, repo, ui, source=None, default_branches=()): + """return a unique `(path, branch)` or abort if multiple are found + + This is useful for command and action that does not support multiple + destination (yet). + + Note that for now, we cannot get multiple destination so this function is "trivial". + + The `action` parameter will be used for the error message. + """ + if source is None: + source = b'default' + url = ui.expandpath(source) + return parseurl(url, default_branches) + + def get_clone_path(ui, source, default_branches=()): """return the `(origsource, path, branch)` selected as clone source""" url = ui.expandpath(source)