Issue with StrippedCRFile in nt.py - Windows

0 views
Skip to first unread message

Maximiliano Neustadt

unread,
Aug 7, 2008, 12:11:58 PM8/7/08
to gvn-discuss
Hey guys.

I've been playing around with gvn - mainly because I loved g4's
workflow for reviews when I worked at google as a contractor, and I
want to implement something similar at my current job, so gvn is a
perfect fit for our svn repo!

I could set it up in my Windows box, create a changelist, and mail it.
However, I had an issue when I tried to do a gvn review for the
changelist:

gvn review failed:
Traceback (most recent call last):
File "c:\python24\lib\site-packages\gvn\cmdline.py", line 1043, in
main
return Run(options, argv)
File "c:\python24\lib\site-packages\gvn\cmdline.py", line 894, in
Run
return cmd(ctx)
File "c:\python24\lib\site-packages\gvn\cmdline.py", line 945, in
__call__
result = self.impl(ctx)
File "C:\Python24\Lib\site-packages\gvn\subcommands\review.py", line
49, in Handle_GvnReview
callbacks = ctx.GetDiffCallbacks(pool=iterpool)
File "c:\python24\lib\site-packages\gvn\cmdline.py", line 783, in
GetDiffCallbacks
stdout.flush()
AttributeError: 'StrippedCRFile' object has no attribute 'flush'

Since that class is a wrapper with an underlying file object, I just
added the flush method to the class (in nt.py), and made it call its
underlying flush method, which fixed the problem. The result is:

class StrippedCRFile(object):
"""File-like object wrapper that strips CRs from CRLF.

svn.diff writes out CRLF-terminated lines on Windows, which happens
to
work well for svn because it uses apr file objects, which apparently
do
no newline translation of their own (despite 30 (?) years of stdio
precedent, *grumble*). But, our file objects do such translation on
Windows, so we need to turn all CRLFs into LFs before letting the
file
object add the CRs back. Sigh.

This only implements the write method.
"""
def __init__(self, fp):
self.fp = fp
def write(self, s):
return self.fp.write(s.replace('\r\n', '\n'))
def flush(self):
return self.fp.flush()

If you want I can join the group and submit a changelist with this
change, in case you think my approach was correct :) Just LMK.

Thanks!

Max
Reply all
Reply to author
Forward
0 new messages