##// END OF EJS Templates
largefiles: check hash of files in the store before copying to working dir...
Mads Kiilerich -
r26823:45e8bd2f stable
parent child Browse files
Show More
@@ -10,7 +10,6 b''
10
10
11 import os
11 import os
12 import platform
12 import platform
13 import shutil
14 import stat
13 import stat
15 import copy
14 import copy
16
15
@@ -207,7 +206,15 b' def copyfromcache(repo, hash, filename):'
207 util.makedirs(os.path.dirname(repo.wjoin(filename)))
206 util.makedirs(os.path.dirname(repo.wjoin(filename)))
208 # The write may fail before the file is fully written, but we
207 # The write may fail before the file is fully written, but we
209 # don't use atomic writes in the working copy.
208 # don't use atomic writes in the working copy.
210 shutil.copy(path, repo.wjoin(filename))
209 dest = repo.wjoin(filename)
210 with open(path, 'rb') as srcfd:
211 with open(dest, 'wb') as destfd:
212 gothash = copyandhash(srcfd, destfd)
213 if gothash != hash:
214 repo.ui.warn(_('%s: data corruption in %s with hash %s\n')
215 % (filename, path, gothash))
216 util.unlink(dest)
217 return False
211 return True
218 return True
212
219
213 def copytostore(repo, rev, file, uploaded=False):
220 def copytostore(repo, rev, file, uploaded=False):
@@ -191,13 +191,12 b' Inject corruption into the largefiles st'
191 e2fb5f2139d086ded2cb600d5a91a196e76bf020
191 e2fb5f2139d086ded2cb600d5a91a196e76bf020
192 $ mv .hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020 ..
192 $ mv .hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020 ..
193 $ echo corruption > .hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020
193 $ echo corruption > .hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020
194 (the following update will put the corrupted file into the working directory
195 where it will show up as a change)
196 $ hg up -C
194 $ hg up -C
197 getting changed largefiles
195 getting changed largefiles
198 1 largefiles updated, 0 removed
196 large: data corruption in $TESTTMP/src/.hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020 with hash 6a7bb2556144babe3899b25e5428123735bb1e27
197 0 largefiles updated, 0 removed
199 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
198 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
200 $ hg st
199 $ hg st
201 M large
200 ! large
202 ? z
201 ? z
203 $ rm .hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020
202 $ rm .hg/largefiles/e2fb5f2139d086ded2cb600d5a91a196e76bf020
General Comments 0
You need to be logged in to leave comments. Login now