[Bug 153493] Re: status gives false positives for text files with CRLF (@win32)
John Arbash Meinel
john at arbash-meinel.com
Mon Oct 22 14:57:39 BST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Alexander Belchenko wrote:
> This regression was introduced by revno.2894 (Martin Pool) with log
> message:
>
> add -Dhashcache, sha_file_by_name using raw os files rather than file
> objects (mbp)
>
>
> I think bug actually in following line:
>
> === modified file 'bzrlib/osutils.py'
> --- bzrlib/osutils.py 04.10.2007 8:09:58
> +++ bzrlib/osutils.py 08.10.2007 8:09:59
> @@ -590,6 +590,20 @@
> return s.hexdigest()
>
>
> +def sha_file_by_name(fname):
> + """Calculate the SHA1 of a file by reading the full text"""
> + s = sha.new()
> + f = os.open(fname, os.O_RDONLY)
>
> ^-- I believe on Windows it should be:
>
> + f = os.open(fname, os.O_RDONLY|os.O_BINARY)
>
> And this change indeed fixes regression.
> The problem here is O_BINARY flag itself. According to Python
> documentation this flag exists only on Windows.
> So probably fix should be something like this:
>
> === modified file 'bzrlib/osutils.py'
> --- bzrlib/osutils.py 2007-10-08 05:09:59 +0000
> +++ bzrlib/osutils.py 2007-10-22 10:57:42 +0000
> @@ -590,10 +590,15 @@
> return s.hexdigest()
>
>
> +if sys.platform == 'win32':
> + OS_OPEN_FLAGS = os.O_RDONLY | os.O_BINARY
> +else:
> + OS_OPEN_FLAGS = os.O_RDONLY
> +
> def sha_file_by_name(fname):
> """Calculate the SHA1 of a file by reading the full text"""
> s = sha.new()
> - f = os.open(fname, os.O_RDONLY)
> + f = os.open(fname, OS_OPEN_FLAGS)
> try:
> while True:
> b = os.read(f, 1<<16)
>
>
>
>
+1
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHHKxTJdeBCYSNAAMRAuwzAJ9whDCYz0LLd8TVBnEpFk85c4lxxACfRZQp
MNzao25GqHQX8ISzJpb6Vmk=
=sYck
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list