[PATCH 1 of 2] lfs: add a local store method for opening a blob
Yuya Nishihara
yuya at tcha.org
Thu Jan 4 07:39:40 UTC 2018
On Tue, 02 Jan 2018 22:49:13 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1514945910 18000
> # Tue Jan 02 21:18:30 2018 -0500
> # Node ID f5064b263d00efc996301c10173067677f874f09
> # Parent 0738d59d753f640ae3d7f310f77e6ec97912ed5c
> lfs: add a local store method for opening a blob
>
> The has() and read() methods already dynamically switch between the usercache
> and local store. This should generally be preferred to directly accessing the
> vfs instances outside of the store.
>
> diff --git a/hgext/lfs/blobstore.py b/hgext/lfs/blobstore.py
> --- a/hgext/lfs/blobstore.py
> +++ b/hgext/lfs/blobstore.py
> @@ -100,6 +100,14 @@
> self.cachevfs = lfsvfs(usercache)
> self.ui = repo.ui
>
> + def open(self, oid, mode='rb'):
> + """Open a file descriptor to the named blob, in either the usercache or
> + the local store."""
> + if self.cachevfs.exists(oid):
> + return self.cachevfs(oid, mode=mode)
> +
> + return self.vfs(oid, mode=mode)
Perhaps it's valid only for mode=read?
More information about the Mercurial-devel
mailing list