changeset 19156:ed1a212193dc stable

subrepo: open files in 'rb' mode to read exact data in (issue3926) Before this patch, "subrepo._calcfilehash()" opens files by "open()" without any mode specification. This implies "text mode" on Windows. When target file contains '\x00' byte, "read()" in "text mode" reads file contents in without data after '\x00'. This causes invalid SHA1 hash calculation in "subrepo._calcfilehash()". This patch opens files in 'rb' mode to read exact data in.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Thu, 09 May 2013 21:09:58 +0900
parents 0a12e5f3a979
children c9431c711ddb 1b329f8c7b24
files mercurial/subrepo.py
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Fri May 03 19:34:59 2013 +0200
+++ b/mercurial/subrepo.py	Thu May 09 21:09:58 2013 +0900
@@ -31,7 +31,7 @@
 def _calcfilehash(filename):
     data = ''
     if os.path.exists(filename):
-        fd = open(filename)
+        fd = open(filename, 'rb')
         data = fd.read()
         fd.close()
     return util.sha1(data).hexdigest()