Patchwork D10379: infinitepush: use the new function to determine push destination

login
register
mail settings
Submitter phabricator
Date April 13, 2021, 12:19 p.m.
Message ID <differential-rev-PHID-DREV-khbhqy32cyfde2fqwylw-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48695/
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
  Since 066b8d8f75b8 <https://phab.mercurial-scm.org/rHG066b8d8f75b873ecd1b8a1c4633c4a121c95d57d>, the push command accept multiple destination. `infinitepush`
  was not aware of that. We now use the new `urlutil.get_push_paths` function to
  determine the push destination, fixing the issue. This will also make future
  evolution of that logic transparent for infinitepush
  
  We still disallow push to multiple destinations if infinite push is enabled
  because I don't know what this means for infinite push. However user will now
  get a clear error message instead of a crash.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/infinitepush/__init__.py

CHANGE DETAILS




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

Patch

diff --git a/hgext/infinitepush/__init__.py b/hgext/infinitepush/__init__.py
--- a/hgext/infinitepush/__init__.py
+++ b/hgext/infinitepush/__init__.py
@@ -811,7 +811,7 @@ 
     return common, True, remoteheads
 
 
-def _push(orig, ui, repo, dest=None, *args, **opts):
+def _push(orig, ui, repo, *dests, **opts):
     opts = pycompat.byteskwargs(opts)
     bookmark = opts.get(b'bookmark')
     # we only support pushing one infinitepush bookmark at once
@@ -839,18 +839,18 @@ 
             oldphasemove = extensions.wrapfunction(
                 exchange, b'_localphasemove', _phasemove
             )
-        # Copy-paste from `push` command
-        path = ui.getpath(dest, default=(b'default-push', b'default'))
-        if not path:
-            raise error.Abort(
-                _(b'default repository not configured!'),
-                hint=_(b"see 'hg help config.paths'"),
-            )
+
+        paths = list(urlutil.get_push_paths(repo, ui, dests))
+        if len(paths) > 1:
+            msg = _(b'cannot push to multiple path with infinitepush')
+            raise error.Abort(msg)
+
+        path = paths[0]
         destpath = path.pushloc or path.loc
         # Remote scratch bookmarks will be deleted because remotenames doesn't
         # know about them. Let's save it before push and restore after
         remotescratchbookmarks = _readscratchremotebookmarks(ui, repo, destpath)
-        result = orig(ui, repo, dest, *args, **pycompat.strkwargs(opts))
+        result = orig(ui, repo, *dests, **pycompat.strkwargs(opts))
         if common.isremotebooksenabled(ui):
             if bookmark and scratchpush:
                 other = hg.peer(repo, opts, destpath)