[PATCH 1 of 2 V2] lfs: add a local store method for opening a blob

Matt Harbison mharbison72 at gmail.com
Fri Jan 5 21:15:54 EST 2018


On Fri, 05 Jan 2018 08:20:44 -0500, Yuya Nishihara <yuya at tcha.org> wrote:

> On Fri, 5 Jan 2018 08:04:54 -0500, Matt Harbison wrote:
>>
>> > On Jan 5, 2018, at 1:10 AM, Yuya Nishihara <yuya at tcha.org> wrote:
>> >
>> >> On Thu, 04 Jan 2018 21:59:09 -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 b8a794103bbb0506069f2b0ad101ba6b0455dc26
>> >> # Parent  31fe397f2bdab5fea4752947e70549e7a7d04f75
>> >> 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.
>> >>
>> >> The file is now explicitly opened in binary mode for clarity.  (It  
>> was also
>> >> being opened in binary mode before, but only because vfs.__call__()  
>> appends 'b'
>> >> if needed when not opening with 'text=True'.)
>> >>
>> >> 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):
>> >> +        """Open a read-only file descriptor to the named blob, in  
>> either the
>> >> +        usercache or the local store."""
>> >> +        if self.cachevfs.exists(oid):
>> >> +            return self.cachevfs(oid, 'rb')
>> >> +
>> >> +        return self.vfs(oid, 'rb')
>> >
>> > Oops, one more nit. cachevfs vs vfs, which should precede the other?  
>> I think
>> > vfs is more "near" as it must belong to the same filesystem.
>>
>> The only reason I ordered it like that was so if the file doesn’t exist  
>> in either place, the “abort: no such file” message points to the local  
>> repo, not somewhere in ~/ or some other place.
>>
>> It’s hard to say what’s more likely to be populated. I’ve been hitting  
>> a lot of cases lately where it is only in vfscache, but that’s because  
>> I’m working with multiple clones. However, the blob will also be in  
>> vfscache because of commits if there’s only one clone, so that seems  
>> like the most likely place to be populated?
>
> Can you add inline comments? I'm already getting confused with lfs, but  
> we're
> responsible for making lfs less bad than largefiles. :)

Lol.  Will do.

Which parts are confusing?  (I've been a little confused by some things  
too, but I'm wondering how much overlap there is, what can be clarified,  
and how much is me juggling too many projects at once.)


More information about the Mercurial-devel mailing list