sapling/tests/test-lfs.t

123 lines
9.3 KiB
Perl
Raw Normal View History

lfs: allow blobstore to be outside the repo Summary: Previously `lfs.blobstore` must be a relative path. If an absolute blobstore path is set, it will traceback because vfs audit fails: ``` File "hg/mercurial/revlog.py", line 1356, in _processflags text, vhash = writetransform(self, text) File "fb-hgext/hgext3rd/lfs/wrapper.py", line 69, in writetostore blobstore.local.get(self.opener).write(storeid, chunk) File "fb-hgext/hgext3rd/lfs/blobstore.py", line 41, in write fp = self._opener(self.filename(storeid), 'w+', atomictemp=True) File "hg/mercurial/vfs.py", line 344, in __call__ self.audit(path) File "hg/mercurial/pathutil.py", line 64, in __call__ raise error.Abort(_("path contains illegal component: %s") % path) Abort: path contains illegal component: /home/quark/lfslocalblobstore/d7/dbc611df1fe7dfacfe267a2bfd32ba8fc27ad16aa72af7e6c553a120b92f18 ``` That was because the code was using `repo.vfs`. This diff adds a new `lfsvfs` to avoid the issue. The `lfsvfs` also did the correct filename check (the old `re.match` check will not match the whole string), so `blobstore.local` could be simplified a lot. Test Plan: A new test case was added to make sure absolute blobstore path works. I also did some cleanups for the test file to de-dup hgrc, and avoid writing files outside `$TESTTMP`. Reviewers: #mercurial, rmcelroy Reviewed By: rmcelroy Subscribers: rmcelroy, mjpieters, remi Differential Revision: https://phabricator.intern.facebook.com/D4785084 Signature: t1:4785084:1490693306:b42eef8e53af107897c2e1bc2984c090bdd2e465
2017-03-29 01:41:59 +03:00
# Initial setup
lfs: allow blobstore to be outside the repo Summary: Previously `lfs.blobstore` must be a relative path. If an absolute blobstore path is set, it will traceback because vfs audit fails: ``` File "hg/mercurial/revlog.py", line 1356, in _processflags text, vhash = writetransform(self, text) File "fb-hgext/hgext3rd/lfs/wrapper.py", line 69, in writetostore blobstore.local.get(self.opener).write(storeid, chunk) File "fb-hgext/hgext3rd/lfs/blobstore.py", line 41, in write fp = self._opener(self.filename(storeid), 'w+', atomictemp=True) File "hg/mercurial/vfs.py", line 344, in __call__ self.audit(path) File "hg/mercurial/pathutil.py", line 64, in __call__ raise error.Abort(_("path contains illegal component: %s") % path) Abort: path contains illegal component: /home/quark/lfslocalblobstore/d7/dbc611df1fe7dfacfe267a2bfd32ba8fc27ad16aa72af7e6c553a120b92f18 ``` That was because the code was using `repo.vfs`. This diff adds a new `lfsvfs` to avoid the issue. The `lfsvfs` also did the correct filename check (the old `re.match` check will not match the whole string), so `blobstore.local` could be simplified a lot. Test Plan: A new test case was added to make sure absolute blobstore path works. I also did some cleanups for the test file to de-dup hgrc, and avoid writing files outside `$TESTTMP`. Reviewers: #mercurial, rmcelroy Reviewed By: rmcelroy Subscribers: rmcelroy, mjpieters, remi Differential Revision: https://phabricator.intern.facebook.com/D4785084 Signature: t1:4785084:1490693306:b42eef8e53af107897c2e1bc2984c090bdd2e465
2017-03-29 01:41:59 +03:00
$ cat >> $HGRCPATH << EOF
> [extensions]
> lfs=$TESTDIR/../hgext3rd/lfs/
> [lfs]
> threshold=1000B
> chunksize=1000B
> blobstore=cache/localblobstore
> remotestore=dummy
lfs: allow blobstore to be outside the repo Summary: Previously `lfs.blobstore` must be a relative path. If an absolute blobstore path is set, it will traceback because vfs audit fails: ``` File "hg/mercurial/revlog.py", line 1356, in _processflags text, vhash = writetransform(self, text) File "fb-hgext/hgext3rd/lfs/wrapper.py", line 69, in writetostore blobstore.local.get(self.opener).write(storeid, chunk) File "fb-hgext/hgext3rd/lfs/blobstore.py", line 41, in write fp = self._opener(self.filename(storeid), 'w+', atomictemp=True) File "hg/mercurial/vfs.py", line 344, in __call__ self.audit(path) File "hg/mercurial/pathutil.py", line 64, in __call__ raise error.Abort(_("path contains illegal component: %s") % path) Abort: path contains illegal component: /home/quark/lfslocalblobstore/d7/dbc611df1fe7dfacfe267a2bfd32ba8fc27ad16aa72af7e6c553a120b92f18 ``` That was because the code was using `repo.vfs`. This diff adds a new `lfsvfs` to avoid the issue. The `lfsvfs` also did the correct filename check (the old `re.match` check will not match the whole string), so `blobstore.local` could be simplified a lot. Test Plan: A new test case was added to make sure absolute blobstore path works. I also did some cleanups for the test file to de-dup hgrc, and avoid writing files outside `$TESTTMP`. Reviewers: #mercurial, rmcelroy Reviewed By: rmcelroy Subscribers: rmcelroy, mjpieters, remi Differential Revision: https://phabricator.intern.facebook.com/D4785084 Signature: t1:4785084:1490693306:b42eef8e53af107897c2e1bc2984c090bdd2e465
2017-03-29 01:41:59 +03:00
> remotepath=$TESTTMP/dummy-remote/
> EOF
lfs: allow blobstore to be outside the repo Summary: Previously `lfs.blobstore` must be a relative path. If an absolute blobstore path is set, it will traceback because vfs audit fails: ``` File "hg/mercurial/revlog.py", line 1356, in _processflags text, vhash = writetransform(self, text) File "fb-hgext/hgext3rd/lfs/wrapper.py", line 69, in writetostore blobstore.local.get(self.opener).write(storeid, chunk) File "fb-hgext/hgext3rd/lfs/blobstore.py", line 41, in write fp = self._opener(self.filename(storeid), 'w+', atomictemp=True) File "hg/mercurial/vfs.py", line 344, in __call__ self.audit(path) File "hg/mercurial/pathutil.py", line 64, in __call__ raise error.Abort(_("path contains illegal component: %s") % path) Abort: path contains illegal component: /home/quark/lfslocalblobstore/d7/dbc611df1fe7dfacfe267a2bfd32ba8fc27ad16aa72af7e6c553a120b92f18 ``` That was because the code was using `repo.vfs`. This diff adds a new `lfsvfs` to avoid the issue. The `lfsvfs` also did the correct filename check (the old `re.match` check will not match the whole string), so `blobstore.local` could be simplified a lot. Test Plan: A new test case was added to make sure absolute blobstore path works. I also did some cleanups for the test file to de-dup hgrc, and avoid writing files outside `$TESTTMP`. Reviewers: #mercurial, rmcelroy Reviewed By: rmcelroy Subscribers: rmcelroy, mjpieters, remi Differential Revision: https://phabricator.intern.facebook.com/D4785084 Signature: t1:4785084:1490693306:b42eef8e53af107897c2e1bc2984c090bdd2e465
2017-03-29 01:41:59 +03:00
$ LONG=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
# Prepare server and enable extension
$ hg init server
$ hg clone -q server client
$ cd client
# Commit small file
$ echo s > smallfile
$ hg commit -Aqm "add small file"
# Commit large file
lfs: allow blobstore to be outside the repo Summary: Previously `lfs.blobstore` must be a relative path. If an absolute blobstore path is set, it will traceback because vfs audit fails: ``` File "hg/mercurial/revlog.py", line 1356, in _processflags text, vhash = writetransform(self, text) File "fb-hgext/hgext3rd/lfs/wrapper.py", line 69, in writetostore blobstore.local.get(self.opener).write(storeid, chunk) File "fb-hgext/hgext3rd/lfs/blobstore.py", line 41, in write fp = self._opener(self.filename(storeid), 'w+', atomictemp=True) File "hg/mercurial/vfs.py", line 344, in __call__ self.audit(path) File "hg/mercurial/pathutil.py", line 64, in __call__ raise error.Abort(_("path contains illegal component: %s") % path) Abort: path contains illegal component: /home/quark/lfslocalblobstore/d7/dbc611df1fe7dfacfe267a2bfd32ba8fc27ad16aa72af7e6c553a120b92f18 ``` That was because the code was using `repo.vfs`. This diff adds a new `lfsvfs` to avoid the issue. The `lfsvfs` also did the correct filename check (the old `re.match` check will not match the whole string), so `blobstore.local` could be simplified a lot. Test Plan: A new test case was added to make sure absolute blobstore path works. I also did some cleanups for the test file to de-dup hgrc, and avoid writing files outside `$TESTTMP`. Reviewers: #mercurial, rmcelroy Reviewed By: rmcelroy Subscribers: rmcelroy, mjpieters, remi Differential Revision: https://phabricator.intern.facebook.com/D4785084 Signature: t1:4785084:1490693306:b42eef8e53af107897c2e1bc2984c090bdd2e465
2017-03-29 01:41:59 +03:00
$ echo $LONG > largefile
$ hg commit --traceback -Aqm "add large file"
# Ensure metadata is stored
$ hg debugdata largefile 0
version https://git-lfs.github.com/spec/chunking
chunks d7dbc611df1fe7dfacfe267a2bfd32ba8fc27ad16aa72af7e6c553a120b92f18:1000,ed0f071aa4ff28ab9863b6cfc5f407e915612d70502422e4ab9b09f3dfec4a74:501
hashalgo sha256
size 1501
# Check the blobstore is populated
$ find .hg/cache/localblobstore | sort
.hg/cache/localblobstore
.hg/cache/localblobstore/d7
.hg/cache/localblobstore/d7/dbc611df1fe7dfacfe267a2bfd32ba8fc27ad16aa72af7e6c553a120b92f18
.hg/cache/localblobstore/ed
.hg/cache/localblobstore/ed/0f071aa4ff28ab9863b6cfc5f407e915612d70502422e4ab9b09f3dfec4a74
# Check the blob stored contains the actual contents of the file
$ cat .hg/cache/localblobstore/d7/dbc611df1fe7dfacfe267a2bfd32ba8fc27ad16aa72af7e6c553a120b92f18
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
# Push changes to the server
$ hg push
pushing to $TESTTMP/server (glob)
searching for changes
lfs: computing set of blobs to upload
lfs: uploading the blobs to the remote (2 chunk(s), 1.47 KB)
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files
$ cd ../
lfs: allow blobstore to be outside the repo Summary: Previously `lfs.blobstore` must be a relative path. If an absolute blobstore path is set, it will traceback because vfs audit fails: ``` File "hg/mercurial/revlog.py", line 1356, in _processflags text, vhash = writetransform(self, text) File "fb-hgext/hgext3rd/lfs/wrapper.py", line 69, in writetostore blobstore.local.get(self.opener).write(storeid, chunk) File "fb-hgext/hgext3rd/lfs/blobstore.py", line 41, in write fp = self._opener(self.filename(storeid), 'w+', atomictemp=True) File "hg/mercurial/vfs.py", line 344, in __call__ self.audit(path) File "hg/mercurial/pathutil.py", line 64, in __call__ raise error.Abort(_("path contains illegal component: %s") % path) Abort: path contains illegal component: /home/quark/lfslocalblobstore/d7/dbc611df1fe7dfacfe267a2bfd32ba8fc27ad16aa72af7e6c553a120b92f18 ``` That was because the code was using `repo.vfs`. This diff adds a new `lfsvfs` to avoid the issue. The `lfsvfs` also did the correct filename check (the old `re.match` check will not match the whole string), so `blobstore.local` could be simplified a lot. Test Plan: A new test case was added to make sure absolute blobstore path works. I also did some cleanups for the test file to de-dup hgrc, and avoid writing files outside `$TESTTMP`. Reviewers: #mercurial, rmcelroy Reviewed By: rmcelroy Subscribers: rmcelroy, mjpieters, remi Differential Revision: https://phabricator.intern.facebook.com/D4785084 Signature: t1:4785084:1490693306:b42eef8e53af107897c2e1bc2984c090bdd2e465
2017-03-29 01:41:59 +03:00
# Initialize new client (not cloning) and setup extension
$ hg init client2
$ cd client2
$ cat >> .hg/hgrc <<EOF
> [paths]
> default = $TESTTMP/server
> EOF
# Pull from server
$ hg pull default
pulling from $TESTTMP/server (glob)
requesting all changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files
(run 'hg update' to get a working copy)
# Check the blobstore is not yet populated
$ [ -f .hg/cache/localblobstore ]
[1]
# Update to the last revision containing the large file
$ hg update
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
# Check the blobstore has been populated on update
$ find .hg/cache/localblobstore | sort
.hg/cache/localblobstore
.hg/cache/localblobstore/d7
.hg/cache/localblobstore/d7/dbc611df1fe7dfacfe267a2bfd32ba8fc27ad16aa72af7e6c553a120b92f18
.hg/cache/localblobstore/ed
.hg/cache/localblobstore/ed/0f071aa4ff28ab9863b6cfc5f407e915612d70502422e4ab9b09f3dfec4a74
# Check the contents of the file are fetched from blobstore when requested
$ hg cat -r . largefile
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB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CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
lfs: allow blobstore to be outside the repo Summary: Previously `lfs.blobstore` must be a relative path. If an absolute blobstore path is set, it will traceback because vfs audit fails: ``` File "hg/mercurial/revlog.py", line 1356, in _processflags text, vhash = writetransform(self, text) File "fb-hgext/hgext3rd/lfs/wrapper.py", line 69, in writetostore blobstore.local.get(self.opener).write(storeid, chunk) File "fb-hgext/hgext3rd/lfs/blobstore.py", line 41, in write fp = self._opener(self.filename(storeid), 'w+', atomictemp=True) File "hg/mercurial/vfs.py", line 344, in __call__ self.audit(path) File "hg/mercurial/pathutil.py", line 64, in __call__ raise error.Abort(_("path contains illegal component: %s") % path) Abort: path contains illegal component: /home/quark/lfslocalblobstore/d7/dbc611df1fe7dfacfe267a2bfd32ba8fc27ad16aa72af7e6c553a120b92f18 ``` That was because the code was using `repo.vfs`. This diff adds a new `lfsvfs` to avoid the issue. The `lfsvfs` also did the correct filename check (the old `re.match` check will not match the whole string), so `blobstore.local` could be simplified a lot. Test Plan: A new test case was added to make sure absolute blobstore path works. I also did some cleanups for the test file to de-dup hgrc, and avoid writing files outside `$TESTTMP`. Reviewers: #mercurial, rmcelroy Reviewed By: rmcelroy Subscribers: rmcelroy, mjpieters, remi Differential Revision: https://phabricator.intern.facebook.com/D4785084 Signature: t1:4785084:1490693306:b42eef8e53af107897c2e1bc2984c090bdd2e465
2017-03-29 01:41:59 +03:00
$ cd ..
# Check blobstore could be an absolute path outside repo vfs:
$ mkdir -p $TESTTMP/global-store
$ cat >> $HGRCPATH <<EOF
> [lfs]
> blobstore=$TESTTMP/global-store
> EOF
$ hg init repo2
$ cd repo2
$ echo $LONG > largefile
$ hg add largefile
$ hg commit -m initcommit
$ [ -f $TESTTMP/global-store/ed/0f071aa4ff28ab9863b6cfc5f407e915612d70502422e4ab9b09f3dfec4a74 ]
$ [ -f $TESTTMP/global-store/d7/dbc611df1fe7dfacfe267a2bfd32ba8fc27ad16aa72af7e6c553a120b92f18 ]