incoming: use `urlutil.get_pull_paths`
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 14 Apr 2021 02:14:15 +0200
changeset 46932 dec31caf5fd6
parent 46931 d4e4ccb75f99
child 46933 9519312ecd81
incoming: use `urlutil.get_pull_paths` Lets use the new method to increase code reuse. However I did not implement support for multiple source yet. It would be possible create multiple temporary bundle, but that is a bit too much work outside of my current route to make the detour. Differential Revision: https://phab.mercurial-scm.org/D10392
mercurial/commands.py
mercurial/hg.py
--- a/mercurial/commands.py	Wed Apr 14 01:26:44 2021 +0200
+++ b/mercurial/commands.py	Wed Apr 14 02:14:15 2021 +0200
@@ -4311,19 +4311,20 @@
     cmdutil.check_incompatible_arguments(opts, b'subrepos', [b'bundle'])
 
     if opts.get(b'bookmarks'):
-        source, branches = urlutil.parseurl(
-            ui.expandpath(source), opts.get(b'branch')
-        )
-        other = hg.peer(repo, opts, source)
-        try:
-            if b'bookmarks' not in other.listkeys(b'namespaces'):
-                ui.warn(_(b"remote doesn't support bookmarks\n"))
-                return 0
-            ui.pager(b'incoming')
-            ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(source))
-            return bookmarks.incoming(ui, repo, other)
-        finally:
-            other.close()
+        srcs = urlutil.get_pull_paths(repo, ui, [source], opts.get(b'branch'))
+        for source, branches in srcs:
+            other = hg.peer(repo, opts, source)
+            try:
+                if b'bookmarks' not in other.listkeys(b'namespaces'):
+                    ui.warn(_(b"remote doesn't support bookmarks\n"))
+                    return 0
+                ui.pager(b'incoming')
+                ui.status(
+                    _(b'comparing with %s\n') % urlutil.hidepassword(source)
+                )
+                return bookmarks.incoming(ui, repo, other)
+            finally:
+                other.close()
 
     repo._subtoppath = ui.expandpath(source)
     try:
--- a/mercurial/hg.py	Wed Apr 14 01:26:44 2021 +0200
+++ b/mercurial/hg.py	Wed Apr 14 02:14:15 2021 +0200
@@ -1263,9 +1263,13 @@
         (remoterepo, incomingchangesetlist, displayer) parameters,
     and is supposed to contain only code that can't be unified.
     """
-    source, branches = urlutil.parseurl(
-        ui.expandpath(source), opts.get(b'branch')
-    )
+    srcs = urlutil.get_pull_paths(repo, ui, [source], opts.get(b'branch'))
+    srcs = list(srcs)
+    if len(srcs) != 1:
+        msg = _('for now, incoming supports only a single source, %d provided')
+        msg %= len(srcs)
+        raise error.Abort(msg)
+    source, branches = srcs[0]
     other = peer(repo, opts, source)
     cleanupfn = other.close
     try: