author | Martin Geisler <mg@aragost.com> |
Thu, 24 Nov 2011 18:12:13 +0100 | |
branch | stable |
changeset 15571 | 809788118aa2 |
child 15572 | 926bc23d0b6a |
permissions | -rw-r--r-- |
15571
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
1 |
Test how largefiles abort in case the disk runs full |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
2 |
|
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
3 |
$ cat > criple.py <<EOF |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
4 |
> import os, errno, shutil |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
5 |
> from mercurial import util |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
6 |
> # |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
7 |
> # this makes the original largefiles code abort: |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
8 |
> def copyfileobj(fsrc, fdst, length=16*1024): |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
9 |
> fdst.write(fsrc.read(4)) |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
10 |
> raise IOError(errno.ENOSPC, os.strerror(errno.ENOSPC)) |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
11 |
> shutil.copyfileobj = copyfileobj |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
12 |
> # |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
13 |
> # this makes the rewritten code abort: |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
14 |
> def filechunkiter(f, size=65536, limit=None): |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
15 |
> yield f.read(4) |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
16 |
> raise IOError(errno.ENOSPC, os.strerror(errno.ENOSPC)) |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
17 |
> util.filechunkiter = filechunkiter |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
18 |
> EOF |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
19 |
|
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
20 |
$ echo "[extensions]" >> $HGRCPATH |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
21 |
$ echo "largefiles =" >> $HGRCPATH |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
22 |
|
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
23 |
$ hg init alice |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
24 |
$ cd alice |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
25 |
$ echo "this is a very big file" > big |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
26 |
$ hg add --large big |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
27 |
$ hg commit --config extensions.criple=$TESTTMP/criple.py -m big |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
28 |
abort: No space left on device |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
29 |
[255] |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
30 |
|
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
31 |
The largefile is not created in .hg/largefiles: |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
32 |
|
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
33 |
$ ls .hg/largefiles |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
34 |
dirstate |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
35 |
|
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
36 |
The user cache is not even created: |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
37 |
|
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
38 |
>>> import os; os.path.exists("$HOME/.cache/largefiles/") |
809788118aa2
largefiles: write .hg/largefiles/ files atomically
Martin Geisler <mg@aragost.com>
parents:
diff
changeset
|
39 |
False |