##// END OF EJS Templates
patch: remove EOL support from linereader class...
Patrick Mezard -
r14418:0174d1f7 default
parent child Browse files
Show More
@@ -330,11 +330,9 b' def readgitpatch(lr):'
330
330
331 class linereader(object):
331 class linereader(object):
332 # simple class to allow pushing lines back into the input stream
332 # simple class to allow pushing lines back into the input stream
333 def __init__(self, fp, textmode=False):
333 def __init__(self, fp):
334 self.fp = fp
334 self.fp = fp
335 self.buf = []
335 self.buf = []
336 self.textmode = textmode
337 self.eol = None
338
336
339 def push(self, line):
337 def push(self, line):
340 if line is not None:
338 if line is not None:
@@ -345,15 +343,7 b' class linereader(object):'
345 l = self.buf[0]
343 l = self.buf[0]
346 del self.buf[0]
344 del self.buf[0]
347 return l
345 return l
348 l = self.fp.readline()
346 return self.fp.readline()
349 if not self.eol:
350 if l.endswith('\r\n'):
351 self.eol = '\r\n'
352 elif l.endswith('\n'):
353 self.eol = '\n'
354 if self.textmode and l.endswith('\r\n'):
355 l = l[:-2] + '\n'
356 return l
357
347
358 def __iter__(self):
348 def __iter__(self):
359 while 1:
349 while 1:
@@ -1097,7 +1087,7 b' def scangitpatch(lr, firstline):'
1097 fp = lr.fp
1087 fp = lr.fp
1098 except IOError:
1088 except IOError:
1099 fp = cStringIO.StringIO(lr.fp.read())
1089 fp = cStringIO.StringIO(lr.fp.read())
1100 gitlr = linereader(fp, lr.textmode)
1090 gitlr = linereader(fp)
1101 gitlr.push(firstline)
1091 gitlr.push(firstline)
1102 gitpatches = readgitpatch(gitlr)
1092 gitpatches = readgitpatch(gitlr)
1103 fp.seek(pos)
1093 fp.seek(pos)
General Comments 0
You need to be logged in to leave comments. Login now