| 1 |
test sparse |
| 2 |
|
| 3 |
$ hg init myrepo |
| 4 |
$ cd myrepo |
| 5 |
$ cat > .hg/hgrc <<EOF |
| 6 |
> [extensions] |
| 7 |
> sparse= |
| 8 |
> strip= |
| 9 |
> EOF |
| 10 |
|
| 11 |
$ echo a > show |
| 12 |
$ echo x > hide |
| 13 |
$ hg ci -Aqm 'initial' |
| 14 |
|
| 15 |
$ echo b > show |
| 16 |
$ echo y > hide |
| 17 |
$ echo aa > show2 |
| 18 |
$ echo xx > hide2 |
| 19 |
$ hg ci -Aqm 'two' |
| 20 |
|
| 21 |
Verify basic --include |
| 22 |
|
| 23 |
$ hg up -q 0 |
| 24 |
|
| 25 |
Test that sparse pattern by default is interpreted as "glob:", and is interpreted relative to the root. |
| 26 |
|
| 27 |
$ hg debugsparse --reset |
| 28 |
$ hg debugsparse -X 'foo*bar' |
| 29 |
$ cat .hg/sparse |
| 30 |
[exclude] |
| 31 |
foo*bar |
| 32 |
|
| 33 |
$ mk() { mkdir -p "$1"; touch "$1"/"$2"; } |
| 34 |
$ mk 'foo' bar |
| 35 |
$ mk 'foo-bar' x |
| 36 |
$ mk 'unanchoredfoo-bar' x |
| 37 |
#if no-windows |
| 38 |
$ mk 'foo*bar' x |
| 39 |
#endif |
| 40 |
$ mk 'dir/foo-bar' x |
| 41 |
$ hg status --config rhg.on-unsupported=abort |
| 42 |
? dir/foo-bar/x |
| 43 |
? foo/bar |
| 44 |
? unanchoredfoo-bar/x |
| 45 |
$ hg clean -a --no-confirm |
| 46 |
$ rm -r foo*bar |
| 47 |
$ hg debugsparse --reset |
| 48 |
|
| 49 |
$ hg debugsparse --include 'hide' |
| 50 |
$ ls -A |
| 51 |
.hg |
| 52 |
hide |
| 53 |
|
| 54 |
Test that status --rev --rev and --change ignore sparse rules. |
| 55 |
$ hg status --rev null --rev 0 |
| 56 |
A hide |
| 57 |
A show |
| 58 |
$ hg status --change 0 |
| 59 |
A hide |
| 60 |
A show |
| 61 |
|
| 62 |
Absolute paths outside the repo should just be rejected |
| 63 |
|
| 64 |
#if no-windows |
| 65 |
$ hg debugsparse --include /foo/bar |
| 66 |
abort: paths cannot be absolute |
| 67 |
[255] |
| 68 |
$ hg debugsparse --include '$TESTTMP/myrepo/hide' |
| 69 |
|
| 70 |
$ hg debugsparse --include '/root' |
| 71 |
abort: paths cannot be absolute |
| 72 |
[255] |
| 73 |
#else |
| 74 |
TODO: See if this can be made to fail the same way as on Unix |
| 75 |
$ hg debugsparse --include /c/foo/bar |
| 76 |
abort: paths cannot be absolute |
| 77 |
[255] |
| 78 |
$ hg debugsparse --include '$TESTTMP/myrepo/hide' |
| 79 |
|
| 80 |
$ hg debugsparse --include '/c/root' |
| 81 |
abort: paths cannot be absolute |
| 82 |
[255] |
| 83 |
#endif |
| 84 |
|
| 85 |
Paths should be treated as cwd-relative, not repo-root-relative |
| 86 |
$ mkdir subdir && cd subdir |
| 87 |
$ hg debugsparse --include path |
| 88 |
$ hg debugsparse |
| 89 |
[include] |
| 90 |
$TESTTMP/myrepo/hide |
| 91 |
hide |
| 92 |
subdir/path |
| 93 |
|
| 94 |
$ cd .. |
| 95 |
$ echo hello > subdir/file2.ext |
| 96 |
$ cd subdir |
| 97 |
$ hg debugsparse --include '**.ext' # let us test globs |
| 98 |
$ hg debugsparse --include 'path:abspath' # and a path: pattern |
| 99 |
$ cd .. |
| 100 |
$ hg debugsparse |
| 101 |
[include] |
| 102 |
$TESTTMP/myrepo/hide |
| 103 |
hide |
| 104 |
path:abspath |
| 105 |
subdir/**.ext |
| 106 |
subdir/path |
| 107 |
|
| 108 |
$ rm -rf subdir |
| 109 |
|
| 110 |
Verify commiting while sparse includes other files |
| 111 |
|
| 112 |
$ echo z > hide |
| 113 |
$ hg ci -Aqm 'edit hide' |
| 114 |
$ ls -A |
| 115 |
.hg |
| 116 |
hide |
| 117 |
$ hg manifest |
| 118 |
hide |
| 119 |
show |
| 120 |
|
| 121 |
Verify --reset brings files back |
| 122 |
|
| 123 |
$ hg debugsparse --reset |
| 124 |
$ ls -A |
| 125 |
.hg |
| 126 |
hide |
| 127 |
show |
| 128 |
$ cat hide |
| 129 |
z |
| 130 |
$ cat show |
| 131 |
a |
| 132 |
|
| 133 |
Verify 'hg debugsparse' default output |
| 134 |
|
| 135 |
$ hg up -q null |
| 136 |
$ hg debugsparse --include 'show*' |
| 137 |
|
| 138 |
$ hg debugsparse |
| 139 |
[include] |
| 140 |
show* |
| 141 |
|
| 142 |
Verify update only writes included files |
| 143 |
|
| 144 |
$ hg up -q 0 |
| 145 |
$ ls -A |
| 146 |
.hg |
| 147 |
show |
| 148 |
|
| 149 |
$ hg up -q 1 |
| 150 |
$ ls -A |
| 151 |
.hg |
| 152 |
show |
| 153 |
show2 |
| 154 |
|
| 155 |
Verify status only shows included files |
| 156 |
|
| 157 |
$ touch hide |
| 158 |
$ touch hide3 |
| 159 |
$ echo c > show |
| 160 |
$ hg status |
| 161 |
M show |
| 162 |
|
| 163 |
Adding an excluded file should fail |
| 164 |
|
| 165 |
$ hg add hide3 |
| 166 |
abort: cannot add 'hide3' - it is outside the sparse checkout |
| 167 |
(include file with `hg debugsparse --include <pattern>` or use `hg add -s <file>` to include file directory while adding) |
| 168 |
[255] |
| 169 |
|
| 170 |
But adding a truly excluded file shouldn't count |
| 171 |
|
| 172 |
$ hg add hide3 -X hide3 |
| 173 |
|
| 174 |
Verify deleting sparseness while a file has changes fails |
| 175 |
|
| 176 |
$ hg debugsparse --delete 'show*' |
| 177 |
pending changes to 'hide' |
| 178 |
abort: cannot change sparseness due to pending changes (delete the files or use --force to bring them back dirty) |
| 179 |
[255] |
| 180 |
|
| 181 |
Verify deleting sparseness with --force brings back files |
| 182 |
|
| 183 |
$ hg debugsparse -f --delete 'show*' |
| 184 |
pending changes to 'hide' |
| 185 |
$ ls -A |
| 186 |
.hg |
| 187 |
hide |
| 188 |
hide2 |
| 189 |
hide3 |
| 190 |
show |
| 191 |
show2 |
| 192 |
$ hg st |
| 193 |
M hide |
| 194 |
M show |
| 195 |
? hide3 |
| 196 |
|
| 197 |
Verify editing sparseness fails if pending changes |
| 198 |
|
| 199 |
$ hg debugsparse --include 'show*' |
| 200 |
pending changes to 'hide' |
| 201 |
abort: could not update sparseness due to pending changes |
| 202 |
[255] |
| 203 |
|
| 204 |
Verify adding sparseness hides files |
| 205 |
|
| 206 |
$ hg debugsparse -f --exclude 'hide*' |
| 207 |
pending changes to 'hide' |
| 208 |
$ ls -A |
| 209 |
.hg |
| 210 |
hide |
| 211 |
hide3 |
| 212 |
show |
| 213 |
show2 |
| 214 |
$ hg st |
| 215 |
M show |
| 216 |
|
| 217 |
$ hg up -qC . |
| 218 |
TODO: add an option to purge to also purge files outside the sparse config? |
| 219 |
$ hg purge --all --config extensions.purge= |
| 220 |
$ ls -A |
| 221 |
.hg |
| 222 |
hide |
| 223 |
hide3 |
| 224 |
show |
| 225 |
show2 |
| 226 |
For now, manually remove the files |
| 227 |
$ rm hide hide3 |
| 228 |
|
| 229 |
Verify rebase temporarily includes excluded files |
| 230 |
|
| 231 |
$ hg rebase -d 1 -r 2 --config extensions.rebase= |
| 232 |
rebasing 2:b91df4f39e75 tip "edit hide" |
| 233 |
temporarily included 2 file(s) in the sparse checkout for merging |
| 234 |
merging hide |
| 235 |
warning: conflicts while merging hide! (edit, then use 'hg resolve --mark') |
| 236 |
unresolved conflicts (see 'hg resolve', then 'hg rebase --continue') |
| 237 |
[240] |
| 238 |
|
| 239 |
$ hg debugsparse |
| 240 |
[exclude] |
| 241 |
hide* |
| 242 |
|
| 243 |
Temporarily Included Files (for merge/rebase): |
| 244 |
hide |
| 245 |
|
| 246 |
$ cat hide |
| 247 |
<<<<<<< dest: 39278f7c08a9 - test: two |
| 248 |
y |
| 249 |
======= |
| 250 |
z |
| 251 |
>>>>>>> source: b91df4f39e75 - test: edit hide |
| 252 |
|
| 253 |
Verify aborting a rebase cleans up temporary files |
| 254 |
|
| 255 |
$ hg rebase --abort --config extensions.rebase= |
| 256 |
cleaned up 1 temporarily added file(s) from the sparse checkout |
| 257 |
rebase aborted |
| 258 |
$ rm hide.orig |
| 259 |
|
| 260 |
$ ls -A |
| 261 |
.hg |
| 262 |
show |
| 263 |
show2 |
| 264 |
|
| 265 |
Verify merge fails if merging excluded files |
| 266 |
|
| 267 |
$ hg up -q 1 |
| 268 |
$ hg merge -r 2 |
| 269 |
temporarily included 2 file(s) in the sparse checkout for merging |
| 270 |
merging hide |
| 271 |
warning: conflicts while merging hide! (edit, then use 'hg resolve --mark') |
| 272 |
0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
| 273 |
use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon |
| 274 |
[1] |
| 275 |
$ hg debugsparse |
| 276 |
[exclude] |
| 277 |
hide* |
| 278 |
|
| 279 |
Temporarily Included Files (for merge/rebase): |
| 280 |
hide |
| 281 |
|
| 282 |
$ hg up -C . |
| 283 |
cleaned up 1 temporarily added file(s) from the sparse checkout |
| 284 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 285 |
$ hg debugsparse |
| 286 |
[exclude] |
| 287 |
hide* |
| 288 |
|
| 289 |
|
| 290 |
Multiple -I and -X can be passed at once |
| 291 |
|
| 292 |
$ hg debugsparse --reset -I '*2' -X 'hide2' |
| 293 |
$ ls -A |
| 294 |
.hg |
| 295 |
hide.orig |
| 296 |
show2 |
| 297 |
$ hg debugsparse --reset -X 'hide*' |
| 298 |
|
| 299 |
Verify strip -k resets dirstate correctly |
| 300 |
|
| 301 |
$ hg status |
| 302 |
$ hg debugsparse |
| 303 |
[exclude] |
| 304 |
hide* |
| 305 |
|
| 306 |
$ hg log -r . -T '{rev}\n' --stat |
| 307 |
1 |
| 308 |
hide | 2 +- |
| 309 |
hide2 | 1 + |
| 310 |
show | 2 +- |
| 311 |
show2 | 1 + |
| 312 |
4 files changed, 4 insertions(+), 2 deletions(-) |
| 313 |
|
| 314 |
$ hg strip -r . -k |
| 315 |
saved backup bundle to $TESTTMP/myrepo/.hg/strip-backup/39278f7c08a9-ce59e002-backup.hg |
| 316 |
$ hg status |
| 317 |
M show |
| 318 |
? show2 |
| 319 |
|
| 320 |
Verify rebase succeeds if all changed files are in sparse checkout |
| 321 |
|
| 322 |
$ hg commit -Aqm "add show2" |
| 323 |
$ hg rebase -d 1 --config extensions.rebase= |
| 324 |
rebasing 2:bdde55290160 tip "add show2" |
| 325 |
saved backup bundle to $TESTTMP/myrepo/.hg/strip-backup/bdde55290160-216ed9c6-rebase.hg |
| 326 |
|
| 327 |
Verify log --sparse only shows commits that affect the sparse checkout |
| 328 |
|
| 329 |
$ hg log -T '{rev} ' |
| 330 |
2 1 0 (no-eol) |
| 331 |
$ hg log --sparse -T '{rev} ' |
| 332 |
2 0 (no-eol) |
| 333 |
|
| 334 |
Test status on a file in a subdir |
| 335 |
|
| 336 |
$ mkdir -p dir1/dir2 |
| 337 |
$ touch dir1/dir2/file |
| 338 |
$ hg debugsparse -I dir1/dir2 |
| 339 |
$ hg status |
| 340 |
? dir1/dir2/file |
| 341 |
|
| 342 |
Mix files and subdirectories, both "glob:" and unprefixed |
| 343 |
|
| 344 |
$ hg debugsparse --reset |
| 345 |
$ touch dir1/notshown |
| 346 |
$ hg commit -A dir1/notshown -m "notshown" |
| 347 |
$ hg debugsparse --include 'dir1/dir2' |
| 348 |
$ "$PYTHON" $TESTDIR/list-tree.py . | grep -E -v '\.[\/]\.hg' |
| 349 |
./ |
| 350 |
./dir1/ |
| 351 |
./dir1/dir2/ |
| 352 |
./dir1/dir2/file |
| 353 |
./hide.orig |
| 354 |
$ hg debugsparse --delete 'dir1/dir2' |
| 355 |
$ hg debugsparse --include 'glob:dir1/dir2' |
| 356 |
$ "$PYTHON" $TESTDIR/list-tree.py . | grep -E -v '\.[\/]\.hg' |
| 357 |
./ |
| 358 |
./dir1/ |
| 359 |
./dir1/dir2/ |
| 360 |
./dir1/dir2/file |
| 361 |
./hide.orig |
| 362 |
|
| 363 |
Test that add -s adds dirs to sparse profile |
| 364 |
|
| 365 |
$ hg debugsparse --reset |
| 366 |
$ hg debugsparse --include empty |
| 367 |
$ hg debugsparse |
| 368 |
[include] |
| 369 |
empty |
| 370 |
|
| 371 |
|
| 372 |
$ mkdir add |
| 373 |
$ touch add/foo |
| 374 |
$ touch add/bar |
| 375 |
$ hg add add/foo |
| 376 |
abort: cannot add 'add/foo' - it is outside the sparse checkout |
| 377 |
(include file with `hg debugsparse --include <pattern>` or use `hg add -s <file>` to include file directory while adding) |
| 378 |
[255] |
| 379 |
$ hg add -s add/foo |
| 380 |
$ hg st |
| 381 |
A add/foo |
| 382 |
? add/bar |
| 383 |
$ hg debugsparse |
| 384 |
[include] |
| 385 |
add |
| 386 |
empty |
| 387 |
|
| 388 |
$ hg add -s add/* |
| 389 |
add/foo already tracked! |
| 390 |
$ hg st |
| 391 |
A add/bar |
| 392 |
A add/foo |
| 393 |
$ hg debugsparse |
| 394 |
[include] |
| 395 |
add |
| 396 |
empty |
| 397 |
|
| 398 |
|
| 399 |
$ cd .. |
| 400 |
|
| 401 |
Test non-sparse repos work while sparse is loaded |
| 402 |
$ hg init sparserepo |
| 403 |
$ hg init nonsparserepo |
| 404 |
$ cd sparserepo |
| 405 |
$ cat > .hg/hgrc <<EOF |
| 406 |
> [extensions] |
| 407 |
> sparse= |
| 408 |
> EOF |
| 409 |
$ cd ../nonsparserepo |
| 410 |
$ echo x > x && hg add x && hg commit -qAm x |
| 411 |
$ cd ../sparserepo |
| 412 |
$ hg clone ../nonsparserepo ../nonsparserepo2 |
| 413 |
updating to branch default |
| 414 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 415 |
|
| 416 |
Test debugrebuilddirstate |
| 417 |
$ cd ../sparserepo |
| 418 |
$ touch included |
| 419 |
$ touch excluded |
| 420 |
$ hg add included excluded |
| 421 |
$ hg commit -m 'a commit' -q |
| 422 |
$ cp .hg/dirstate ../dirstateboth |
| 423 |
$ hg debugsparse -X excluded |
| 424 |
$ cp ../dirstateboth .hg/dirstate |
| 425 |
$ hg debugrebuilddirstate |
| 426 |
$ hg debugdirstate |
| 427 |
n 0 -1 unset included |
| 428 |
|
| 429 |
Test debugdirstate --minimal where file is in the parent manifest but not the |
| 430 |
dirstate |
| 431 |
$ hg debugsparse -X included |
| 432 |
$ hg debugdirstate |
| 433 |
$ cp .hg/dirstate ../dirstateallexcluded |
| 434 |
$ hg debugsparse --reset |
| 435 |
$ hg debugsparse -X excluded |
| 436 |
$ cp ../dirstateallexcluded .hg/dirstate |
| 437 |
$ touch includedadded |
| 438 |
$ hg add includedadded |
| 439 |
$ hg debugdirstate --no-dates |
| 440 |
a 0 -1 unset includedadded |
| 441 |
$ hg debugrebuilddirstate --minimal |
| 442 |
$ hg debugdirstate --no-dates |
| 443 |
n 0 -1 unset included |
| 444 |
a 0 -1 * includedadded (glob) |
| 445 |
|
| 446 |
Test debugdirstate --minimal where a file is not in parent manifest |
| 447 |
but in the dirstate. This should take into account excluded files in the |
| 448 |
manifest |
| 449 |
$ cp ../dirstateboth .hg/dirstate |
| 450 |
$ touch includedadded |
| 451 |
$ hg add includedadded |
| 452 |
$ touch excludednomanifest |
| 453 |
$ hg add excludednomanifest |
| 454 |
$ cp .hg/dirstate ../moreexcluded |
| 455 |
$ hg forget excludednomanifest |
| 456 |
$ rm excludednomanifest |
| 457 |
$ hg debugsparse -X excludednomanifest |
| 458 |
$ cp ../moreexcluded .hg/dirstate |
| 459 |
$ hg manifest |
| 460 |
excluded |
| 461 |
included |
| 462 |
We have files in the dirstate that are included and excluded. Some are in the |
| 463 |
manifest and some are not. |
| 464 |
$ hg debugdirstate --no-dates |
| 465 |
n * excluded (glob) |
| 466 |
a * excludednomanifest (glob) |
| 467 |
n * included (glob) |
| 468 |
a * includedadded (glob) |
| 469 |
$ hg debugrebuilddirstate --minimal |
| 470 |
$ hg debugdirstate --no-dates |
| 471 |
n * included (glob) |
| 472 |
a * includedadded (glob) |
| 473 |
|