Show More
@@ -1479,3 +1479,14 b' def upgraderequirements(orig, repo):' | |||||
1479 | if 'largefiles' in repo.requirements: |
|
1479 | if 'largefiles' in repo.requirements: | |
1480 | reqs.add('largefiles') |
|
1480 | reqs.add('largefiles') | |
1481 | return reqs |
|
1481 | return reqs | |
|
1482 | ||||
|
1483 | _lfscheme = 'largefile://' | |||
|
1484 | def openlargefile(orig, ui, url_, data=None): | |||
|
1485 | if url_.startswith(_lfscheme): | |||
|
1486 | if data: | |||
|
1487 | msg = "cannot use data on a 'largefile://' url" | |||
|
1488 | raise error.ProgrammingError(msg) | |||
|
1489 | lfid = url_[len(_lfscheme):] | |||
|
1490 | return storefactory.getlfile(ui, lfid) | |||
|
1491 | else: | |||
|
1492 | return orig(ui, url_, data=data) |
@@ -27,7 +27,9 b' class remotestore(basestore.basestore):' | |||||
27 | '''a largefile store accessed over a network''' |
|
27 | '''a largefile store accessed over a network''' | |
28 | def __init__(self, ui, repo, url): |
|
28 | def __init__(self, ui, repo, url): | |
29 | super(remotestore, self).__init__(ui, repo, url) |
|
29 | super(remotestore, self).__init__(ui, repo, url) | |
30 | self._lstore = localstore.localstore(self.ui, self.repo, self.repo) |
|
30 | self._lstore = None | |
|
31 | if repo is not None: | |||
|
32 | self._lstore = localstore.localstore(self.ui, self.repo, self.repo) | |||
31 |
|
33 | |||
32 | def put(self, source, hash): |
|
34 | def put(self, source, hash): | |
33 | if self.sendfile(source, hash): |
|
35 | if self.sendfile(source, hash): |
@@ -22,8 +22,9 b' from . import (' | |||||
22 | # During clone this function is passed the src's ui object |
|
22 | # During clone this function is passed the src's ui object | |
23 | # but it needs the dest's ui object so it can read out of |
|
23 | # but it needs the dest's ui object so it can read out of | |
24 | # the config file. Use repo.ui instead. |
|
24 | # the config file. Use repo.ui instead. | |
25 | def openstore(repo, remote=None, put=False): |
|
25 | def openstore(repo=None, remote=None, put=False, ui=None): | |
26 | ui = repo.ui |
|
26 | if ui is None: | |
|
27 | ui = repo.ui | |||
27 |
|
28 | |||
28 | if not remote: |
|
29 | if not remote: | |
29 | lfpullsource = getattr(repo, 'lfpullsource', None) |
|
30 | lfpullsource = getattr(repo, 'lfpullsource', None) | |
@@ -37,12 +38,16 b' def openstore(repo, remote=None, put=Fal' | |||||
37 | # ui.expandpath() leaves 'default-push' and 'default' alone if |
|
38 | # ui.expandpath() leaves 'default-push' and 'default' alone if | |
38 | # they cannot be expanded: fallback to the empty string, |
|
39 | # they cannot be expanded: fallback to the empty string, | |
39 | # meaning the current directory. |
|
40 | # meaning the current directory. | |
40 | if path == 'default-push' or path == 'default': |
|
41 | if repo is None: | |
|
42 | path = ui.expandpath('default') | |||
|
43 | path, _branches = hg.parseurl(path) | |||
|
44 | remote = hg.peer(repo or ui, {}, path) | |||
|
45 | elif path == 'default-push' or path == 'default': | |||
41 | path = '' |
|
46 | path = '' | |
42 | remote = repo |
|
47 | remote = repo | |
43 | else: |
|
48 | else: | |
44 | path, _branches = hg.parseurl(path) |
|
49 | path, _branches = hg.parseurl(path) | |
45 | remote = hg.peer(repo, {}, path) |
|
50 | remote = hg.peer(repo or ui, {}, path) | |
46 |
|
51 | |||
47 | # The path could be a scheme so use Mercurial's normal functionality |
|
52 | # The path could be a scheme so use Mercurial's normal functionality | |
48 | # to resolve the scheme to a repository and use its path |
|
53 | # to resolve the scheme to a repository and use its path | |
@@ -76,3 +81,6 b' def openstore(repo, remote=None, put=Fal' | |||||
76 | } |
|
81 | } | |
77 |
|
82 | |||
78 | _scheme_re = re.compile(r'^([a-zA-Z0-9+-.]+)://') |
|
83 | _scheme_re = re.compile(r'^([a-zA-Z0-9+-.]+)://') | |
|
84 | ||||
|
85 | def getlfile(ui, hash): | |||
|
86 | return util.chunkbuffer(openstore(ui=ui)._get(hash)) |
@@ -31,6 +31,7 b' from mercurial import (' | |||||
31 | sshpeer, |
|
31 | sshpeer, | |
32 | subrepo, |
|
32 | subrepo, | |
33 | upgrade, |
|
33 | upgrade, | |
|
34 | url, | |||
34 | wireproto, |
|
35 | wireproto, | |
35 | ) |
|
36 | ) | |
36 |
|
37 | |||
@@ -160,6 +161,9 b' def uisetup(ui):' | |||||
160 | extensions.wrapfunction(scmutil, 'marktouched', |
|
161 | extensions.wrapfunction(scmutil, 'marktouched', | |
161 | overrides.scmutilmarktouched) |
|
162 | overrides.scmutilmarktouched) | |
162 |
|
163 | |||
|
164 | extensions.wrapfunction(url, 'open', | |||
|
165 | overrides.openlargefile) | |||
|
166 | ||||
163 | # create the new wireproto commands ... |
|
167 | # create the new wireproto commands ... | |
164 | wireproto.commands['putlfile'] = (proto.putlfile, 'sha') |
|
168 | wireproto.commands['putlfile'] = (proto.putlfile, 'sha') | |
165 | wireproto.commands['getlfile'] = (proto.getlfile, 'sha') |
|
169 | wireproto.commands['getlfile'] = (proto.getlfile, 'sha') |
@@ -34,3 +34,21 b' Check other kind of compatible url' | |||||
34 | $ hg debugdownload ./null.txt |
|
34 | $ hg debugdownload ./null.txt | |
35 | 1 0000000000000000000000000000000000000000 |
|
35 | 1 0000000000000000000000000000000000000000 | |
36 |
|
36 | |||
|
37 | Test largefile URL | |||
|
38 | ------------------ | |||
|
39 | ||||
|
40 | $ cat << EOF >> $HGRCPATH | |||
|
41 | > [extensions] | |||
|
42 | > largefiles= | |||
|
43 | > EOF | |||
|
44 | ||||
|
45 | $ killdaemons.py | |||
|
46 | $ rm -f error.log hg1.pid | |||
|
47 | $ hg serve -R server -p $HGPORT -d --pid-file=hg1.pid -E error.log | |||
|
48 | $ cat hg1.pid >> $DAEMON_PIDS | |||
|
49 | ||||
|
50 | $ hg -R server debuglfput null.txt | |||
|
51 | a57b57b39ee4dc3da1e03526596007f480ecdbe8 | |||
|
52 | ||||
|
53 | $ hg --traceback debugdownload "largefile://a57b57b39ee4dc3da1e03526596007f480ecdbe8" --config paths.default=http://localhost:$HGPORT/ | |||
|
54 | 1 0000000000000000000000000000000000000000 |
General Comments 0
You need to be logged in to leave comments.
Login now