D11673: path: return path instance directly from get_pull_paths
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Fri Oct 15 08:19:46 UTC 2021
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
This means the caller has to do a bit more work, however it give access to the
`path` instance and the information it contains.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D11673
AFFECTED FILES
mercurial/commands.py
mercurial/hg.py
mercurial/utils/urlutil.py
CHANGE DETAILS
diff --git a/mercurial/utils/urlutil.py b/mercurial/utils/urlutil.py
--- a/mercurial/utils/urlutil.py
+++ b/mercurial/utils/urlutil.py
@@ -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):
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -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():
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -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)
To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list