[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] tools/examples/svnshell.py

From: Max Bowsher <maxb1_at_ukf.net>
Date: 2006-01-05 13:29:44 CET

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

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!
>
> Thanks,
>
> Peter
>
> On 03/01/06, Max Bowsher <maxb1@ukf.net> wrote:
>
> Peter Ericson wrote:
>
>>* tools/examples/svnshell.py
>> (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
> return
> ### 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"""
>

Committed r17989.

Max.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)

iD8DBQFDvRE4fFNSmcDyxYARAkleAJ9xu5TarrMAzUD+mACVLorgZfja8ACeKVtD
7C34kcdKMhJ/40mXFzydI7s=
=FakQ
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Jan 5 13:31:08 2006

This is an archived mail posted to the Subversion Dev mailing list.