util & scmutil: adapt read/write helpers as request by mpm
authorDan Villiom Podlaski Christiansen <danchr@gmail.com>
Mon, 02 May 2011 10:11:05 +0200
changeset 14167 0e4753807c93
parent 14166 9cbff8a39a2a
child 14168 135e244776f0
util & scmutil: adapt read/write helpers as request by mpm
mercurial/scmutil.py
mercurial/util.py
--- a/mercurial/scmutil.py	Mon May 02 09:11:35 2011 +0200
+++ b/mercurial/scmutil.py	Mon May 02 10:11:05 2011 +0200
@@ -139,15 +139,22 @@
         '''Prevent instantiation; don't call this from subclasses.'''
         raise NotImplementedError('attempted instantiating ' + str(type(self)))
 
-    def read(self, *args, **kwargs):
-        fp = self(*args, **kwargs)
+    def read(self, path):
+        fp = self(path, 'rb')
         try:
             return fp.read()
         finally:
             fp.close()
 
-    def write(self, data, *args, **kwargs):
-        fp = self(*args, **kwargs)
+    def write(self, path, data):
+        fp = self(path, 'wb')
+        try:
+            return fp.write(data)
+        finally:
+            fp.close()
+
+    def append(self, path, data):
+        fp = self(path, 'ab')
         try:
             return fp.write(data)
         finally:
--- a/mercurial/util.py	Mon May 02 09:11:35 2011 +0200
+++ b/mercurial/util.py	Mon May 02 10:11:05 2011 +0200
@@ -778,8 +778,15 @@
     finally:
         fp.close()
 
-def writefile(path, mode, text):
-    fp = open(path, mode)
+def writefile(path, text):
+    fp = open(path, 'wb')
+    try:
+        fp.write(text)
+    finally:
+        fp.close()
+
+def appendfile(path, text):
+    fp = open(path, 'ab')
     try:
         fp.write(text)
     finally: