Patchwork D10377: urlutil: add a `get_push_paths` to perform the push destination logic

login
register
mail settings
Submitter phabricator
Date April 13, 2021, 12:19 p.m.
Message ID <differential-rev-PHID-DREV-fiavnf2u5etvstcmucwg-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48694/
State Superseded
Headers show

Comments

phabricator - April 13, 2021, 12:19 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10377

AFFECTED FILES
  mercurial/commands.py
  mercurial/utils/urlutil.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/utils/urlutil.py b/mercurial/utils/urlutil.py
--- a/mercurial/utils/urlutil.py
+++ b/mercurial/utils/urlutil.py
@@ -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)
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5719,12 +5719,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!'),