hgext/largefiles/storefactory.py
changeset 35564 cf841f2b5a72
parent 29355 85868ecf2c0d
child 36310 ea62c2df882d
--- a/hgext/largefiles/storefactory.py	Thu Dec 21 13:53:26 2017 +0100
+++ b/hgext/largefiles/storefactory.py	Thu Dec 21 13:57:57 2017 +0100
@@ -22,8 +22,9 @@
 # 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.
-def openstore(repo, remote=None, put=False):
-    ui = repo.ui
+def openstore(repo=None, remote=None, put=False, ui=None):
+    if ui is None:
+        ui = repo.ui
 
     if not remote:
         lfpullsource = getattr(repo, 'lfpullsource', None)
@@ -37,12 +38,16 @@
         # ui.expandpath() leaves 'default-push' and 'default' alone if
         # they cannot be expanded: fallback to the empty string,
         # meaning the current directory.
-        if path == 'default-push' or path == 'default':
+        if repo is None:
+            path = ui.expandpath('default')
+            path, _branches = hg.parseurl(path)
+            remote = hg.peer(repo or ui, {}, path)
+        elif path == 'default-push' or path == 'default':
             path = ''
             remote = repo
         else:
             path, _branches = hg.parseurl(path)
-            remote = hg.peer(repo, {}, path)
+            remote = hg.peer(repo or ui, {}, path)
 
     # The path could be a scheme so use Mercurial's normal functionality
     # to resolve the scheme to a repository and use its path
@@ -76,3 +81,6 @@
     }
 
 _scheme_re = re.compile(r'^([a-zA-Z0-9+-.]+)://')
+
+def getlfile(ui, hash):
+    return util.chunkbuffer(openstore(ui=ui)._get(hash))