Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/utils/urlutil.py @ 46940:368294967c95
urlutil: add a new `get_unique_push_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/D10407
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 14 Apr 2021 11:57:20 +0200 |
parents | 1998a8311c48 |
children | afdd7c472ef2 |
comparison
equal
deleted
inserted
replaced
46939:b133154f1e7b | 46940:368294967c95 |
---|---|
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_unique_push_path(action, repo, ui, dest=None): | |
475 """return a unique `path` or abort if multiple are found | |
476 | |
477 This is useful for command and action that does not support multiple | |
478 destination (yet). | |
479 | |
480 Note that for now, we cannot get multiple destination so this function is "trivial". | |
481 | |
482 The `action` parameter will be used for the error message. | |
483 """ | |
484 if dest is None: | |
485 dests = [] | |
486 else: | |
487 dests = [dest] | |
488 dests = list(get_push_paths(repo, ui, dests)) | |
489 assert len(dests) == 1 | |
490 return dests[0] | |
491 | |
492 | |
474 def get_unique_pull_path(action, repo, ui, source=None, default_branches=()): | 493 def get_unique_pull_path(action, repo, ui, source=None, default_branches=()): |
475 """return a unique `(path, branch)` or abort if multiple are found | 494 """return a unique `(path, branch)` or abort if multiple are found |
476 | 495 |
477 This is useful for command and action that does not support multiple | 496 This is useful for command and action that does not support multiple |
478 destination (yet). | 497 destination (yet). |