Show More
@@ -1,92 +1,96 b'' | |||
|
1 | 1 | # This software may be used and distributed according to the terms of the |
|
2 | 2 | # GNU General Public License version 2 or any later version. |
|
3 | 3 | |
|
4 | 4 | from __future__ import absolute_import |
|
5 | 5 | |
|
6 | 6 | import re |
|
7 | 7 | |
|
8 | 8 | from mercurial.i18n import _ |
|
9 | 9 | from mercurial.pycompat import getattr |
|
10 | 10 | from mercurial import ( |
|
11 | 11 | error, |
|
12 | 12 | hg, |
|
13 | 13 | util, |
|
14 | 14 | ) |
|
15 | 15 | from mercurial.utils import ( |
|
16 | 16 | urlutil, |
|
17 | 17 | ) |
|
18 | 18 | |
|
19 | 19 | from . import ( |
|
20 | 20 | lfutil, |
|
21 | 21 | localstore, |
|
22 | 22 | wirestore, |
|
23 | 23 | ) |
|
24 | 24 | |
|
25 | ||
|
25 | 26 | # During clone this function is passed the src's ui object |
|
26 | 27 | # but it needs the dest's ui object so it can read out of |
|
27 | 28 | # the config file. Use repo.ui instead. |
|
28 | 29 | def openstore(repo=None, remote=None, put=False, ui=None): |
|
29 | 30 | if ui is None: |
|
30 | 31 | ui = repo.ui |
|
31 | 32 | |
|
32 | 33 | if not remote: |
|
33 | 34 | lfpullsource = getattr(repo, 'lfpullsource', None) |
|
34 |
if |
|
|
35 |
path = ui. |
|
|
36 | elif put: | |
|
37 | path = ui.expandpath(b'default-push', b'default') | |
|
35 | if put: | |
|
36 | path = urlutil.get_unique_push_path( | |
|
37 | b'lfpullsource', repo, ui, lfpullsource | |
|
38 | ) | |
|
38 | 39 | else: |
|
39 | path = ui.expandpath(b'default') | |
|
40 | path, _branches = urlutil.get_unique_pull_path( | |
|
41 | b'lfpullsource', repo, ui, lfpullsource | |
|
42 | ) | |
|
40 | 43 | |
|
41 | # ui.expandpath() leaves 'default-push' and 'default' alone if | |
|
42 | # they cannot be expanded: fallback to the empty string, | |
|
43 | # meaning the current directory. | |
|
44 | # XXX we should not explicitly pass b'default', as this will result in | |
|
45 | # b'default' being returned if no `paths.default` was defined. We | |
|
46 | # should explicitely handle the lack of value instead. | |
|
44 | 47 | if repo is None: |
|
45 | path = ui.expandpath(b'default') | |
|
46 | path, _branches = urlutil.parseurl(path) | |
|
48 | path, _branches = urlutil.get_unique_pull_path( | |
|
49 | b'lfs', repo, ui, b'default' | |
|
50 | ) | |
|
47 | 51 | remote = hg.peer(repo or ui, {}, path) |
|
48 | 52 | elif path == b'default-push' or path == b'default': |
|
49 | 53 | remote = repo |
|
50 | 54 | else: |
|
51 | 55 | path, _branches = urlutil.parseurl(path) |
|
52 | 56 | remote = hg.peer(repo or ui, {}, path) |
|
53 | 57 | |
|
54 | 58 | # The path could be a scheme so use Mercurial's normal functionality |
|
55 | 59 | # to resolve the scheme to a repository and use its path |
|
56 | 60 | path = util.safehasattr(remote, b'url') and remote.url() or remote.path |
|
57 | 61 | |
|
58 | 62 | match = _scheme_re.match(path) |
|
59 | 63 | if not match: # regular filesystem path |
|
60 | 64 | scheme = b'file' |
|
61 | 65 | else: |
|
62 | 66 | scheme = match.group(1) |
|
63 | 67 | |
|
64 | 68 | try: |
|
65 | 69 | storeproviders = _storeprovider[scheme] |
|
66 | 70 | except KeyError: |
|
67 | 71 | raise error.Abort(_(b'unsupported URL scheme %r') % scheme) |
|
68 | 72 | |
|
69 | 73 | for classobj in storeproviders: |
|
70 | 74 | try: |
|
71 | 75 | return classobj(ui, repo, remote) |
|
72 | 76 | except lfutil.storeprotonotcapable: |
|
73 | 77 | pass |
|
74 | 78 | |
|
75 | 79 | raise error.Abort( |
|
76 | 80 | _(b'%s does not appear to be a largefile store') |
|
77 | 81 | % urlutil.hidepassword(path) |
|
78 | 82 | ) |
|
79 | 83 | |
|
80 | 84 | |
|
81 | 85 | _storeprovider = { |
|
82 | 86 | b'file': [localstore.localstore], |
|
83 | 87 | b'http': [wirestore.wirestore], |
|
84 | 88 | b'https': [wirestore.wirestore], |
|
85 | 89 | b'ssh': [wirestore.wirestore], |
|
86 | 90 | } |
|
87 | 91 | |
|
88 | 92 | _scheme_re = re.compile(br'^([a-zA-Z0-9+-.]+)://') |
|
89 | 93 | |
|
90 | 94 | |
|
91 | 95 | def getlfile(ui, hash): |
|
92 | 96 | return util.chunkbuffer(openstore(ui=ui)._get(hash)) |
General Comments 0
You need to be logged in to leave comments.
Login now