Patchwork D10430: urlutil: remove usage of `ui.expandpath` in `get_unique_pull_path`

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

Comments

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

REVISION SUMMARY
  We want to deprecate `ui.expandpath` and simplify the code before adding more
  complexity in the form of `[paths]` entry pointing to multiple url. So we inline
  the relevant bits.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -509,8 +509,22 @@ 
     The `action` parameter will be used for the error message.
     """
     if source is None:
-        source = b'default'
-    url = ui.expandpath(source)
+        if b'default' in ui.paths:
+            url = ui.paths[b'default'].rawloc
+        else:
+            # XXX this is the historical default behavior, but that is not
+            # great, consider breaking BC on this.
+            url = b'default'
+    else:
+        if source in ui.paths:
+            url = ui.paths[source].rawloc
+        else:
+            # Try to resolve as a local path or URI.
+            try:
+                # we pass the ui instance are warning might need to be issued
+                url = path(ui, None, rawloc=source).rawloc
+            except ValueError:
+                url = source
     return parseurl(url, default_branches)