[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: Peter Ericson <argblarg_at_gmail.com>
Date: 2006-01-02 22:36:57 CET

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:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> NotDashEscaped: You need GnuPG to verify this message
>
> 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"""
>
> Max.
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (Cygwin)
>
> iD8DBQFDuV9ZfFNSmcDyxYARAhhNAJwL7BGUvClyJXbyZVWqo2g+jj3j5QCeIKeP
> Oy9rzIouPW31etUhKauP6LQ=
> =aXph
> -----END PGP SIGNATURE-----
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Jan 2 22:39:44 2006

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.