-----BEGIN PGP SIGNED MESSAGE-----
Peter Ericson wrote:
> Good point; I had tested my fix by calling write method on a file
> object instead of print. I didn't test the patch because trunk
> svnlook.py was incompatible with my installed bindings!
> On 03/01/06, Max Bowsher <firstname.lastname@example.org> wrote:
> Peter Ericson wrote:
>> (do_cat): Fix endless loop that occurs when cat-ing files larger
>> than core.SVN_STREAM_CHUNK_SIZE.
>>@@ -78,6 +78,7 @@
>> stream = fs.file_contents(self.root, catpath)
>> while filelen > core.SVN_STREAM_CHUNK_SIZE:
>> print core.svn_stream_read(stream, int(core.SVN_STREAM_CHUNK_SIZE))
>>+ filelen -= core.SVN_STREAM_CHUNK_SIZE
>> print core.svn_stream_read(stream, int(filelen))
> Thanks for the heads-up - actually, now you have drawn attention to that
> code, I see that it is even more buggy than you have noticed:
> It is using 'print', which will cause an extra newline to be inserted
> every SVN_STREAM_CHUNK_SIZE bytes, and at the end of the file. Also, it
> is unnecessarily using svn_fs_file_length, since it can just keep
> reading the stream until it gets a short read to indicate EOF.
> And, using int(core.SVN_STREAM_CHUNK_SIZE) is rather strange too -
> actually, does anyone know a reason for that? Was it working around some
> old Python bindings bug?
> Index: svnshell.py
> --- svnshell.py (revision 17951)
> +++ svnshell.py (working copy)
> @@ -74,11 +74,12 @@
> print "Path '%s' is not a file." % catpath
> ### be nice to get some paging in here.
> - filelen = fs.file_length(self.root, catpath)
> stream = fs.file_contents(self.root, catpath)
> - while filelen > core.SVN_STREAM_CHUNK_SIZE:
> - print core.svn_stream_read(stream, int(core.SVN_STREAM_CHUNK_SIZE))
> - print core.svn_stream_read(stream, int(filelen))
> + while 1:
> + data = core.svn_stream_read(stream, core.SVN_STREAM_CHUNK_SIZE)
> + sys.stdout.write(data)
> + if len(data) < core.SVN_STREAM_CHUNK_SIZE:
> + break
> def do_cd(self, arg):
> """change directory"""
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
-----END PGP SIGNATURE-----
To unsubscribe, e-mail: email@example.com
For additional commands, e-mail: firstname.lastname@example.org
Received on Thu Jan 5 13:31:08 2006