[PATCH 4 of 8] opener: add read & write utility methods

Dan Villiom Podlaski Christiansen danchr at gmail.com
Sat Dec 25 05:37:28 CST 2010


On 25 Dec 2010, at 05:21, Augie Fackler wrote:

>> diff --git a/mercurial/store.py b/mercurial/store.py
>> --- a/mercurial/store.py
>> +++ b/mercurial/store.py
>> @@ -176,6 +176,8 @@ class basicstore(object):
>>        op = opener(self.path)
>>        op.createmode = self.createmode
>>        self.opener = lambda f, *args, **kw: op(encodedir(f), *args,  
>> **kw)
>> +        self.opener.read = (lambda f, *args, **kw:
>> +                            op(encodedir(f), *args, **kw).read())
>
> How does this ensure the file is closed properly? Isn't this  
> identical to doing self.opener().read()? (Note: it's a bit late and  
> it's probable that I'm missing something obvious, but I feel like a  
> comment might be warranted anyway for clarity.

It doesn't, actually. I was just hoping that things would work anyway,  
as we don't need to immediately close *all* files — a transient leak  
or two for reading doesn't hurt much.

That being said, I think I'll add a filteropener or something to  
handle the store cases. I'm not sure if the static HTTP opener will  
leak any file handles, but I suspect not.

--

Dan Villiom Podlaski Christiansen
danchr at gmail.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1943 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20101225/c20f0e5e/attachment.bin>


More information about the Mercurial-devel mailing list