[PATCH] largefiles: check file in the repo store before checking remotely (issue4686)

Piotr Listkiewicz piotr.listkiewicz at gmail.com
Mon Jun 27 03:19:16 EDT 2016


>
> Is there any reason to build localhashes list?
> I think "expectedhash in localhashes" can be simply written as
> "lfutil.instore(self.repo, expectedhash)".


There is no reason, this is changed in V2

2016-06-26 17:00 GMT+02:00 Yuya Nishihara <yuya at tcha.org>:

> On Fri, 24 Jun 2016 09:47:16 +0200, liscju wrote:
> > # HG changeset patch
> > # User liscju <piotr.listkiewicz at gmail.com>
> > # Date 1466714237 -7200
> > #      Thu Jun 23 22:37:17 2016 +0200
> > # Node ID 2670e4331e0c763b04c0de2e1149917ccca42364
> > # Parent  6d96658a22b0fc1eb210c99c5629dd69fedf3006
> > largefiles: check file in the repo store before checking remotely
> (issue4686)
> >
> > Problem was files to check were gathered in the repository where
> > the verify was launched but verification was done on the remote
> > store. It was observed when user committed in cloned repository
> > and ran verify before pushing - committed files were marked
> > as non existing.
> >
> > This commit fixes this by checking in the remote store only files
> > that are not existing in the repository store where verify was launched.
>
> I'm not pretty sure, but this patch seems good because the docstring says
> "localstore first attempts to grab files out of the store in the remote",
> which would imply in-store files precede remote files.
>
> > --- a/hgext/largefiles/localstore.py
> > +++ b/hgext/largefiles/localstore.py
> > @@ -45,10 +45,23 @@ class localstore(basestore.basestore):
> >          with open(path, 'rb') as fd:
> >              return lfutil.copyandhash(fd, tmpfile)
> >
> > +    def _hashesavailablelocally(self, hashes):
> > +        localhashes = [hash for hash in hashes
> > +                       if lfutil.instore(self.repo, hash)]
> > +        return localhashes
> > +
> >      def _verifyfiles(self, contents, filestocheck):
> >          failed = False
> > +        expectedhashes = [expectedhash
> > +                          for cset, filename, expectedhash in
> filestocheck]
> > +        localhashes = self._hashesavailablelocally(expectedhashes)
> >          for cset, filename, expectedhash in filestocheck:
> > -            storepath, exists = lfutil.findstorepath(self.remote,
> expectedhash)
> > +            if expectedhash in localhashes:
> > +                storepath, exists = lfutil.findstorepath(
> > +                    self.repo, expectedhash)
> > +            else:
> > +                storepath, exists = lfutil.findstorepath(
> > +                    self.remote, expectedhash)
>
> Is there any reason to build localhashes list?
>
> I think "expectedhash in localhashes" can be simply written as
> "lfutil.instore(self.repo, expectedhash)".
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20160627/7d89a875/attachment.html>


More information about the Mercurial-devel mailing list