Show More
@@ -1,108 +1,125 b'' | |||||
1 | # Copyright 2010-2011 Fog Creek Software |
|
1 | # Copyright 2010-2011 Fog Creek Software | |
2 | # Copyright 2010-2011 Unity Technologies |
|
2 | # Copyright 2010-2011 Unity Technologies | |
3 | # |
|
3 | # | |
4 | # This software may be used and distributed according to the terms of the |
|
4 | # This software may be used and distributed according to the terms of the | |
5 | # GNU General Public License version 2 or any later version. |
|
5 | # GNU General Public License version 2 or any later version. | |
6 |
|
6 | |||
7 | '''remote largefile store; the base class for wirestore''' |
|
7 | '''remote largefile store; the base class for wirestore''' | |
8 |
|
8 | |||
9 | from mercurial import util, wireproto, error |
|
9 | from mercurial import util, wireproto, error | |
10 | from mercurial.i18n import _ |
|
10 | from mercurial.i18n import _ | |
11 |
|
11 | |||
12 | urlerr = util.urlerr |
|
12 | urlerr = util.urlerr | |
13 | urlreq = util.urlreq |
|
13 | urlreq = util.urlreq | |
14 |
|
14 | |||
15 | import lfutil |
|
15 | import lfutil | |
16 | import basestore |
|
16 | import basestore | |
|
17 | import localstore | |||
17 |
|
18 | |||
18 | class remotestore(basestore.basestore): |
|
19 | class remotestore(basestore.basestore): | |
19 | '''a largefile store accessed over a network''' |
|
20 | '''a largefile store accessed over a network''' | |
20 | def __init__(self, ui, repo, url): |
|
21 | def __init__(self, ui, repo, url): | |
21 | super(remotestore, self).__init__(ui, repo, url) |
|
22 | super(remotestore, self).__init__(ui, repo, url) | |
|
23 | self._lstore = localstore.localstore(self.ui, self.repo, self.repo) | |||
22 |
|
24 | |||
23 | def put(self, source, hash): |
|
25 | def put(self, source, hash): | |
24 | if self.sendfile(source, hash): |
|
26 | if self.sendfile(source, hash): | |
25 | raise error.Abort( |
|
27 | raise error.Abort( | |
26 | _('remotestore: could not put %s to remote store %s') |
|
28 | _('remotestore: could not put %s to remote store %s') | |
27 | % (source, util.hidepassword(self.url))) |
|
29 | % (source, util.hidepassword(self.url))) | |
28 | self.ui.debug( |
|
30 | self.ui.debug( | |
29 | _('remotestore: put %s to remote store %s\n') |
|
31 | _('remotestore: put %s to remote store %s\n') | |
30 | % (source, util.hidepassword(self.url))) |
|
32 | % (source, util.hidepassword(self.url))) | |
31 |
|
33 | |||
32 | def exists(self, hashes): |
|
34 | def exists(self, hashes): | |
33 | return dict((h, s == 0) for (h, s) in # dict-from-generator |
|
35 | return dict((h, s == 0) for (h, s) in # dict-from-generator | |
34 | self._stat(hashes).iteritems()) |
|
36 | self._stat(hashes).iteritems()) | |
35 |
|
37 | |||
36 | def sendfile(self, filename, hash): |
|
38 | def sendfile(self, filename, hash): | |
37 | self.ui.debug('remotestore: sendfile(%s, %s)\n' % (filename, hash)) |
|
39 | self.ui.debug('remotestore: sendfile(%s, %s)\n' % (filename, hash)) | |
38 | fd = None |
|
40 | fd = None | |
39 | try: |
|
41 | try: | |
40 | fd = lfutil.httpsendfile(self.ui, filename) |
|
42 | fd = lfutil.httpsendfile(self.ui, filename) | |
41 | return self._put(hash, fd) |
|
43 | return self._put(hash, fd) | |
42 | except IOError as e: |
|
44 | except IOError as e: | |
43 | raise error.Abort( |
|
45 | raise error.Abort( | |
44 | _('remotestore: could not open file %s: %s') |
|
46 | _('remotestore: could not open file %s: %s') | |
45 | % (filename, str(e))) |
|
47 | % (filename, str(e))) | |
46 | finally: |
|
48 | finally: | |
47 | if fd: |
|
49 | if fd: | |
48 | fd.close() |
|
50 | fd.close() | |
49 |
|
51 | |||
50 | def _getfile(self, tmpfile, filename, hash): |
|
52 | def _getfile(self, tmpfile, filename, hash): | |
51 | try: |
|
53 | try: | |
52 | chunks = self._get(hash) |
|
54 | chunks = self._get(hash) | |
53 | except urlerr.httperror as e: |
|
55 | except urlerr.httperror as e: | |
54 | # 401s get converted to error.Aborts; everything else is fine being |
|
56 | # 401s get converted to error.Aborts; everything else is fine being | |
55 | # turned into a StoreError |
|
57 | # turned into a StoreError | |
56 | raise basestore.StoreError(filename, hash, self.url, str(e)) |
|
58 | raise basestore.StoreError(filename, hash, self.url, str(e)) | |
57 | except urlerr.urlerror as e: |
|
59 | except urlerr.urlerror as e: | |
58 | # This usually indicates a connection problem, so don't |
|
60 | # This usually indicates a connection problem, so don't | |
59 | # keep trying with the other files... they will probably |
|
61 | # keep trying with the other files... they will probably | |
60 | # all fail too. |
|
62 | # all fail too. | |
61 | raise error.Abort('%s: %s' % |
|
63 | raise error.Abort('%s: %s' % | |
62 | (util.hidepassword(self.url), e.reason)) |
|
64 | (util.hidepassword(self.url), e.reason)) | |
63 | except IOError as e: |
|
65 | except IOError as e: | |
64 | raise basestore.StoreError(filename, hash, self.url, str(e)) |
|
66 | raise basestore.StoreError(filename, hash, self.url, str(e)) | |
65 |
|
67 | |||
66 | return lfutil.copyandhash(chunks, tmpfile) |
|
68 | return lfutil.copyandhash(chunks, tmpfile) | |
67 |
|
69 | |||
|
70 | def _hashesavailablelocally(self, hashes): | |||
|
71 | existslocallymap = self._lstore.exists(hashes) | |||
|
72 | localhashes = [hash for hash in hashes if existslocallymap[hash]] | |||
|
73 | return localhashes | |||
|
74 | ||||
68 | def _verifyfiles(self, contents, filestocheck): |
|
75 | def _verifyfiles(self, contents, filestocheck): | |
69 | failed = False |
|
76 | failed = False | |
70 | expectedhashes = [expectedhash |
|
77 | expectedhashes = [expectedhash | |
71 | for cset, filename, expectedhash in filestocheck] |
|
78 | for cset, filename, expectedhash in filestocheck] | |
72 |
|
|
79 | localhashes = self._hashesavailablelocally(expectedhashes) | |
|
80 | stats = self._stat([expectedhash for expectedhash in expectedhashes | |||
|
81 | if expectedhash not in localhashes]) | |||
|
82 | ||||
73 | for cset, filename, expectedhash in filestocheck: |
|
83 | for cset, filename, expectedhash in filestocheck: | |
|
84 | if expectedhash in localhashes: | |||
|
85 | filetocheck = (cset, filename, expectedhash) | |||
|
86 | verifyresult = self._lstore._verifyfiles(contents, | |||
|
87 | [filetocheck]) | |||
|
88 | if verifyresult: | |||
|
89 | failed = True | |||
|
90 | else: | |||
74 | stat = stats[expectedhash] |
|
91 | stat = stats[expectedhash] | |
75 | if stat: |
|
92 | if stat: | |
76 | if stat == 1: |
|
93 | if stat == 1: | |
77 | self.ui.warn( |
|
94 | self.ui.warn( | |
78 | _('changeset %s: %s: contents differ\n') |
|
95 | _('changeset %s: %s: contents differ\n') | |
79 | % (cset, filename)) |
|
96 | % (cset, filename)) | |
80 | failed = True |
|
97 | failed = True | |
81 | elif stat == 2: |
|
98 | elif stat == 2: | |
82 | self.ui.warn( |
|
99 | self.ui.warn( | |
83 | _('changeset %s: %s missing\n') |
|
100 | _('changeset %s: %s missing\n') | |
84 | % (cset, filename)) |
|
101 | % (cset, filename)) | |
85 | failed = True |
|
102 | failed = True | |
86 | else: |
|
103 | else: | |
87 | raise RuntimeError('verify failed: unexpected response ' |
|
104 | raise RuntimeError('verify failed: unexpected response ' | |
88 | 'from statlfile (%r)' % stat) |
|
105 | 'from statlfile (%r)' % stat) | |
89 | return failed |
|
106 | return failed | |
90 |
|
107 | |||
91 | def batch(self): |
|
108 | def batch(self): | |
92 | '''Support for remote batching.''' |
|
109 | '''Support for remote batching.''' | |
93 | return wireproto.remotebatch(self) |
|
110 | return wireproto.remotebatch(self) | |
94 |
|
111 | |||
95 | def _put(self, hash, fd): |
|
112 | def _put(self, hash, fd): | |
96 | '''Put file with the given hash in the remote store.''' |
|
113 | '''Put file with the given hash in the remote store.''' | |
97 | raise NotImplementedError('abstract method') |
|
114 | raise NotImplementedError('abstract method') | |
98 |
|
115 | |||
99 | def _get(self, hash): |
|
116 | def _get(self, hash): | |
100 | '''Get file with the given hash from the remote store.''' |
|
117 | '''Get file with the given hash from the remote store.''' | |
101 | raise NotImplementedError('abstract method') |
|
118 | raise NotImplementedError('abstract method') | |
102 |
|
119 | |||
103 | def _stat(self, hashes): |
|
120 | def _stat(self, hashes): | |
104 | '''Get information about availability of files specified by |
|
121 | '''Get information about availability of files specified by | |
105 | hashes in the remote store. Return dictionary mapping hashes |
|
122 | hashes in the remote store. Return dictionary mapping hashes | |
106 | to return code where 0 means that file is available, other |
|
123 | to return code where 0 means that file is available, other | |
107 | values if not.''' |
|
124 | values if not.''' | |
108 | raise NotImplementedError('abstract method') |
|
125 | raise NotImplementedError('abstract method') |
@@ -1,351 +1,383 b'' | |||||
1 | This file contains testcases that tend to be related to the wire protocol part |
|
1 | This file contains testcases that tend to be related to the wire protocol part | |
2 | of largefiles. |
|
2 | of largefiles. | |
3 |
|
3 | |||
4 | $ USERCACHE="$TESTTMP/cache"; export USERCACHE |
|
4 | $ USERCACHE="$TESTTMP/cache"; export USERCACHE | |
5 | $ mkdir "${USERCACHE}" |
|
5 | $ mkdir "${USERCACHE}" | |
6 | $ cat >> $HGRCPATH <<EOF |
|
6 | $ cat >> $HGRCPATH <<EOF | |
7 | > [extensions] |
|
7 | > [extensions] | |
8 | > largefiles= |
|
8 | > largefiles= | |
9 | > purge= |
|
9 | > purge= | |
10 | > rebase= |
|
10 | > rebase= | |
11 | > transplant= |
|
11 | > transplant= | |
12 | > [phases] |
|
12 | > [phases] | |
13 | > publish=False |
|
13 | > publish=False | |
14 | > [largefiles] |
|
14 | > [largefiles] | |
15 | > minsize=2 |
|
15 | > minsize=2 | |
16 | > patterns=glob:**.dat |
|
16 | > patterns=glob:**.dat | |
17 | > usercache=${USERCACHE} |
|
17 | > usercache=${USERCACHE} | |
18 | > [web] |
|
18 | > [web] | |
19 | > allow_archive = zip |
|
19 | > allow_archive = zip | |
20 | > [hooks] |
|
20 | > [hooks] | |
21 | > precommit=sh -c "echo \\"Invoking status precommit hook\\"; hg status" |
|
21 | > precommit=sh -c "echo \\"Invoking status precommit hook\\"; hg status" | |
22 | > EOF |
|
22 | > EOF | |
23 |
|
23 | |||
24 |
|
24 | |||
25 | #if serve |
|
25 | #if serve | |
26 | vanilla clients not locked out from largefiles servers on vanilla repos |
|
26 | vanilla clients not locked out from largefiles servers on vanilla repos | |
27 | $ mkdir r1 |
|
27 | $ mkdir r1 | |
28 | $ cd r1 |
|
28 | $ cd r1 | |
29 | $ hg init |
|
29 | $ hg init | |
30 | $ echo c1 > f1 |
|
30 | $ echo c1 > f1 | |
31 | $ hg add f1 |
|
31 | $ hg add f1 | |
32 | $ hg commit -m "m1" |
|
32 | $ hg commit -m "m1" | |
33 | Invoking status precommit hook |
|
33 | Invoking status precommit hook | |
34 | A f1 |
|
34 | A f1 | |
35 | $ cd .. |
|
35 | $ cd .. | |
36 | $ hg serve -R r1 -d -p $HGPORT --pid-file hg.pid |
|
36 | $ hg serve -R r1 -d -p $HGPORT --pid-file hg.pid | |
37 | $ cat hg.pid >> $DAEMON_PIDS |
|
37 | $ cat hg.pid >> $DAEMON_PIDS | |
38 | $ hg --config extensions.largefiles=! clone http://localhost:$HGPORT r2 |
|
38 | $ hg --config extensions.largefiles=! clone http://localhost:$HGPORT r2 | |
39 | requesting all changes |
|
39 | requesting all changes | |
40 | adding changesets |
|
40 | adding changesets | |
41 | adding manifests |
|
41 | adding manifests | |
42 | adding file changes |
|
42 | adding file changes | |
43 | added 1 changesets with 1 changes to 1 files |
|
43 | added 1 changesets with 1 changes to 1 files | |
44 | updating to branch default |
|
44 | updating to branch default | |
45 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
45 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
46 |
|
46 | |||
47 | largefiles clients still work with vanilla servers |
|
47 | largefiles clients still work with vanilla servers | |
48 | $ hg serve --config extensions.largefiles=! -R r1 -d -p $HGPORT1 --pid-file hg.pid |
|
48 | $ hg serve --config extensions.largefiles=! -R r1 -d -p $HGPORT1 --pid-file hg.pid | |
49 | $ cat hg.pid >> $DAEMON_PIDS |
|
49 | $ cat hg.pid >> $DAEMON_PIDS | |
50 | $ hg clone http://localhost:$HGPORT1 r3 |
|
50 | $ hg clone http://localhost:$HGPORT1 r3 | |
51 | requesting all changes |
|
51 | requesting all changes | |
52 | adding changesets |
|
52 | adding changesets | |
53 | adding manifests |
|
53 | adding manifests | |
54 | adding file changes |
|
54 | adding file changes | |
55 | added 1 changesets with 1 changes to 1 files |
|
55 | added 1 changesets with 1 changes to 1 files | |
56 | updating to branch default |
|
56 | updating to branch default | |
57 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
57 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
58 | #endif |
|
58 | #endif | |
59 |
|
59 | |||
60 | vanilla clients locked out from largefiles http repos |
|
60 | vanilla clients locked out from largefiles http repos | |
61 | $ mkdir r4 |
|
61 | $ mkdir r4 | |
62 | $ cd r4 |
|
62 | $ cd r4 | |
63 | $ hg init |
|
63 | $ hg init | |
64 | $ echo c1 > f1 |
|
64 | $ echo c1 > f1 | |
65 | $ hg add --large f1 |
|
65 | $ hg add --large f1 | |
66 | $ hg commit -m "m1" |
|
66 | $ hg commit -m "m1" | |
67 | Invoking status precommit hook |
|
67 | Invoking status precommit hook | |
68 | A f1 |
|
68 | A f1 | |
69 | $ cd .. |
|
69 | $ cd .. | |
70 |
|
70 | |||
71 | largefiles can be pushed locally (issue3583) |
|
71 | largefiles can be pushed locally (issue3583) | |
72 | $ hg init dest |
|
72 | $ hg init dest | |
73 | $ cd r4 |
|
73 | $ cd r4 | |
74 | $ hg outgoing ../dest |
|
74 | $ hg outgoing ../dest | |
75 | comparing with ../dest |
|
75 | comparing with ../dest | |
76 | searching for changes |
|
76 | searching for changes | |
77 | changeset: 0:639881c12b4c |
|
77 | changeset: 0:639881c12b4c | |
78 | tag: tip |
|
78 | tag: tip | |
79 | user: test |
|
79 | user: test | |
80 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
80 | date: Thu Jan 01 00:00:00 1970 +0000 | |
81 | summary: m1 |
|
81 | summary: m1 | |
82 |
|
82 | |||
83 | $ hg push ../dest |
|
83 | $ hg push ../dest | |
84 | pushing to ../dest |
|
84 | pushing to ../dest | |
85 | searching for changes |
|
85 | searching for changes | |
86 | adding changesets |
|
86 | adding changesets | |
87 | adding manifests |
|
87 | adding manifests | |
88 | adding file changes |
|
88 | adding file changes | |
89 | added 1 changesets with 1 changes to 1 files |
|
89 | added 1 changesets with 1 changes to 1 files | |
90 |
|
90 | |||
91 | exit code with nothing outgoing (issue3611) |
|
91 | exit code with nothing outgoing (issue3611) | |
92 | $ hg outgoing ../dest |
|
92 | $ hg outgoing ../dest | |
93 | comparing with ../dest |
|
93 | comparing with ../dest | |
94 | searching for changes |
|
94 | searching for changes | |
95 | no changes found |
|
95 | no changes found | |
96 | [1] |
|
96 | [1] | |
97 | $ cd .. |
|
97 | $ cd .. | |
98 |
|
98 | |||
99 | #if serve |
|
99 | #if serve | |
100 | $ hg serve -R r4 -d -p $HGPORT2 --pid-file hg.pid |
|
100 | $ hg serve -R r4 -d -p $HGPORT2 --pid-file hg.pid | |
101 | $ cat hg.pid >> $DAEMON_PIDS |
|
101 | $ cat hg.pid >> $DAEMON_PIDS | |
102 | $ hg --config extensions.largefiles=! clone http://localhost:$HGPORT2 r5 |
|
102 | $ hg --config extensions.largefiles=! clone http://localhost:$HGPORT2 r5 | |
103 | abort: remote error: |
|
103 | abort: remote error: | |
104 |
|
104 | |||
105 | This repository uses the largefiles extension. |
|
105 | This repository uses the largefiles extension. | |
106 |
|
106 | |||
107 | Please enable it in your Mercurial config file. |
|
107 | Please enable it in your Mercurial config file. | |
108 | [255] |
|
108 | [255] | |
109 |
|
109 | |||
110 | used all HGPORTs, kill all daemons |
|
110 | used all HGPORTs, kill all daemons | |
111 | $ killdaemons.py |
|
111 | $ killdaemons.py | |
112 | #endif |
|
112 | #endif | |
113 |
|
113 | |||
114 | vanilla clients locked out from largefiles ssh repos |
|
114 | vanilla clients locked out from largefiles ssh repos | |
115 | $ hg --config extensions.largefiles=! clone -e "python \"$TESTDIR/dummyssh\"" ssh://user@dummy/r4 r5 |
|
115 | $ hg --config extensions.largefiles=! clone -e "python \"$TESTDIR/dummyssh\"" ssh://user@dummy/r4 r5 | |
116 | remote: |
|
116 | remote: | |
117 | remote: This repository uses the largefiles extension. |
|
117 | remote: This repository uses the largefiles extension. | |
118 | remote: |
|
118 | remote: | |
119 | remote: Please enable it in your Mercurial config file. |
|
119 | remote: Please enable it in your Mercurial config file. | |
120 | remote: |
|
120 | remote: | |
121 | remote: - |
|
121 | remote: - | |
122 | abort: remote error |
|
122 | abort: remote error | |
123 | (check previous remote output) |
|
123 | (check previous remote output) | |
124 | [255] |
|
124 | [255] | |
125 |
|
125 | |||
126 | #if serve |
|
126 | #if serve | |
127 |
|
127 | |||
128 | largefiles clients refuse to push largefiles repos to vanilla servers |
|
128 | largefiles clients refuse to push largefiles repos to vanilla servers | |
129 | $ mkdir r6 |
|
129 | $ mkdir r6 | |
130 | $ cd r6 |
|
130 | $ cd r6 | |
131 | $ hg init |
|
131 | $ hg init | |
132 | $ echo c1 > f1 |
|
132 | $ echo c1 > f1 | |
133 | $ hg add f1 |
|
133 | $ hg add f1 | |
134 | $ hg commit -m "m1" |
|
134 | $ hg commit -m "m1" | |
135 | Invoking status precommit hook |
|
135 | Invoking status precommit hook | |
136 | A f1 |
|
136 | A f1 | |
137 | $ cat >> .hg/hgrc <<! |
|
137 | $ cat >> .hg/hgrc <<! | |
138 | > [web] |
|
138 | > [web] | |
139 | > push_ssl = false |
|
139 | > push_ssl = false | |
140 | > allow_push = * |
|
140 | > allow_push = * | |
141 | > ! |
|
141 | > ! | |
142 | $ cd .. |
|
142 | $ cd .. | |
143 | $ hg clone r6 r7 |
|
143 | $ hg clone r6 r7 | |
144 | updating to branch default |
|
144 | updating to branch default | |
145 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
145 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
146 | $ cd r7 |
|
146 | $ cd r7 | |
147 | $ echo c2 > f2 |
|
147 | $ echo c2 > f2 | |
148 | $ hg add --large f2 |
|
148 | $ hg add --large f2 | |
149 | $ hg commit -m "m2" |
|
149 | $ hg commit -m "m2" | |
150 | Invoking status precommit hook |
|
150 | Invoking status precommit hook | |
151 | A f2 |
|
151 | A f2 | |
152 | $ hg serve --config extensions.largefiles=! -R ../r6 -d -p $HGPORT --pid-file ../hg.pid |
|
152 | $ hg serve --config extensions.largefiles=! -R ../r6 -d -p $HGPORT --pid-file ../hg.pid | |
153 | $ cat ../hg.pid >> $DAEMON_PIDS |
|
153 | $ cat ../hg.pid >> $DAEMON_PIDS | |
154 | $ hg push http://localhost:$HGPORT |
|
154 | $ hg push http://localhost:$HGPORT | |
155 | pushing to http://localhost:$HGPORT/ |
|
155 | pushing to http://localhost:$HGPORT/ | |
156 | searching for changes |
|
156 | searching for changes | |
157 | abort: http://localhost:$HGPORT/ does not appear to be a largefile store |
|
157 | abort: http://localhost:$HGPORT/ does not appear to be a largefile store | |
158 | [255] |
|
158 | [255] | |
159 | $ cd .. |
|
159 | $ cd .. | |
160 |
|
160 | |||
161 | putlfile errors are shown (issue3123) |
|
161 | putlfile errors are shown (issue3123) | |
162 | Corrupt the cached largefile in r7 and move it out of the servers usercache |
|
162 | Corrupt the cached largefile in r7 and move it out of the servers usercache | |
163 | $ mv r7/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8 . |
|
163 | $ mv r7/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8 . | |
164 | $ echo 'client side corruption' > r7/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8 |
|
164 | $ echo 'client side corruption' > r7/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8 | |
165 | $ rm "$USERCACHE/4cdac4d8b084d0b599525cf732437fb337d422a8" |
|
165 | $ rm "$USERCACHE/4cdac4d8b084d0b599525cf732437fb337d422a8" | |
166 | $ hg init empty |
|
166 | $ hg init empty | |
167 | $ hg serve -R empty -d -p $HGPORT1 --pid-file hg.pid \ |
|
167 | $ hg serve -R empty -d -p $HGPORT1 --pid-file hg.pid \ | |
168 | > --config 'web.allow_push=*' --config web.push_ssl=False |
|
168 | > --config 'web.allow_push=*' --config web.push_ssl=False | |
169 | $ cat hg.pid >> $DAEMON_PIDS |
|
169 | $ cat hg.pid >> $DAEMON_PIDS | |
170 | $ hg push -R r7 http://localhost:$HGPORT1 |
|
170 | $ hg push -R r7 http://localhost:$HGPORT1 | |
171 | pushing to http://localhost:$HGPORT1/ |
|
171 | pushing to http://localhost:$HGPORT1/ | |
172 | searching for changes |
|
172 | searching for changes | |
173 | remote: largefiles: failed to put 4cdac4d8b084d0b599525cf732437fb337d422a8 into store: largefile contents do not match hash |
|
173 | remote: largefiles: failed to put 4cdac4d8b084d0b599525cf732437fb337d422a8 into store: largefile contents do not match hash | |
174 | abort: remotestore: could not put $TESTTMP/r7/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8 to remote store http://localhost:$HGPORT1/ (glob) |
|
174 | abort: remotestore: could not put $TESTTMP/r7/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8 to remote store http://localhost:$HGPORT1/ (glob) | |
175 | [255] |
|
175 | [255] | |
176 | $ mv 4cdac4d8b084d0b599525cf732437fb337d422a8 r7/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8 |
|
176 | $ mv 4cdac4d8b084d0b599525cf732437fb337d422a8 r7/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8 | |
177 | Push of file that exists on server but is corrupted - magic healing would be nice ... but too magic |
|
177 | Push of file that exists on server but is corrupted - magic healing would be nice ... but too magic | |
178 | $ echo "server side corruption" > empty/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8 |
|
178 | $ echo "server side corruption" > empty/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8 | |
179 | $ hg push -R r7 http://localhost:$HGPORT1 |
|
179 | $ hg push -R r7 http://localhost:$HGPORT1 | |
180 | pushing to http://localhost:$HGPORT1/ |
|
180 | pushing to http://localhost:$HGPORT1/ | |
181 | searching for changes |
|
181 | searching for changes | |
182 | remote: adding changesets |
|
182 | remote: adding changesets | |
183 | remote: adding manifests |
|
183 | remote: adding manifests | |
184 | remote: adding file changes |
|
184 | remote: adding file changes | |
185 | remote: added 2 changesets with 2 changes to 2 files |
|
185 | remote: added 2 changesets with 2 changes to 2 files | |
186 | $ cat empty/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8 |
|
186 | $ cat empty/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8 | |
187 | server side corruption |
|
187 | server side corruption | |
188 | $ rm -rf empty |
|
188 | $ rm -rf empty | |
189 |
|
189 | |||
190 | Push a largefiles repository to a served empty repository |
|
190 | Push a largefiles repository to a served empty repository | |
191 | $ hg init r8 |
|
191 | $ hg init r8 | |
192 | $ echo c3 > r8/f1 |
|
192 | $ echo c3 > r8/f1 | |
193 | $ hg add --large r8/f1 -R r8 |
|
193 | $ hg add --large r8/f1 -R r8 | |
194 | $ hg commit -m "m1" -R r8 |
|
194 | $ hg commit -m "m1" -R r8 | |
195 | Invoking status precommit hook |
|
195 | Invoking status precommit hook | |
196 | A f1 |
|
196 | A f1 | |
197 | $ hg init empty |
|
197 | $ hg init empty | |
198 | $ hg serve -R empty -d -p $HGPORT2 --pid-file hg.pid \ |
|
198 | $ hg serve -R empty -d -p $HGPORT2 --pid-file hg.pid \ | |
199 | > --config 'web.allow_push=*' --config web.push_ssl=False |
|
199 | > --config 'web.allow_push=*' --config web.push_ssl=False | |
200 | $ cat hg.pid >> $DAEMON_PIDS |
|
200 | $ cat hg.pid >> $DAEMON_PIDS | |
201 | $ rm "${USERCACHE}"/* |
|
201 | $ rm "${USERCACHE}"/* | |
202 | $ hg push -R r8 http://localhost:$HGPORT2/#default |
|
202 | $ hg push -R r8 http://localhost:$HGPORT2/#default | |
203 | pushing to http://localhost:$HGPORT2/ |
|
203 | pushing to http://localhost:$HGPORT2/ | |
204 | searching for changes |
|
204 | searching for changes | |
205 | remote: adding changesets |
|
205 | remote: adding changesets | |
206 | remote: adding manifests |
|
206 | remote: adding manifests | |
207 | remote: adding file changes |
|
207 | remote: adding file changes | |
208 | remote: added 1 changesets with 1 changes to 1 files |
|
208 | remote: added 1 changesets with 1 changes to 1 files | |
209 | $ [ -f "${USERCACHE}"/02a439e5c31c526465ab1a0ca1f431f76b827b90 ] |
|
209 | $ [ -f "${USERCACHE}"/02a439e5c31c526465ab1a0ca1f431f76b827b90 ] | |
210 | $ [ -f empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 ] |
|
210 | $ [ -f empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 ] | |
211 |
|
211 | |||
212 | Clone over http, no largefiles pulled on clone. |
|
212 | Clone over http, no largefiles pulled on clone. | |
213 |
|
213 | |||
214 | $ hg clone http://localhost:$HGPORT2/#default http-clone -U |
|
214 | $ hg clone http://localhost:$HGPORT2/#default http-clone -U | |
215 | adding changesets |
|
215 | adding changesets | |
216 | adding manifests |
|
216 | adding manifests | |
217 | adding file changes |
|
217 | adding file changes | |
218 | added 1 changesets with 1 changes to 1 files |
|
218 | added 1 changesets with 1 changes to 1 files | |
219 |
|
219 | |||
220 | Archive contains largefiles |
|
220 | Archive contains largefiles | |
221 | >>> import urllib2, os |
|
221 | >>> import urllib2, os | |
222 | >>> u = 'http://localhost:%s/archive/default.zip' % os.environ['HGPORT2'] |
|
222 | >>> u = 'http://localhost:%s/archive/default.zip' % os.environ['HGPORT2'] | |
223 | >>> with open('archive.zip', 'w') as f: |
|
223 | >>> with open('archive.zip', 'w') as f: | |
224 | ... f.write(urllib2.urlopen(u).read()) |
|
224 | ... f.write(urllib2.urlopen(u).read()) | |
225 | $ unzip -t archive.zip |
|
225 | $ unzip -t archive.zip | |
226 | Archive: archive.zip |
|
226 | Archive: archive.zip | |
227 | testing: empty-default/.hg_archival.txt OK |
|
227 | testing: empty-default/.hg_archival.txt OK | |
228 | testing: empty-default/f1 OK |
|
228 | testing: empty-default/f1 OK | |
229 | No errors detected in compressed data of archive.zip. |
|
229 | No errors detected in compressed data of archive.zip. | |
230 |
|
230 | |||
231 | test 'verify' with remotestore: |
|
231 | test 'verify' with remotestore: | |
232 |
|
232 | |||
233 | $ rm "${USERCACHE}"/02a439e5c31c526465ab1a0ca1f431f76b827b90 |
|
233 | $ rm "${USERCACHE}"/02a439e5c31c526465ab1a0ca1f431f76b827b90 | |
234 | $ mv empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 . |
|
234 | $ mv empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 . | |
235 | $ hg -R http-clone verify --large --lfa |
|
235 | $ hg -R http-clone verify --large --lfa | |
236 | checking changesets |
|
236 | checking changesets | |
237 | checking manifests |
|
237 | checking manifests | |
238 | crosschecking files in changesets and manifests |
|
238 | crosschecking files in changesets and manifests | |
239 | checking files |
|
239 | checking files | |
240 | 1 files, 1 changesets, 1 total revisions |
|
240 | 1 files, 1 changesets, 1 total revisions | |
241 | searching 1 changesets for largefiles |
|
241 | searching 1 changesets for largefiles | |
242 | changeset 0:cf03e5bb9936: f1 missing |
|
242 | changeset 0:cf03e5bb9936: f1 missing | |
243 | verified existence of 1 revisions of 1 largefiles |
|
243 | verified existence of 1 revisions of 1 largefiles | |
244 | [1] |
|
244 | [1] | |
245 | $ mv 02a439e5c31c526465ab1a0ca1f431f76b827b90 empty/.hg/largefiles/ |
|
245 | $ mv 02a439e5c31c526465ab1a0ca1f431f76b827b90 empty/.hg/largefiles/ | |
246 | $ hg -R http-clone -q verify --large --lfa |
|
246 | $ hg -R http-clone -q verify --large --lfa | |
247 |
|
247 | |||
248 | largefiles pulled on update - a largefile missing on the server: |
|
248 | largefiles pulled on update - a largefile missing on the server: | |
249 | $ mv empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 . |
|
249 | $ mv empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 . | |
250 | $ hg -R http-clone up --config largefiles.usercache=http-clone-usercache |
|
250 | $ hg -R http-clone up --config largefiles.usercache=http-clone-usercache | |
251 | getting changed largefiles |
|
251 | getting changed largefiles | |
252 | f1: largefile 02a439e5c31c526465ab1a0ca1f431f76b827b90 not available from http://localhost:$HGPORT2/ |
|
252 | f1: largefile 02a439e5c31c526465ab1a0ca1f431f76b827b90 not available from http://localhost:$HGPORT2/ | |
253 | 0 largefiles updated, 0 removed |
|
253 | 0 largefiles updated, 0 removed | |
254 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
254 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
255 | $ hg -R http-clone st |
|
255 | $ hg -R http-clone st | |
256 | ! f1 |
|
256 | ! f1 | |
257 | $ hg -R http-clone up -Cqr null |
|
257 | $ hg -R http-clone up -Cqr null | |
258 |
|
258 | |||
259 | largefiles pulled on update - a largefile corrupted on the server: |
|
259 | largefiles pulled on update - a largefile corrupted on the server: | |
260 | $ echo corruption > empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 |
|
260 | $ echo corruption > empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 | |
261 | $ hg -R http-clone up --config largefiles.usercache=http-clone-usercache |
|
261 | $ hg -R http-clone up --config largefiles.usercache=http-clone-usercache | |
262 | getting changed largefiles |
|
262 | getting changed largefiles | |
263 | f1: data corruption (expected 02a439e5c31c526465ab1a0ca1f431f76b827b90, got 6a7bb2556144babe3899b25e5428123735bb1e27) |
|
263 | f1: data corruption (expected 02a439e5c31c526465ab1a0ca1f431f76b827b90, got 6a7bb2556144babe3899b25e5428123735bb1e27) | |
264 | 0 largefiles updated, 0 removed |
|
264 | 0 largefiles updated, 0 removed | |
265 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
265 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
266 | $ hg -R http-clone st |
|
266 | $ hg -R http-clone st | |
267 | ! f1 |
|
267 | ! f1 | |
268 | $ [ ! -f http-clone/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 ] |
|
268 | $ [ ! -f http-clone/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 ] | |
269 | $ [ ! -f http-clone/f1 ] |
|
269 | $ [ ! -f http-clone/f1 ] | |
270 | $ [ ! -f http-clone-usercache ] |
|
270 | $ [ ! -f http-clone-usercache ] | |
271 | $ hg -R http-clone verify --large --lfc |
|
271 | $ hg -R http-clone verify --large --lfc | |
272 | checking changesets |
|
272 | checking changesets | |
273 | checking manifests |
|
273 | checking manifests | |
274 | crosschecking files in changesets and manifests |
|
274 | crosschecking files in changesets and manifests | |
275 | checking files |
|
275 | checking files | |
276 | 1 files, 1 changesets, 1 total revisions |
|
276 | 1 files, 1 changesets, 1 total revisions | |
277 | searching 1 changesets for largefiles |
|
277 | searching 1 changesets for largefiles | |
278 | verified contents of 1 revisions of 1 largefiles |
|
278 | verified contents of 1 revisions of 1 largefiles | |
279 | $ hg -R http-clone up -Cqr null |
|
279 | $ hg -R http-clone up -Cqr null | |
280 |
|
280 | |||
281 | largefiles pulled on update - no server side problems: |
|
281 | largefiles pulled on update - no server side problems: | |
282 | $ mv 02a439e5c31c526465ab1a0ca1f431f76b827b90 empty/.hg/largefiles/ |
|
282 | $ mv 02a439e5c31c526465ab1a0ca1f431f76b827b90 empty/.hg/largefiles/ | |
283 | $ hg -R http-clone --debug up --config largefiles.usercache=http-clone-usercache --config progress.debug=true |
|
283 | $ hg -R http-clone --debug up --config largefiles.usercache=http-clone-usercache --config progress.debug=true | |
284 | resolving manifests |
|
284 | resolving manifests | |
285 | branchmerge: False, force: False, partial: False |
|
285 | branchmerge: False, force: False, partial: False | |
286 | ancestor: 000000000000, local: 000000000000+, remote: cf03e5bb9936 |
|
286 | ancestor: 000000000000, local: 000000000000+, remote: cf03e5bb9936 | |
287 | .hglf/f1: remote created -> g |
|
287 | .hglf/f1: remote created -> g | |
288 | getting .hglf/f1 |
|
288 | getting .hglf/f1 | |
289 | updating: .hglf/f1 1/1 files (100.00%) |
|
289 | updating: .hglf/f1 1/1 files (100.00%) | |
290 | getting changed largefiles |
|
290 | getting changed largefiles | |
291 | using http://localhost:$HGPORT2/ |
|
291 | using http://localhost:$HGPORT2/ | |
292 | sending capabilities command |
|
292 | sending capabilities command | |
293 | sending batch command |
|
293 | sending batch command | |
294 | getting largefiles: 0/1 files (0.00%) |
|
294 | getting largefiles: 0/1 files (0.00%) | |
295 | getting f1:02a439e5c31c526465ab1a0ca1f431f76b827b90 |
|
295 | getting f1:02a439e5c31c526465ab1a0ca1f431f76b827b90 | |
296 | sending getlfile command |
|
296 | sending getlfile command | |
297 | found 02a439e5c31c526465ab1a0ca1f431f76b827b90 in store |
|
297 | found 02a439e5c31c526465ab1a0ca1f431f76b827b90 in store | |
298 | 1 largefiles updated, 0 removed |
|
298 | 1 largefiles updated, 0 removed | |
299 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
299 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
300 |
|
300 | |||
301 | $ ls http-clone-usercache/* |
|
301 | $ ls http-clone-usercache/* | |
302 | http-clone-usercache/02a439e5c31c526465ab1a0ca1f431f76b827b90 |
|
302 | http-clone-usercache/02a439e5c31c526465ab1a0ca1f431f76b827b90 | |
303 |
|
303 | |||
304 | $ rm -rf empty http-clone* |
|
304 | $ rm -rf empty http-clone* | |
305 |
|
305 | |||
306 | used all HGPORTs, kill all daemons |
|
306 | used all HGPORTs, kill all daemons | |
307 | $ killdaemons.py |
|
307 | $ killdaemons.py | |
308 |
|
308 | |||
309 | largefiles should batch verify remote calls |
|
309 | largefiles should batch verify remote calls | |
310 |
|
310 | |||
311 | $ hg init batchverifymain |
|
311 | $ hg init batchverifymain | |
312 | $ cd batchverifymain |
|
312 | $ cd batchverifymain | |
313 | $ echo "aaa" >> a |
|
313 | $ echo "aaa" >> a | |
314 | $ hg add --large a |
|
314 | $ hg add --large a | |
315 | $ hg commit -m "a" |
|
315 | $ hg commit -m "a" | |
316 | Invoking status precommit hook |
|
316 | Invoking status precommit hook | |
317 | A a |
|
317 | A a | |
318 | $ echo "bbb" >> b |
|
318 | $ echo "bbb" >> b | |
319 | $ hg add --large b |
|
319 | $ hg add --large b | |
320 | $ hg commit -m "b" |
|
320 | $ hg commit -m "b" | |
321 | Invoking status precommit hook |
|
321 | Invoking status precommit hook | |
322 | A b |
|
322 | A b | |
323 | $ cd .. |
|
323 | $ cd .. | |
324 | $ hg serve -R batchverifymain -d -p $HGPORT --pid-file hg.pid \ |
|
324 | $ hg serve -R batchverifymain -d -p $HGPORT --pid-file hg.pid \ | |
325 | > -A access.log |
|
325 | > -A access.log | |
326 | $ cat hg.pid >> $DAEMON_PIDS |
|
326 | $ cat hg.pid >> $DAEMON_PIDS | |
327 | $ hg clone http://localhost:$HGPORT batchverifyclone |
|
327 | $ hg clone --noupdate http://localhost:$HGPORT batchverifyclone | |
328 | requesting all changes |
|
328 | requesting all changes | |
329 | adding changesets |
|
329 | adding changesets | |
330 | adding manifests |
|
330 | adding manifests | |
331 | adding file changes |
|
331 | adding file changes | |
332 | added 2 changesets with 2 changes to 2 files |
|
332 | added 2 changesets with 2 changes to 2 files | |
333 | updating to branch default |
|
333 | $ hg -R batchverifyclone verify --large --lfa | |
334 | getting changed largefiles |
|
|||
335 | 2 largefiles updated, 0 removed |
|
|||
336 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
|||
337 | $ hg -R batchverifyclone verify --large |
|
|||
338 | checking changesets |
|
334 | checking changesets | |
339 | checking manifests |
|
335 | checking manifests | |
340 | crosschecking files in changesets and manifests |
|
336 | crosschecking files in changesets and manifests | |
341 | checking files |
|
337 | checking files | |
342 | 2 files, 2 changesets, 2 total revisions |
|
338 | 2 files, 2 changesets, 2 total revisions | |
343 |
searching |
|
339 | searching 2 changesets for largefiles | |
344 | verified existence of 2 revisions of 2 largefiles |
|
340 | verified existence of 2 revisions of 2 largefiles | |
345 | $ tail -1 access.log |
|
341 | $ tail -1 access.log | |
346 | 127.0.0.1 - - [*] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=statlfile+sha%3D972a1a11f19934401291cc99117ec614933374ce%3Bstatlfile+sha%3Dc801c9cfe94400963fcb683246217d5db77f9a9a (glob) |
|
342 | 127.0.0.1 - - [*] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=statlfile+sha%3D972a1a11f19934401291cc99117ec614933374ce%3Bstatlfile+sha%3Dc801c9cfe94400963fcb683246217d5db77f9a9a (glob) | |
347 | $ rm access.log |
|
343 | $ hg -R batchverifyclone update | |
|
344 | getting changed largefiles | |||
|
345 | 2 largefiles updated, 0 removed | |||
|
346 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
347 | ||||
|
348 | Clear log file before next test | |||
|
349 | ||||
|
350 | $ printf "" > access.log | |||
|
351 | ||||
|
352 | Verify should check file on remote server only when file is not | |||
|
353 | available locally. | |||
|
354 | ||||
|
355 | $ echo "ccc" >> batchverifymain/c | |||
|
356 | $ hg -R batchverifymain status | |||
|
357 | ? c | |||
|
358 | $ hg -R batchverifymain add --large batchverifymain/c | |||
|
359 | $ hg -R batchverifymain commit -m "c" | |||
|
360 | Invoking status precommit hook | |||
|
361 | A c | |||
|
362 | $ hg -R batchverifyclone pull | |||
|
363 | pulling from http://localhost:$HGPORT/ | |||
|
364 | searching for changes | |||
|
365 | adding changesets | |||
|
366 | adding manifests | |||
|
367 | adding file changes | |||
|
368 | added 1 changesets with 1 changes to 1 files | |||
|
369 | (run 'hg update' to get a working copy) | |||
|
370 | $ hg -R batchverifyclone verify --lfa | |||
|
371 | checking changesets | |||
|
372 | checking manifests | |||
|
373 | crosschecking files in changesets and manifests | |||
|
374 | checking files | |||
|
375 | 3 files, 3 changesets, 3 total revisions | |||
|
376 | searching 3 changesets for largefiles | |||
|
377 | verified existence of 3 revisions of 3 largefiles | |||
|
378 | $ tail -1 access.log | |||
|
379 | 127.0.0.1 - - [*] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=statlfile+sha%3Dc8559c3c9cfb42131794b7d8009230403b9b454c (glob) | |||
348 |
|
380 | |||
349 | $ killdaemons.py |
|
381 | $ killdaemons.py | |
350 |
|
382 | |||
351 | #endif |
|
383 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now