##// END OF EJS Templates
tests: update test-largefiles-small-disk to pass our import checker
Augie Fackler -
r33964:99113426 default
parent child Browse files
Show More
@@ -1,71 +1,74 b''
1 1 Test how largefiles abort in case the disk runs full
2 2
3 3 $ cat > criple.py <<EOF
4 > import os, errno, shutil
4 > from __future__ import absolute_import
5 > import errno
6 > import os
7 > import shutil
5 8 > from mercurial import util
6 9 > #
7 10 > # this makes the original largefiles code abort:
8 11 > _origcopyfileobj = shutil.copyfileobj
9 12 > def copyfileobj(fsrc, fdst, length=16*1024):
10 13 > # allow journal files (used by transaction) to be written
11 14 > if 'journal.' in fdst.name:
12 15 > return _origcopyfileobj(fsrc, fdst, length)
13 16 > fdst.write(fsrc.read(4))
14 17 > raise IOError(errno.ENOSPC, os.strerror(errno.ENOSPC))
15 18 > shutil.copyfileobj = copyfileobj
16 19 > #
17 20 > # this makes the rewritten code abort:
18 21 > def filechunkiter(f, size=131072, limit=None):
19 22 > yield f.read(4)
20 23 > raise IOError(errno.ENOSPC, os.strerror(errno.ENOSPC))
21 24 > util.filechunkiter = filechunkiter
22 25 > #
23 26 > def oslink(src, dest):
24 27 > raise OSError("no hardlinks, try copying instead")
25 28 > util.oslink = oslink
26 29 > EOF
27 30
28 31 $ echo "[extensions]" >> $HGRCPATH
29 32 $ echo "largefiles =" >> $HGRCPATH
30 33
31 34 $ hg init alice
32 35 $ cd alice
33 36 $ echo "this is a very big file" > big
34 37 $ hg add --large big
35 38 $ hg commit --config extensions.criple=$TESTTMP/criple.py -m big
36 39 abort: No space left on device
37 40 [255]
38 41
39 42 The largefile is not created in .hg/largefiles:
40 43
41 44 $ ls .hg/largefiles
42 45 dirstate
43 46
44 47 The user cache is not even created:
45 48
46 49 >>> import os; os.path.exists("$HOME/.cache/largefiles/")
47 50 False
48 51
49 52 Make the commit with space on the device:
50 53
51 54 $ hg commit -m big
52 55
53 56 Now make a clone with a full disk, and make sure lfutil.link function
54 57 makes copies instead of hardlinks:
55 58
56 59 $ cd ..
57 60 $ hg --config extensions.criple=$TESTTMP/criple.py clone --pull alice bob
58 61 requesting all changes
59 62 adding changesets
60 63 adding manifests
61 64 adding file changes
62 65 added 1 changesets with 1 changes to 1 files
63 66 updating to branch default
64 67 getting changed largefiles
65 68 abort: No space left on device
66 69 [255]
67 70
68 71 The largefile is not created in .hg/largefiles:
69 72
70 73 $ ls bob/.hg/largefiles
71 74 dirstate
General Comments 0
You need to be logged in to leave comments. Login now