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