changeset 48252:607e9322fc89

path: return path instance directly from get_pull_paths This means the caller has to do a bit more work, however it give access to the `path` instance and the information it contains. Differential Revision: https://phab.mercurial-scm.org/D11673
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 15 Oct 2021 02:44:14 +0200
parents 08630dd719f9
children 7d1e60244561
files mercurial/commands.py mercurial/hg.py mercurial/utils/urlutil.py
diffstat 3 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Fri Oct 15 02:36:54 2021 +0200
+++ b/mercurial/commands.py	Fri Oct 15 02:44:14 2021 +0200
@@ -4346,8 +4346,11 @@
     cmdutil.check_incompatible_arguments(opts, b'subrepos', [b'bundle'])
 
     if opts.get(b'bookmarks'):
-        srcs = urlutil.get_pull_paths(repo, ui, [source], opts.get(b'branch'))
-        for source, branches in srcs:
+        srcs = urlutil.get_pull_paths(repo, ui, [source])
+        for path in srcs:
+            source, branches = urlutil.parseurl(
+                path.rawloc, opts.get(b'branch')
+            )
             other = hg.peer(repo, opts, source)
             try:
                 if b'bookmarks' not in other.listkeys(b'namespaces'):
@@ -5393,8 +5396,8 @@
         hint = _(b'use hg pull followed by hg update DEST')
         raise error.InputError(msg, hint=hint)
 
-    sources = urlutil.get_pull_paths(repo, ui, sources, opts.get(b'branch'))
-    for source, branches in sources:
+    for path in urlutil.get_pull_paths(repo, ui, sources):
+        source, branches = urlutil.parseurl(path.rawloc, opts.get(b'branch'))
         ui.status(_(b'pulling from %s\n') % urlutil.hidepassword(source))
         ui.flush()
         other = hg.peer(repo, opts, source)
--- a/mercurial/hg.py	Fri Oct 15 02:36:54 2021 +0200
+++ b/mercurial/hg.py	Fri Oct 15 02:44:14 2021 +0200
@@ -1261,13 +1261,14 @@
         (remoterepo, incomingchangesetlist, displayer) parameters,
     and is supposed to contain only code that can't be unified.
     """
-    srcs = urlutil.get_pull_paths(repo, ui, [source], opts.get(b'branch'))
+    srcs = urlutil.get_pull_paths(repo, ui, [source])
     srcs = list(srcs)
     if len(srcs) != 1:
         msg = _(b'for now, incoming supports only a single source, %d provided')
         msg %= len(srcs)
         raise error.Abort(msg)
-    source, branches = srcs[0]
+    path = srcs[0]
+    source, branches = urlutil.parseurl(path.rawloc, opts.get(b'branch'))
     if subpath is not None:
         subpath = urlutil.url(subpath)
         if subpath.isabs():
--- a/mercurial/utils/urlutil.py	Fri Oct 15 02:36:54 2021 +0200
+++ b/mercurial/utils/urlutil.py	Fri Oct 15 02:44:14 2021 +0200
@@ -503,17 +503,17 @@
                 yield path
 
 
-def get_pull_paths(repo, ui, sources, default_branches=()):
+def get_pull_paths(repo, ui, sources):
     """yields all the `(path, branch)` selected as pull source by `sources`"""
     if not sources:
         sources = [b'default']
     for source in sources:
         if source in ui.paths:
             for p in ui.paths[source]:
-                yield parseurl(p.rawloc, default_branches)
+                yield p
         else:
             p = path(ui, None, source, validate_path=False)
-            yield parseurl(p.rawloc, default_branches)
+            yield p
 
 
 def get_unique_push_path(action, repo, ui, dest=None):