test-hgignore.t
285 lines
| 5.3 KiB
| text/troff
|
Tads3Lexer
/ tests / test-hgignore.t
|
r25869 | $ hg init ignorerepo | ||
$ cd ignorerepo | ||||
|
r12312 | |||
|
r12399 | Issue562: .hgignore requires newline at end: | ||
|
r12312 | |||
$ touch foo | ||||
$ touch bar | ||||
$ touch baz | ||||
$ cat > makeignore.py <<EOF | ||||
> f = open(".hgignore", "w") | ||||
> f.write("ignore\n") | ||||
> f.write("foo\n") | ||||
> # No EOL here | ||||
> f.write("bar") | ||||
> f.close() | ||||
> EOF | ||||
$ python makeignore.py | ||||
Should display baz only: | ||||
$ hg status | ||||
? baz | ||||
$ rm foo bar baz .hgignore makeignore.py | ||||
$ touch a.o | ||||
$ touch a.c | ||||
$ touch syntax | ||||
$ mkdir dir | ||||
$ touch dir/a.o | ||||
$ touch dir/b.o | ||||
$ touch dir/c.o | ||||
$ hg add dir/a.o | ||||
$ hg commit -m 0 | ||||
$ hg add dir/b.o | ||||
$ hg status | ||||
A dir/b.o | ||||
? a.c | ||||
? a.o | ||||
? dir/c.o | ||||
? syntax | ||||
$ echo "*.o" > .hgignore | ||||
|
r12366 | $ hg status | ||
|
r25869 | abort: $TESTTMP/ignorerepo/.hgignore: invalid pattern (relre): *.o (glob) | ||
|
r12366 | [255] | ||
|
r12312 | |||
$ echo ".*\.o" > .hgignore | ||||
|
r16487 | $ hg status | ||
|
r12312 | A dir/b.o | ||
? .hgignore | ||||
? a.c | ||||
? syntax | ||||
|
r27326 | Ensure that comments work: | ||
|
r27381 | $ touch 'foo#bar' 'quux#' | ||
#if no-windows | ||||
$ touch 'baz\#wat' | ||||
#endif | ||||
|
r27326 | $ cat <<'EOF' >> .hgignore | ||
> # full-line comment | ||||
> # whitespace-only comment line | ||||
> syntax# pattern, no whitespace, then comment | ||||
> a.c # pattern, then whitespace, then comment | ||||
> baz\\# # escaped comment character | ||||
> foo\#b # escaped comment character | ||||
> quux\## escaped comment character at end of name | ||||
> EOF | ||||
$ hg status | ||||
A dir/b.o | ||||
? .hgignore | ||||
|
r27381 | $ rm 'foo#bar' 'quux#' | ||
#if no-windows | ||||
$ rm 'baz\#wat' | ||||
#endif | ||||
|
r27326 | |||
|
r12312 | Check it does not ignore the current directory '.': | ||
$ echo "^\." > .hgignore | ||||
$ hg status | ||||
A dir/b.o | ||||
? a.c | ||||
? a.o | ||||
? dir/c.o | ||||
? syntax | ||||
|
r23628 | Test that patterns from ui.ignore options are read: | ||
$ echo > .hgignore | ||||
$ cat >> $HGRCPATH << EOF | ||||
> [ui] | ||||
|
r25869 | > ignore.other = $TESTTMP/ignorerepo/.hg/testhgignore | ||
|
r23628 | > EOF | ||
$ echo "glob:**.o" > .hg/testhgignore | ||||
|
r12312 | $ hg status | ||
A dir/b.o | ||||
? .hgignore | ||||
? a.c | ||||
? syntax | ||||
|
r23628 | empty out testhgignore | ||
$ echo > .hg/testhgignore | ||||
|
r23629 | |||
Test relative ignore path (issue4473): | ||||
$ cat >> $HGRCPATH << EOF | ||||
> [ui] | ||||
> ignore.relative = .hg/testhgignorerel | ||||
> EOF | ||||
$ echo "glob:*.o" > .hg/testhgignorerel | ||||
$ cd dir | ||||
|
r12312 | $ hg status | ||
A dir/b.o | ||||
? .hgignore | ||||
? a.c | ||||
? syntax | ||||
|
r23629 | $ cd .. | ||
$ echo > .hg/testhgignorerel | ||||
|
r12312 | $ echo "syntax: glob" > .hgignore | ||
$ echo "re:.*\.o" >> .hgignore | ||||
$ hg status | ||||
A dir/b.o | ||||
? .hgignore | ||||
? a.c | ||||
? syntax | ||||
$ echo "syntax: invalid" > .hgignore | ||||
|
r12366 | $ hg status | ||
|
r25869 | $TESTTMP/ignorerepo/.hgignore: ignoring invalid syntax 'invalid' (glob) | ||
|
r12312 | A dir/b.o | ||
? .hgignore | ||||
? a.c | ||||
? a.o | ||||
? dir/c.o | ||||
? syntax | ||||
$ echo "syntax: glob" > .hgignore | ||||
$ echo "*.o" >> .hgignore | ||||
$ hg status | ||||
A dir/b.o | ||||
? .hgignore | ||||
? a.c | ||||
? syntax | ||||
$ echo "relglob:syntax*" > .hgignore | ||||
$ hg status | ||||
A dir/b.o | ||||
? .hgignore | ||||
? a.c | ||||
? a.o | ||||
? dir/c.o | ||||
$ echo "relglob:*" > .hgignore | ||||
$ hg status | ||||
A dir/b.o | ||||
$ cd dir | ||||
$ hg status . | ||||
A b.o | ||||
|
r13396 | $ hg debugignore | ||
(?:(?:|.*/)[^/]*(?:/|$)) | ||||
|
r16913 | |||
|
r27671 | $ hg debugignore b.o | ||
b.o is ignored | ||||
|
r16913 | $ cd .. | ||
|
r19128 | |||
Check patterns that match only the directory | ||||
$ echo "^dir\$" > .hgignore | ||||
$ hg status | ||||
A dir/b.o | ||||
? .hgignore | ||||
? a.c | ||||
? a.o | ||||
? syntax | ||||
|
r21815 | |||
Check recursive glob pattern matches no directories (dir/**/c.o matches dir/c.o) | ||||
$ echo "syntax: glob" > .hgignore | ||||
$ echo "dir/**/c.o" >> .hgignore | ||||
$ touch dir/c.o | ||||
$ mkdir dir/subdir | ||||
$ touch dir/subdir/c.o | ||||
$ hg status | ||||
A dir/b.o | ||||
? .hgignore | ||||
? a.c | ||||
? a.o | ||||
? syntax | ||||
|
r27671 | $ hg debugignore a.c | ||
a.c is not ignored | ||||
$ hg debugignore dir/c.o | ||||
dir/c.o is ignored | ||||
|
r25215 | |||
Check using 'include:' in ignore file | ||||
$ hg purge --all --config extensions.purge= | ||||
$ touch foo.included | ||||
$ echo ".*.included" > otherignore | ||||
$ hg status -I "include:otherignore" | ||||
? foo.included | ||||
$ echo "include:otherignore" >> .hgignore | ||||
$ hg status | ||||
A dir/b.o | ||||
? .hgignore | ||||
? otherignore | ||||
Check recursive uses of 'include:' | ||||
|
r25870 | $ echo "include:nested/ignore" >> otherignore | ||
$ mkdir nested | ||||
$ echo "glob:*ignore" > nested/ignore | ||||
|
r25215 | $ hg status | ||
A dir/b.o | ||||
|
r25216 | |||
|
r25283 | $ cp otherignore goodignore | ||
|
r25216 | $ echo "include:badignore" >> otherignore | ||
$ hg status | ||||
skipping unreadable pattern file 'badignore': No such file or directory | ||||
A dir/b.o | ||||
|
r25283 | |||
$ mv goodignore otherignore | ||||
|
r25870 | Check using 'include:' while in a non-root directory | ||
$ cd .. | ||||
$ hg -R ignorerepo status | ||||
A dir/b.o | ||||
$ cd ignorerepo | ||||
|
r25283 | Check including subincludes | ||
$ hg revert -q --all | ||||
$ hg purge --all --config extensions.purge= | ||||
$ echo ".hgignore" > .hgignore | ||||
$ mkdir dir1 dir2 | ||||
$ touch dir1/file1 dir1/file2 dir2/file1 dir2/file2 | ||||
$ echo "subinclude:dir2/.hgignore" >> .hgignore | ||||
$ echo "glob:file*2" > dir2/.hgignore | ||||
$ hg status | ||||
? dir1/file1 | ||||
? dir1/file2 | ||||
? dir2/file1 | ||||
Check including subincludes with regexs | ||||
$ echo "subinclude:dir1/.hgignore" >> .hgignore | ||||
$ echo "regexp:f.le1" > dir1/.hgignore | ||||
$ hg status | ||||
? dir1/file2 | ||||
? dir2/file1 | ||||
Check multiple levels of sub-ignores | ||||
$ mkdir dir1/subdir | ||||
$ touch dir1/subdir/subfile1 dir1/subdir/subfile3 dir1/subdir/subfile4 | ||||
$ echo "subinclude:subdir/.hgignore" >> dir1/.hgignore | ||||
$ echo "glob:subfil*3" >> dir1/subdir/.hgignore | ||||
$ hg status | ||||
? dir1/file2 | ||||
? dir1/subdir/subfile4 | ||||
? dir2/file1 | ||||
Check include subignore at the same level | ||||
$ mv dir1/subdir/.hgignore dir1/.hgignoretwo | ||||
$ echo "regexp:f.le1" > dir1/.hgignore | ||||
$ echo "subinclude:.hgignoretwo" >> dir1/.hgignore | ||||
$ echo "glob:file*2" > dir1/.hgignoretwo | ||||
$ hg status | grep file2 | ||||
[1] | ||||
|
r27671 | $ hg debugignore dir1/file2 | ||
dir1/file2 is ignored | ||||