[PATCH 02 of 16] vfs: add a read only vfs

Matt Mackall mpm at selenic.com
Thu Jan 3 16:59:34 CST 2013


On Thu, 2013-01-03 at 16:55 -0600, Kevin Bullock wrote:
> On Jan 1, 2013, at 7:09 PM, Pierre-Yves David wrote:
> 
> > # HG changeset patch
> > # User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
> > # Date 1356664856 -3600
> > # Node ID f347244a1d604ed96f3a4231e1bb1868fb60c533
> > # Parent  13d23b0b1ef6751240408123218108899f0f1881
> > vfs: add a read only vfs
> > 
> > This read only wrapper is intended to be used bundle repo. See follow up commit
> > for details.
> > 
> > diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
> > --- a/mercurial/scmutil.py
> > +++ b/mercurial/scmutil.py
> > @@ -376,10 +376,22 @@ class filtervfs(abstractvfs, auditvfs):
> >         else:
> >             return self.vfs.join(path)
> > 
> > filteropener = filtervfs
> > 
> > +class readonlyvfs(abstractvfs, auditvfs):
> > +    '''Wrapper vfs preventing any writing.'''
> > +
> > +    def __init__(self, vfs):
> > +        auditvfs.__init__(self, vfs)
> > +
> > +    def __call__(self, path, mode='r', *args, **kw):
> > +        if mode not in ('r', 'rb'):
> > +            raise IOError('Permission denied')
> 
> Misleading message. It's not a filesystem constraint preventing us
> from writing to 'path', it's a caller violating the expectations of
> the object using readonlyvfs.

Indeed, under no circumstances should we be spoofing operating
system-level errors. Debugging is already hard enough; users routinely
believe that 'permission denied' is something Mercurial is inflicting on
them.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list