Submitter | Katsunori FUJIWARA |
---|---|
Date | May 9, 2013, 12:29 p.m. |
Message ID | <ed1a212193dc237edc35.1368102587@juju> |
Download | mbox | patch |
Permalink | /patch/1602/ |
State | Accepted, archived |
Headers | show |
Comments
On Thu, May 09, 2013 at 09:29:47PM +0900, FUJIWARA Katsunori wrote: > # HG changeset patch > # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp> > # Date 1368101398 -32400 > # Thu May 09 21:09:58 2013 +0900 > # Branch stable > # Node ID ed1a212193dc237edc350330146128a13641e38f > # Parent 0a12e5f3a979ee302dc10647483200df00a105ab > subrepo: open files in 'rb' mode to read exact data in (issue3926) queued for stable, thanks > > 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. > > diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py > --- a/mercurial/subrepo.py > +++ b/mercurial/subrepo.py > @@ -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() > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > http://selenic.com/mailman/listinfo/mercurial-devel
Patch
diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -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()