hgext/largefiles/lfutil.py
branchstable
changeset 26823 45e8bd2f36f0
parent 26817 b68797f244e4
child 27903 512a814c5595
--- 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):