Patchwork D10407: get_unique_push_path

login
register
mail settings
Submitter phabricator
Date April 14, 2021, 11:37 p.m.
Message ID <differential-rev-PHID-DREV-y2it7sejn7hrdv5fksme-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48722/
State Superseded
Headers show

Comments

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

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/utils/urlutil.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/utils/urlutil.py b/mercurial/utils/urlutil.py
--- a/mercurial/utils/urlutil.py
+++ b/mercurial/utils/urlutil.py
@@ -471,6 +471,25 @@ 
         yield parseurl(url, default_branches)
 
 
+def get_unique_push_path(action, repo, ui, dest=None):
+    """return a unique `path` or abort if multiple are found
+
+    This is useful for command and action that does not support multiple
+    destination (yet).
+
+    Note that for now, we cannot get multiple destination so this function is "trivial".
+
+    The `action` parameter will be used for the error message.
+    """
+    if dest is None:
+        dests = []
+    else:
+        dests = [dest]
+    dests = list(get_push_paths(repo, ui, dests))
+    assert len(dests) == 1
+    return dests[0]
+
+
 def get_unique_pull_path(action, repo, ui, source=None, default_branches=()):
     """return a unique `(path, branch)` or abort if multiple are found