[PATCH 02 of 10] opener: add read & write utility methods
Adrian Buehlmann
adrian at cadifra.com
Fri Dec 3 11:07:34 CST 2010
On 2010-12-02 00:42, Adrian Buehlmann wrote:
> On 2010-12-01 22:34, Dan Villiom Podlaski Christiansen wrote:
> in util.py:
>
> def read(op, path, text=False):
> fp = op(path, 'r', text)
> try:
> return fp.read()
> finally:
> fp.close()
>
Actually, we might do something like
def read(path, op=None, text=False):
if op is None:
fp = posixfile(path)
else:
fp = op(path, 'r', text)
try:
return fp.read()
finally:
fp.close()
which could then also be used for the case where we don't have openers,
as shown in my readlock patch.
More information about the Mercurial-devel
mailing list