[PATCH 2 of 6] lfs: add the ability to disable the usercache

Matt Harbison mharbison72 at gmail.com
Mon Apr 9 15:28:54 UTC 2018


> On Apr 9, 2018, at 9:21 AM, Yuya Nishihara <yuya at tcha.org> wrote:
> 
>> On Mon, 09 Apr 2018 00:26:42 -0400, Matt Harbison wrote:
>> # HG changeset patch
>> # User Matt Harbison <matt_harbison at yahoo.com>
>> # Date 1523155211 14400
>> #      Sat Apr 07 22:40:11 2018 -0400
>> # Node ID f4381233ecb960307d39459ea961a0af03df442b
>> # Parent  69ead78af94459ca41e529d0ebfb24bd1d11c32c
>> lfs: add the ability to disable the usercache
> 
>> +class nullvfs(lfsvfs):
>> +    def __init__(self):
>> +        pass
>> +
>> +    def exists(self, oid):
>> +        return False
>> +
>> +    def read(self, oid):
>> +        raise IOError('%s: No such file or directory' % self.join(oid))
>> +
>> +    def walk(self, path=None, onerror=None):
>> +        return ('', [], [])
>> +
>> +    def write(self, oid, data):
>> +        pass
> 
> I don't think this abstraction would work nicely. For example, local.read()
> expects something exists in usercache.
> 
>    def read(self, oid, verify=True):
>        """Read blob from local blobstore."""
>        if not self.vfs.exists(oid):
>            blob = self._read(self.cachevfs, oid, verify)

That initially gave me pause too. But vfs.read(oid) inside _read() will also fail if the file doesn’t exist.  So before reading from the store, all code calls store.exists(oid).  Since the nullvfs always says the file doesn’t exist, the only way for a store to say it exists is if self.vfs (the repo internal store) has it.  That’s the desired behavior.

The only thing I was puzzling over after seeing that was if nullvfs.read() should raise an error or return an empty string- it should never be called.




More information about the Mercurial-devel mailing list