diff mercurial/patch.py @ 14418:0174d1f79280

patch: remove EOL support from linereader class This was only used when reading patched files which is now done by backends.
author Patrick Mezard <pmezard@gmail.com>
date Tue, 24 May 2011 14:21:04 +0200
parents f03f08240c32
children 5f6090e559fa
line wrap: on
line diff
--- a/mercurial/patch.py	Mon May 23 22:49:10 2011 -0500
+++ b/mercurial/patch.py	Tue May 24 14:21:04 2011 +0200
@@ -330,11 +330,9 @@
 
 class linereader(object):
     # simple class to allow pushing lines back into the input stream
-    def __init__(self, fp, textmode=False):
+    def __init__(self, fp):
         self.fp = fp
         self.buf = []
-        self.textmode = textmode
-        self.eol = None
 
     def push(self, line):
         if line is not None:
@@ -345,15 +343,7 @@
             l = self.buf[0]
             del self.buf[0]
             return l
-        l = self.fp.readline()
-        if not self.eol:
-            if l.endswith('\r\n'):
-                self.eol = '\r\n'
-            elif l.endswith('\n'):
-                self.eol = '\n'
-        if self.textmode and l.endswith('\r\n'):
-            l = l[:-2] + '\n'
-        return l
+        return self.fp.readline()
 
     def __iter__(self):
         while 1:
@@ -1097,7 +1087,7 @@
         fp = lr.fp
     except IOError:
         fp = cStringIO.StringIO(lr.fp.read())
-    gitlr = linereader(fp, lr.textmode)
+    gitlr = linereader(fp)
     gitlr.push(firstline)
     gitpatches = readgitpatch(gitlr)
     fp.seek(pos)