comparison mercurial/scmutil.py @ 14167:0e4753807c93

util & scmutil: adapt read/write helpers as request by mpm
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Mon, 02 May 2011 10:11:05 +0200
parents c18204fd35b0
children 21b8ce4d3331
comparison
equal deleted inserted replaced
14166:9cbff8a39a2a 14167:0e4753807c93
137 137
138 def __init__(self, *args, **kwargs): 138 def __init__(self, *args, **kwargs):
139 '''Prevent instantiation; don't call this from subclasses.''' 139 '''Prevent instantiation; don't call this from subclasses.'''
140 raise NotImplementedError('attempted instantiating ' + str(type(self))) 140 raise NotImplementedError('attempted instantiating ' + str(type(self)))
141 141
142 def read(self, *args, **kwargs): 142 def read(self, path):
143 fp = self(*args, **kwargs) 143 fp = self(path, 'rb')
144 try: 144 try:
145 return fp.read() 145 return fp.read()
146 finally: 146 finally:
147 fp.close() 147 fp.close()
148 148
149 def write(self, data, *args, **kwargs): 149 def write(self, path, data):
150 fp = self(*args, **kwargs) 150 fp = self(path, 'wb')
151 try:
152 return fp.write(data)
153 finally:
154 fp.close()
155
156 def append(self, path, data):
157 fp = self(path, 'ab')
151 try: 158 try:
152 return fp.write(data) 159 return fp.write(data)
153 finally: 160 finally:
154 fp.close() 161 fp.close()
155 162