# HG changeset patch # User Pierre-Yves David # Date 1618258976 -7200 # Node ID 067840864f370c72fdfb7de4f0049d370f15dad7 # Parent 4452cb7884042b769202ba58382f49e028ea6c25 urlutil: add a `get_push_paths` to perform the push destination logic As is this changeset does not change anything. However having an official empty point will help unifying the logic and encapsulate the details and update the logic to support path definition pointing to multiple other path. Differential Revision: https://phab.mercurial-scm.org/D10377 diff -r 4452cb788404 -r 067840864f37 mercurial/commands.py --- a/mercurial/commands.py Mon Apr 12 06:34:54 2021 +0200 +++ b/mercurial/commands.py Mon Apr 12 22:22:56 2021 +0200 @@ -5720,12 +5720,9 @@ # this lets simultaneous -r, -b options continue working opts.setdefault(b'rev', []).append(b"null") - if not dests: - dests = [None] some_pushed = False result = 0 - for dest in dests: - path = ui.getpath(dest, default=(b'default-push', b'default')) + for path in urlutil.get_push_paths(repo, ui, dests): if not path: raise error.ConfigError( _(b'default repository not configured!'), diff -r 4452cb788404 -r 067840864f37 mercurial/utils/urlutil.py --- a/mercurial/utils/urlutil.py Mon Apr 12 06:34:54 2021 +0200 +++ b/mercurial/utils/urlutil.py Mon Apr 12 22:22:56 2021 +0200 @@ -445,6 +445,14 @@ return bytes(u) +def get_push_paths(repo, ui, dests): + """yields all the `path` selected as push destination by `dests`""" + if not dests: + dests = [None] + for dest in dests: + yield ui.getpath(dest, default=(b'default-push', b'default')) + + def parseurl(path, branches=None): '''parse url#branch, returning (url, (branch, branches))''' u = url(path)