[PATCH 02 of 16] vfs: add a read only vfs
Kevin Bullock
kbullock+mercurial at ringworld.org
Thu Jan 3 16:55:41 CST 2013
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.
pacem in terris / мир / शान्ति / سَلاَم / 平和
Kevin R. Bullock
More information about the Mercurial-devel
mailing list