diff tests/test-sparse-clone.t @ 33289:abd7dedbaa36

sparse: vendor Facebook-developed extension Facebook has developed an extension to enable "sparse" checkouts - a working directory with a subset of files. This feature is a critical component in enabling repositories to scale to infinite number of files while retaining reasonable performance. It's worth noting that sparse checkout is only one possible solution to this problem: another is virtual filesystems that realize files on first access. But given that virtual filesystems may not be accessible to all users, sparse checkout is necessary as a fallback. Per mailing list discussion at https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-March/095868.html we want to add sparse checkout to the Mercurial distribution via roughly the following mechanism: 1. Vendor extension as-is with minimal modifications (this patch) 2. Refactor extension so it is more clearly experimental and inline with Mercurial practices 3. Move code from extension into core where possible 4. Drop experimental labeling and/or move feature into core after sign-off from narrow clone feature owners This commit essentially copies the sparse extension and tests from revision 71e0a2aeca92a4078fe1b8c76e32c88ff1929737 of the https://bitbucket.org/facebook/hg-experimental repository. A list of modifications made as part of vendoring is as follows: * "EXPERIMENTAL" added to module docstring * Imports were changed to match Mercurial style conventions * "testedwith" value was updated to core Mercurial special value and comment boilerplate was inserted * A "clone_sparse" function was renamed to "clonesparse" to appease the style checker * Paths to the sparse extension in tests reflect built-in location * test-sparse-extensions.t was renamed to test-sparse-fsmonitor.t and references to "simplecache" were removed. The test always skips because it isn't trivial to run it given the way we currently run fsmonitor tests * A double empty line was removed from test-sparse-profiles.t There are aspects of the added code that are obviously not ideal. The goal is to make a minimal number of modifications as part of the vendoring to make it easier to track changes from the original implementation. Refactoring will occur in subsequent patches.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 01 Jul 2017 10:43:29 -0700
parents
children c18ae7a07019
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-sparse-clone.t	Sat Jul 01 10:43:29 2017 -0700
@@ -0,0 +1,72 @@
+test sparse
+
+  $ cat >> $HGRCPATH << EOF
+  > [ui]
+  > ssh = python "$RUNTESTDIR/dummyssh"
+  > username = nobody <no.reply@fb.com>
+  > [extensions]
+  > sparse=
+  > purge=
+  > strip=
+  > rebase=
+  > EOF
+
+  $ hg init myrepo
+  $ cd myrepo
+  $ echo a > index.html
+  $ echo x > data.py
+  $ echo z > readme.txt
+  $ cat > webpage.sparse <<EOF
+  > [include]
+  > *.html
+  > EOF
+  $ cat > backend.sparse <<EOF
+  > [include]
+  > *.py
+  > EOF
+  $ hg ci -Aqm 'initial'
+  $ cd ..
+
+Verify local clone with a sparse profile works
+
+  $ hg clone --enable-profile webpage.sparse myrepo clone1
+  updating to branch default
+  warning: sparse profile 'webpage.sparse' not found in rev 000000000000 - ignoring it
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd clone1
+  $ ls
+  index.html
+  $ cd ..
+
+Verify local clone with include works
+
+  $ hg clone --include *.sparse myrepo clone2
+  updating to branch default
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd clone2
+  $ ls
+  backend.sparse
+  webpage.sparse
+  $ cd ..
+
+Verify local clone with exclude works
+
+  $ hg clone --exclude data.py myrepo clone3
+  updating to branch default
+  4 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd clone3
+  $ ls
+  backend.sparse
+  index.html
+  readme.txt
+  webpage.sparse
+  $ cd ..
+
+Verify sparse clone profile over ssh works
+
+  $ hg clone -q --enable-profile webpage.sparse ssh://user@dummy/myrepo clone4
+  warning: sparse profile 'webpage.sparse' not found in rev 000000000000 - ignoring it
+  $ cd clone4
+  $ ls
+  index.html
+  $ cd ..