Patchwork D10392: incoming: use `urlutil.get_pull_paths`

login
register
mail settings
Submitter phabricator
Date April 14, 2021, 8:14 a.m.
Message ID <differential-rev-PHID-DREV-3q6y2bphyopc7awz3ant-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48710/
State Superseded
Headers show

Comments

phabricator - April 14, 2021, 8:14 a.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

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

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/hg.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -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:
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4310,19 +4310,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: