Show More
@@ -0,0 +1,39 b'' | |||||
|
1 | Test how largefiles abort in case the disk runs full | |||
|
2 | ||||
|
3 | $ cat > criple.py <<EOF | |||
|
4 | > import os, errno, shutil | |||
|
5 | > from mercurial import util | |||
|
6 | > # | |||
|
7 | > # this makes the original largefiles code abort: | |||
|
8 | > def copyfileobj(fsrc, fdst, length=16*1024): | |||
|
9 | > fdst.write(fsrc.read(4)) | |||
|
10 | > raise IOError(errno.ENOSPC, os.strerror(errno.ENOSPC)) | |||
|
11 | > shutil.copyfileobj = copyfileobj | |||
|
12 | > # | |||
|
13 | > # this makes the rewritten code abort: | |||
|
14 | > def filechunkiter(f, size=65536, limit=None): | |||
|
15 | > yield f.read(4) | |||
|
16 | > raise IOError(errno.ENOSPC, os.strerror(errno.ENOSPC)) | |||
|
17 | > util.filechunkiter = filechunkiter | |||
|
18 | > EOF | |||
|
19 | ||||
|
20 | $ echo "[extensions]" >> $HGRCPATH | |||
|
21 | $ echo "largefiles =" >> $HGRCPATH | |||
|
22 | ||||
|
23 | $ hg init alice | |||
|
24 | $ cd alice | |||
|
25 | $ echo "this is a very big file" > big | |||
|
26 | $ hg add --large big | |||
|
27 | $ hg commit --config extensions.criple=$TESTTMP/criple.py -m big | |||
|
28 | abort: No space left on device | |||
|
29 | [255] | |||
|
30 | ||||
|
31 | The largefile is not created in .hg/largefiles: | |||
|
32 | ||||
|
33 | $ ls .hg/largefiles | |||
|
34 | dirstate | |||
|
35 | ||||
|
36 | The user cache is not even created: | |||
|
37 | ||||
|
38 | >>> import os; os.path.exists("$HOME/.cache/largefiles/") | |||
|
39 | False |
@@ -228,8 +228,11 b' def copytostoreabsolute(repo, file, hash' | |||||
228 | if inusercache(repo.ui, hash): |
|
228 | if inusercache(repo.ui, hash): | |
229 | link(usercachepath(repo.ui, hash), storepath(repo, hash)) |
|
229 | link(usercachepath(repo.ui, hash), storepath(repo, hash)) | |
230 | else: |
|
230 | else: | |
231 |
|
|
231 | dst = util.atomictempfile(storepath(repo, hash)) | |
232 | os.chmod(storepath(repo, hash), os.stat(file).st_mode) |
|
232 | for chunk in util.filechunkiter(open(file)): | |
|
233 | dst.write(chunk) | |||
|
234 | dst.close() | |||
|
235 | util.copymode(file, storepath(repo, hash)) | |||
233 | linktousercache(repo, hash) |
|
236 | linktousercache(repo, hash) | |
234 |
|
237 | |||
235 | def linktousercache(repo, hash): |
|
238 | def linktousercache(repo, hash): |
General Comments 0
You need to be logged in to leave comments.
Login now