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

Adrian Buehlmann adrian at cadifra.com
Mon Dec 27 09:05:55 CST 2010


On 2010-12-27 12:45, Dirkjan Ochtman wrote:
> On Mon, Dec 27, 2010 at 12:31, Nicolas Dumazet <nicdumz at gmail.com> wrote:
>> Adrian, do we have alternatives here?
>> If you can come up with an alternate patch or suggestion that ensures
>> that things just work (tm) for PyPy, I'd gladly hear it.
> 
> Adrian seems to want to use utility functions (that take an opener) in
> util.py instead of methods on opener classes. It seems mostly a matter
> of taste, I haven't seen any convincing arguments either way.

It's more than a matter if taste.

If I see that a change like

On 2010-12-26 12:51, Dan Villiom Podlaski Christiansen wrote:
> A similar method for reading is added to the opener used by static
> HTTP repositories. It doesn't do any actual closing, as the opener
> doesn't have access to any underlying files.
>
> diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py
> --- a/mercurial/statichttprepo.py
> +++ b/mercurial/statichttprepo.py
> @@ -75,6 +75,8 @@ def build_opener(ui, authinfo):
>                  raise IOError('Permission denied')
>              f = "/".join((p, urllib.quote(path)))
>              return httprangereader(f, urlopener)
> +        # for compatibility with regular file openers
> +        o.read = lambda *args, **kwargs: o(*args, **kwargs).read()
>          return o
>
>      opener.options = {'nonlazy': 1}

is needed, then I'm fairly convinced that having to add read and write
member functions to every kind of opener is fishy.

See also my reasoning in http://markmail.org/message/otixtvzmcsxbbdvi


More information about the Mercurial-devel mailing list