##// END OF EJS Templates
largefiles: copy files into .hg/largefiles atomically...
Martin Geisler -
r15572:926bc23d stable
parent child Browse files
Show More
@@ -77,8 +77,11 b' def link(src, dest):'
77 try:
77 try:
78 util.oslink(src, dest)
78 util.oslink(src, dest)
79 except OSError:
79 except OSError:
80 # if hardlinks fail, fallback on copy
80 # if hardlinks fail, fallback on atomic copy
81 shutil.copyfile(src, dest)
81 dst = util.atomictempfile(dest)
82 for chunk in util.filechunkiter(open(src)):
83 dst.write(chunk)
84 dst.close()
82 os.chmod(dest, os.stat(src).st_mode)
85 os.chmod(dest, os.stat(src).st_mode)
83
86
84 def usercachepath(ui, hash):
87 def usercachepath(ui, hash):
@@ -15,6 +15,10 b' Test how largefiles abort in case the di'
15 > yield f.read(4)
15 > yield f.read(4)
16 > raise IOError(errno.ENOSPC, os.strerror(errno.ENOSPC))
16 > raise IOError(errno.ENOSPC, os.strerror(errno.ENOSPC))
17 > util.filechunkiter = filechunkiter
17 > util.filechunkiter = filechunkiter
18 > #
19 > def oslink(src, dest):
20 > raise OSError("no hardlinks, try copying instead")
21 > util.oslink = oslink
18 > EOF
22 > EOF
19
23
20 $ echo "[extensions]" >> $HGRCPATH
24 $ echo "[extensions]" >> $HGRCPATH
@@ -37,3 +41,28 b' The user cache is not even created:'
37
41
38 >>> import os; os.path.exists("$HOME/.cache/largefiles/")
42 >>> import os; os.path.exists("$HOME/.cache/largefiles/")
39 False
43 False
44
45 Make the commit with space on the device:
46
47 $ hg commit -m big
48
49 Now make a clone with a full disk, and make sure lfutil.link function
50 makes copies instead of hardlinks:
51
52 $ cd ..
53 $ hg --config extensions.criple=$TESTTMP/criple.py clone --pull alice bob
54 requesting all changes
55 adding changesets
56 adding manifests
57 adding file changes
58 added 1 changesets with 1 changes to 1 files
59 updating to branch default
60 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
61 getting changed largefiles
62 abort: No space left on device
63 [255]
64
65 The largefile is not created in .hg/largefiles:
66
67 $ ls bob/.hg/largefiles
68 dirstate
General Comments 0
You need to be logged in to leave comments. Login now