Debian Codegraph @

tests/test-largefiles-cache.t

raw
1 Create user cache directory
2
3 $ USERCACHE=`pwd`/cache; export USERCACHE
4 $ cat <<EOF >> ${HGRCPATH}
5 > [extensions]
6 > hgext.largefiles=
7 > [largefiles]
8 > usercache=${USERCACHE}
9 > EOF
10 $ mkdir -p ${USERCACHE}
11
12 Create source repo, and commit adding largefile.
13
14 $ hg init src
15 $ cd src
16 $ echo large > large
17 $ hg add --large large
18 $ hg commit -m 'add largefile'
19 $ hg rm large
20 $ hg commit -m 'branchhead without largefile' large
21 $ hg up -qr 0
22 $ rm large
23 $ echo "0000000000000000000000000000000000000000" > .hglf/large
24 $ hg commit -m 'commit missing file with corrupt standin' large
25 abort: large: file not found!
26 [255]
27 $ hg up -Cqr 0
28 $ cd ..
29
30 Discard all cached largefiles in USERCACHE
31
32 $ rm -rf ${USERCACHE}
33
34 Create mirror repo, and pull from source without largefile:
35 "pull" is used instead of "clone" for suppression of (1) updating to
36 tip (= caching largefile from source repo), and (2) recording source
37 repo as "default" path in .hg/hgrc.
38
39 $ hg init mirror
40 $ cd mirror
41 $ hg pull ../src
42 pulling from ../src
43 requesting all changes
44 adding changesets
45 adding manifests
46 adding file changes
47 added 2 changesets with 1 changes to 1 files
48 new changesets eb85d9124f3f:26c18ce05e4e
49 (run 'hg update' to get a working copy)
50
51 Update working directory to "tip", which requires largefile("large"),
52 but there is no cache file for it. So, hg must treat it as
53 "missing"(!) file.
54
55 $ hg update -r0
56 getting changed largefiles
57 large: largefile 7f7097b041ccf68cc5561e9600da4655d21c6d18 not available from file:/*/$TESTTMP/mirror (glob)
58 0 largefiles updated, 0 removed
59 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
60 $ hg status
61 ! large
62
63 Update working directory to null: this cleanup .hg/largefiles/dirstate
64
65 $ hg update null
66 getting changed largefiles
67 0 largefiles updated, 0 removed
68 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
69
70 Update working directory to tip, again.
71
72 $ hg update -r0
73 getting changed largefiles
74 large: largefile 7f7097b041ccf68cc5561e9600da4655d21c6d18 not available from file:/*/$TESTTMP/mirror (glob)
75 0 largefiles updated, 0 removed
76 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
77 $ hg status
78 ! large
79 $ cd ..
80
81 Verify that largefiles from pulled branchheads are fetched, also to an empty repo
82
83 $ hg init mirror2
84 $ hg -R mirror2 pull src -r0
85 pulling from src
86 adding changesets
87 adding manifests
88 adding file changes
89 added 1 changesets with 1 changes to 1 files
90 new changesets eb85d9124f3f
91 (run 'hg update' to get a working copy)
92
93 #if unix-permissions
94
95 Portable way to print file permissions:
96
97 $ cat > ls-l.py <<EOF
98 > #!$PYTHON
99 > import os
100 > import sys
101 > path = sys.argv[1]
102 > print('%03o' % (os.lstat(path).st_mode & 0o777))
103 > EOF
104 $ chmod +x ls-l.py
105
106 Test that files in .hg/largefiles inherit mode from .hg/store, not
107 from file in working copy:
108
109 $ cd src
110 $ chmod 750 .hg/store
111 $ chmod 660 large
112 $ echo change >> large
113 $ hg commit -m change
114 created new head
115 $ ../ls-l.py .hg/largefiles/e151b474069de4ca6898f67ce2f2a7263adf8fea
116 640
117
118 Test permission of with files in .hg/largefiles created by update:
119
120 $ cd ../mirror
121 $ rm -r "$USERCACHE" .hg/largefiles # avoid links
122 $ chmod 750 .hg/store
123 $ hg pull ../src --update -q
124 $ ../ls-l.py .hg/largefiles/e151b474069de4ca6898f67ce2f2a7263adf8fea
125 640
126
127 Test permission of files created by push:
128
129 $ hg serve -R ../src -d -p $HGPORT --pid-file hg.pid \
130 > --config "web.allow_push=*" --config web.push_ssl=no
131 $ cat hg.pid >> $DAEMON_PIDS
132
133 $ echo change >> large
134 $ hg commit -m change
135
136 $ rm -r "$USERCACHE"
137
138 $ hg push -q http://localhost:$HGPORT/
139
140 $ ../ls-l.py ../src/.hg/largefiles/b734e14a0971e370408ab9bce8d56d8485e368a9
141 640
142
143 $ cd ..
144
145 #else
146
147 This is deleted by `hg push` in the other block above.
148
149 $ rm src/.hg/largefiles/undo.backup.dirstate.bck
150
151 #endif
152
153 Test issue 4053 (remove --after on a deleted, uncommitted file shouldn't say
154 it is missing, but a remove on a nonexistent unknown file still should. Same
155 for a forget.)
156
157 $ cd src
158 $ touch x
159 $ hg add x
160 $ mv x y
161 $ hg remove -A x y ENOENT
162 ENOENT: * (glob)
163 not removing y: file is untracked
164 [1]
165 $ hg add y
166 $ mv y z
167 $ hg forget y z ENOENT
168 ENOENT: * (glob)
169 not removing z: file is already untracked
170 [1]
171
172 Largefiles are accessible from the share's store
173 $ cd ..
174 $ hg share -q src share_dst --config extensions.share=
175 $ hg -R share_dst update -r0
176 getting changed largefiles
177 1 largefiles updated, 0 removed
178 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
179
180 $ echo modified > share_dst/large
181 $ hg -R share_dst ci -m modified
182 created new head
183
184 Only dirstate is in the local store for the share, and the largefile is in the
185 share source's local store. Avoid the extra largefiles added in the unix
186 conditional above.
187 $ hash=`hg -R share_dst cat share_dst/.hglf/large`
188 $ echo $hash
189 e2fb5f2139d086ded2cb600d5a91a196e76bf020
190
191 $ find share_dst/.hg/largefiles/* | sort
192 share_dst/.hg/largefiles/dirstate
193 share_dst/.hg/largefiles/undo.backup.dirstate.bck
194
195 $ find src/.hg/largefiles/* | grep -E "(dirstate|$hash)" | sort
196 src/.hg/largefiles/dirstate
197 src/.hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020
198
199 Verify that backwards compatibility is maintained for old storage layout
200 $ mv src/.hg/largefiles/$hash share_dst/.hg/largefiles
201 $ hg verify --quiet --lfa -R share_dst --config largefiles.usercache=
202
203 Inject corruption into the largefiles store and see how update handles that:
204
205 $ cd src
206 $ hg up -qC tip
207 $ cat large
208 modified
209 $ rm large
210 $ cat .hglf/large
211 e2fb5f2139d086ded2cb600d5a91a196e76bf020
212 $ mv .hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020 ..
213 $ echo corruption > .hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020
214 $ hg up -C
215 getting changed largefiles
216 large: data corruption in $TESTTMP/src/.hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020 with hash 6a7bb2556144babe3899b25e5428123735bb1e27
217 0 largefiles updated, 0 removed
218 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
219 updated to "cd24c147f45c: modified"
220 [12] other heads for branch "default" (re)
221 $ hg st
222 ! large
223 ? z
224 $ rm .hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020
225
226 #if serve
227
228 Test coverage of error handling from putlfile:
229
230 $ mkdir $TESTTMP/mirrorcache
231 $ hg serve -R ../mirror -d -p $HGPORT1 --pid-file hg.pid --config largefiles.usercache=$TESTTMP/mirrorcache
232 $ cat hg.pid >> $DAEMON_PIDS
233
234 $ hg push http://localhost:$HGPORT1 -f --config files.usercache=nocache
235 pushing to http://localhost:$HGPORT1/
236 searching for changes
237 abort: remotestore: could not open file $TESTTMP/src/.hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020: HTTP Error 403: ssl required
238 [255]
239
240 $ rm .hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020
241
242 Test coverage of 'missing from store':
243
244 $ hg serve -R ../mirror -d -p $HGPORT2 --pid-file hg.pid --config largefiles.usercache=$TESTTMP/mirrorcache --config "web.allow_push=*" --config web.push_ssl=no
245 $ cat hg.pid >> $DAEMON_PIDS
246
247 $ hg push http://localhost:$HGPORT2 -f --config largefiles.usercache=nocache
248 pushing to http://localhost:$HGPORT2/
249 searching for changes
250 abort: largefile e2fb5f2139d086ded2cb600d5a91a196e76bf020 missing from store (needs to be uploaded)
251 [255]
252
253 Verify that --lfrev controls which revisions are checked for largefiles to push
254
255 $ hg push http://localhost:$HGPORT2 -f --config largefiles.usercache=nocache --lfrev tip
256 pushing to http://localhost:$HGPORT2/
257 searching for changes
258 abort: largefile e2fb5f2139d086ded2cb600d5a91a196e76bf020 missing from store (needs to be uploaded)
259 [255]
260
261 $ hg push http://localhost:$HGPORT2 -f --config largefiles.usercache=nocache --lfrev null
262 pushing to http://localhost:$HGPORT2/
263 searching for changes
264 remote: adding changesets
265 remote: adding manifests
266 remote: adding file changes
267 remote: added 1 changesets with 1 changes to 1 files (+1 heads)
268
269 #endif