comparison tests/test-sparse-profiles.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 c9cbf4de27ba
comparison
equal deleted inserted replaced
33288:f08a178adadf 33289:abd7dedbaa36
1 test sparse
2
3 $ hg init myrepo
4 $ cd myrepo
5 $ cat > .hg/hgrc <<EOF
6 > [extensions]
7 > sparse=
8 > purge=
9 > strip=
10 > rebase=
11 > EOF
12
13 $ echo a > index.html
14 $ echo x > data.py
15 $ echo z > readme.txt
16 $ cat > webpage.sparse <<EOF
17 > # frontend sparse profile
18 > [include]
19 > *.html
20 > EOF
21 $ cat > backend.sparse <<EOF
22 > # backend sparse profile
23 > [include]
24 > *.py
25 > EOF
26 $ hg ci -Aqm 'initial'
27
28 $ hg sparse --include '*.sparse'
29
30 Verify enabling a single profile works
31
32 $ hg sparse --enable-profile webpage.sparse
33 $ ls
34 backend.sparse
35 index.html
36 webpage.sparse
37
38 Verify enabling two profiles works
39
40 $ hg sparse --enable-profile backend.sparse
41 $ ls
42 backend.sparse
43 data.py
44 index.html
45 webpage.sparse
46
47 Verify disabling a profile works
48
49 $ hg sparse --disable-profile webpage.sparse
50 $ ls
51 backend.sparse
52 data.py
53 webpage.sparse
54
55 Verify that a profile is updated across multiple commits
56
57 $ cat > webpage.sparse <<EOF
58 > # frontend sparse profile
59 > [include]
60 > *.html
61 > EOF
62 $ cat > backend.sparse <<EOF
63 > # backend sparse profile
64 > [include]
65 > *.py
66 > *.txt
67 > EOF
68
69 $ echo foo >> data.py
70
71 $ hg ci -m 'edit profile'
72 $ ls
73 backend.sparse
74 data.py
75 readme.txt
76 webpage.sparse
77
78 $ hg up -q 0
79 $ ls
80 backend.sparse
81 data.py
82 webpage.sparse
83
84 $ hg up -q 1
85 $ ls
86 backend.sparse
87 data.py
88 readme.txt
89 webpage.sparse
90
91 Introduce a conflicting .hgsparse change
92
93 $ hg up -q 0
94 $ cat > backend.sparse <<EOF
95 > # Different backend sparse profile
96 > [include]
97 > *.html
98 > EOF
99 $ echo bar >> data.py
100
101 $ hg ci -qAm "edit profile other"
102 $ ls
103 backend.sparse
104 index.html
105 webpage.sparse
106
107 Verify conflicting merge pulls in the conflicting changes
108
109 $ hg merge 1
110 temporarily included 1 file(s) in the sparse checkout for merging
111 merging backend.sparse
112 merging data.py
113 warning: conflicts while merging backend.sparse! (edit, then use 'hg resolve --mark')
114 warning: conflicts while merging data.py! (edit, then use 'hg resolve --mark')
115 0 files updated, 0 files merged, 0 files removed, 2 files unresolved
116 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
117 [1]
118
119 $ rm *.orig
120 $ ls
121 backend.sparse
122 data.py
123 index.html
124 webpage.sparse
125
126 Verify resolving the merge removes the temporarily unioned files
127
128 $ cat > backend.sparse <<EOF
129 > # backend sparse profile
130 > [include]
131 > *.html
132 > *.txt
133 > EOF
134 $ hg resolve -m backend.sparse
135
136 $ cat > data.py <<EOF
137 > x
138 > foo
139 > bar
140 > EOF
141 $ hg resolve -m data.py
142 (no more unresolved files)
143
144 $ hg ci -qAm "merge profiles"
145 $ ls
146 backend.sparse
147 index.html
148 readme.txt
149 webpage.sparse
150
151 $ hg cat -r . data.py
152 x
153 foo
154 bar
155
156 Verify stripping refreshes dirstate
157
158 $ hg strip -q -r .
159 $ ls
160 backend.sparse
161 index.html
162 webpage.sparse
163
164 Verify rebase conflicts pulls in the conflicting changes
165
166 $ hg up -q 1
167 $ ls
168 backend.sparse
169 data.py
170 readme.txt
171 webpage.sparse
172
173 $ hg rebase -d 2
174 rebasing 1:a2b1de640a62 "edit profile"
175 temporarily included 1 file(s) in the sparse checkout for merging
176 merging backend.sparse
177 merging data.py
178 warning: conflicts while merging backend.sparse! (edit, then use 'hg resolve --mark')
179 warning: conflicts while merging data.py! (edit, then use 'hg resolve --mark')
180 unresolved conflicts (see hg resolve, then hg rebase --continue)
181 [1]
182 $ rm *.orig
183 $ ls
184 backend.sparse
185 data.py
186 index.html
187 webpage.sparse
188
189 Verify resolving conflict removes the temporary files
190
191 $ cat > backend.sparse <<EOF
192 > [include]
193 > *.html
194 > *.txt
195 > EOF
196 $ hg resolve -m backend.sparse
197
198 $ cat > data.py <<EOF
199 > x
200 > foo
201 > bar
202 > EOF
203 $ hg resolve -m data.py
204 (no more unresolved files)
205 continue: hg rebase --continue
206
207 $ hg rebase -q --continue
208 $ ls
209 backend.sparse
210 index.html
211 readme.txt
212 webpage.sparse
213
214 $ hg cat -r . data.py
215 x
216 foo
217 bar
218
219 Test checking out a commit that does not contain the sparse profile. The
220 warning message can be suppressed by setting missingwarning = false in
221 [sparse] section of your config:
222
223 $ hg sparse --reset
224 $ hg rm *.sparse
225 $ hg commit -m "delete profiles"
226 $ hg up -q ".^"
227 $ hg sparse --enable-profile backend.sparse
228 $ ls
229 index.html
230 readme.txt
231 $ hg up tip | grep warning
232 warning: sparse profile 'backend.sparse' not found in rev bfcb76de99cc - ignoring it
233 [1]
234 $ ls
235 data.py
236 index.html
237 readme.txt
238 $ hg sparse --disable-profile backend.sparse | grep warning
239 warning: sparse profile 'backend.sparse' not found in rev bfcb76de99cc - ignoring it
240 [1]
241 $ cat >> .hg/hgrc <<EOF
242 > [sparse]
243 > missingwarning = false
244 > EOF
245 $ hg sparse --enable-profile backend.sparse
246
247 $ cd ..
248
249 Test file permissions changing across a sparse profile change
250 $ hg init sparseperm
251 $ cd sparseperm
252 $ cat > .hg/hgrc <<EOF
253 > [extensions]
254 > sparse=
255 > EOF
256 $ touch a b
257 $ cat > .hgsparse <<EOF
258 > a
259 > EOF
260 $ hg commit -Aqm 'initial'
261 $ chmod a+x b
262 $ hg commit -qm 'make executable'
263 $ cat >> .hgsparse <<EOF
264 > b
265 > EOF
266 $ hg commit -qm 'update profile'
267 $ hg up -q 0
268 $ hg sparse --enable-profile .hgsparse
269 $ hg up -q 2
270 $ ls -l b
271 -rwxr-xr-x* b (glob)
272