changeset 4923:59b8ff35c4ed

patch: patches should be read and written in binary mode when possible.
author Patrick Mezard <pmezard@gmail.com>
date Tue, 17 Jul 2007 23:35:24 +0200
parents 020ee9c781cf
children 164daf101a54
files mercurial/patch.py
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/patch.py	Tue Jul 17 23:34:52 2007 +0200
+++ b/mercurial/patch.py	Tue Jul 17 23:35:24 2007 +0200
@@ -281,7 +281,7 @@
 def internalpatch(patchname, ui, strip, cwd, files):
     """use builtin patch to apply <patchname> to the working directory.
     returns whether patch was applied with fuzz factor."""
-    fp = file(patchname)
+    fp = file(patchname, 'rb')
     if cwd:
         curdir = os.getcwd()
         os.chdir(cwd)
@@ -303,7 +303,7 @@
         self.fname = fname
         self.ui = ui
         try:
-            fp = file(fname, 'r')
+            fp = file(fname, 'rb')
             self.lines = fp.readlines()
             self.exists = True
         except IOError:
@@ -383,7 +383,7 @@
         try: os.unlink(fname)
         except:
             pass
-        fp = file(fname, 'w')
+        fp = file(fname, 'wb')
         base = os.path.basename(self.fname)
         fp.write("--- %s\n+++ %s\n" % (base, base))
         for x in self.rej:
@@ -402,7 +402,7 @@
                 if st.st_nlink > 1:
                     os.unlink(dest)
             except: pass
-            fp = file(dest, 'w')
+            fp = file(dest, 'wb')
             if st:
                 os.chmod(dest, st.st_mode)
             fp.writelines(self.lines)