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