[MERGE] Make Tree.get_file_text and Tree.get_file_lines official

John Arbash Meinel john at arbash-meinel.com
Mon Oct 20 22:04:11 BST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Aaron Bentley wrote:
> Hi all,
> 
> This patch adds testing and default implementations for
> Tree.get_file_lines and Tree.get_file_text.  Tree.get_file_lines is
> important to supply, because it is easy to make mistakes if it is not
> available.  Specifically, it is tempting to use file.readlines, but this
> has platform-dependent behaviour.
> 
> Also, this adds a path parameter to both, mirroring get_file.  It's
> becoming apparent to me that WorkingTree and PreviewTree ought to
> provide reasonable access to unversioned files, so I hope to make
> get_file, get_file_lines, and get_file_text accept None for the file-id
> in a future revision.
> 
> Aaron

As 'osutils.splitlines()' is pretty bad at performance, I would rather
only use it when we need to.

I'm pretty sure that as long as you always open the file in binary mode,
then win32/mac osx/linux will actually return the same bytes from
'readlines()'. I suppose Mac OS 9 would return something different, but
I don't believe that is a supported platform.

And certainly, get_file_text() should always be returning the binary
stream, so get_file() should also always be opening in binary mode.

Do you have a specific case where you *know* that the results are
varying by platform, or is it just something that you think is happening?

BB:tweak

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkj88ksACgkQJdeBCYSNAAMOsQCfWrgQqYx4tqarsOuPM9Qlmdja
acYAn2zxYxVtTcx6QZDxgWwsydk6cGbA
=98iJ
-----END PGP SIGNATURE-----



More information about the bazaar mailing list