lfs: use the new APIs
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 14 Apr 2021 14:35:13 +0200
changeset 46947 3f29765e0d95
parent 46946 b6b696442a4d
child 46948 946db89607c8
lfs: use the new APIs The part of the lfs store that requires a destination cannot operate on multiple destination (yet). So we move them to the dedicated APIs. Differential Revision: https://phab.mercurial-scm.org/D10413
hgext/largefiles/storefactory.py
--- a/hgext/largefiles/storefactory.py	Wed Apr 14 13:06:09 2021 +0200
+++ b/hgext/largefiles/storefactory.py	Wed Apr 14 14:35:13 2021 +0200
@@ -22,6 +22,7 @@
     wirestore,
 )
 
+
 # During clone this function is passed the src's ui object
 # but it needs the dest's ui object so it can read out of
 # the config file. Use repo.ui instead.
@@ -31,19 +32,22 @@
 
     if not remote:
         lfpullsource = getattr(repo, 'lfpullsource', None)
-        if lfpullsource:
-            path = ui.expandpath(lfpullsource)
-        elif put:
-            path = ui.expandpath(b'default-push', b'default')
+        if put:
+            path = urlutil.get_unique_push_path(
+                b'lfpullsource', repo, ui, lfpullsource
+            )
         else:
-            path = ui.expandpath(b'default')
+            path, _branches = urlutil.get_unique_pull_path(
+                b'lfpullsource', repo, ui, lfpullsource
+            )
 
-        # ui.expandpath() leaves 'default-push' and 'default' alone if
-        # they cannot be expanded: fallback to the empty string,
-        # meaning the current directory.
+        # XXX we should not explicitly pass b'default', as this will result in
+        # b'default' being returned if no `paths.default` was defined. We
+        # should explicitely handle the lack of value instead.
         if repo is None:
-            path = ui.expandpath(b'default')
-            path, _branches = urlutil.parseurl(path)
+            path, _branches = urlutil.get_unique_pull_path(
+                b'lfs', repo, ui, b'default'
+            )
             remote = hg.peer(repo or ui, {}, path)
         elif path == b'default-push' or path == b'default':
             remote = repo