--- a/hgext/largefiles/lfutil.py Fri Oct 23 21:27:29 2015 +0200
+++ b/hgext/largefiles/lfutil.py Fri Oct 23 21:27:29 2015 +0200
@@ -10,7 +10,6 @@
import os
import platform
-import shutil
import stat
import copy
@@ -207,7 +206,15 @@
util.makedirs(os.path.dirname(repo.wjoin(filename)))
# The write may fail before the file is fully written, but we
# don't use atomic writes in the working copy.
- shutil.copy(path, repo.wjoin(filename))
+ dest = repo.wjoin(filename)
+ with open(path, 'rb') as srcfd:
+ with open(dest, 'wb') as destfd:
+ gothash = copyandhash(srcfd, destfd)
+ if gothash != hash:
+ repo.ui.warn(_('%s: data corruption in %s with hash %s\n')
+ % (filename, path, gothash))
+ util.unlink(dest)
+ return False
return True
def copytostore(repo, rev, file, uploaded=False):