Show More
@@ -1,270 +1,276 b'' | |||||
1 | $ hg init ignorerepo |
|
1 | $ hg init ignorerepo | |
2 | $ cd ignorerepo |
|
2 | $ cd ignorerepo | |
3 |
|
3 | |||
4 | Issue562: .hgignore requires newline at end: |
|
4 | Issue562: .hgignore requires newline at end: | |
5 |
|
5 | |||
6 | $ touch foo |
|
6 | $ touch foo | |
7 | $ touch bar |
|
7 | $ touch bar | |
8 | $ touch baz |
|
8 | $ touch baz | |
9 | $ cat > makeignore.py <<EOF |
|
9 | $ cat > makeignore.py <<EOF | |
10 | > f = open(".hgignore", "w") |
|
10 | > f = open(".hgignore", "w") | |
11 | > f.write("ignore\n") |
|
11 | > f.write("ignore\n") | |
12 | > f.write("foo\n") |
|
12 | > f.write("foo\n") | |
13 | > # No EOL here |
|
13 | > # No EOL here | |
14 | > f.write("bar") |
|
14 | > f.write("bar") | |
15 | > f.close() |
|
15 | > f.close() | |
16 | > EOF |
|
16 | > EOF | |
17 |
|
17 | |||
18 | $ python makeignore.py |
|
18 | $ python makeignore.py | |
19 |
|
19 | |||
20 | Should display baz only: |
|
20 | Should display baz only: | |
21 |
|
21 | |||
22 | $ hg status |
|
22 | $ hg status | |
23 | ? baz |
|
23 | ? baz | |
24 |
|
24 | |||
25 | $ rm foo bar baz .hgignore makeignore.py |
|
25 | $ rm foo bar baz .hgignore makeignore.py | |
26 |
|
26 | |||
27 | $ touch a.o |
|
27 | $ touch a.o | |
28 | $ touch a.c |
|
28 | $ touch a.c | |
29 | $ touch syntax |
|
29 | $ touch syntax | |
30 | $ mkdir dir |
|
30 | $ mkdir dir | |
31 | $ touch dir/a.o |
|
31 | $ touch dir/a.o | |
32 | $ touch dir/b.o |
|
32 | $ touch dir/b.o | |
33 | $ touch dir/c.o |
|
33 | $ touch dir/c.o | |
34 |
|
34 | |||
35 | $ hg add dir/a.o |
|
35 | $ hg add dir/a.o | |
36 | $ hg commit -m 0 |
|
36 | $ hg commit -m 0 | |
37 | $ hg add dir/b.o |
|
37 | $ hg add dir/b.o | |
38 |
|
38 | |||
39 | $ hg status |
|
39 | $ hg status | |
40 | A dir/b.o |
|
40 | A dir/b.o | |
41 | ? a.c |
|
41 | ? a.c | |
42 | ? a.o |
|
42 | ? a.o | |
43 | ? dir/c.o |
|
43 | ? dir/c.o | |
44 | ? syntax |
|
44 | ? syntax | |
45 |
|
45 | |||
46 | $ echo "*.o" > .hgignore |
|
46 | $ echo "*.o" > .hgignore | |
47 | $ hg status |
|
47 | $ hg status | |
48 | abort: $TESTTMP/ignorerepo/.hgignore: invalid pattern (relre): *.o (glob) |
|
48 | abort: $TESTTMP/ignorerepo/.hgignore: invalid pattern (relre): *.o (glob) | |
49 | [255] |
|
49 | [255] | |
50 |
|
50 | |||
51 | $ echo ".*\.o" > .hgignore |
|
51 | $ echo ".*\.o" > .hgignore | |
52 | $ hg status |
|
52 | $ hg status | |
53 | A dir/b.o |
|
53 | A dir/b.o | |
54 | ? .hgignore |
|
54 | ? .hgignore | |
55 | ? a.c |
|
55 | ? a.c | |
56 | ? syntax |
|
56 | ? syntax | |
57 |
|
57 | |||
58 | Ensure that comments work: |
|
58 | Ensure that comments work: | |
59 |
|
59 | |||
60 |
$ touch 'foo#bar' 'quux#' |
|
60 | $ touch 'foo#bar' 'quux#' | |
|
61 | #if no-windows | |||
|
62 | $ touch 'baz\#wat' | |||
|
63 | #endif | |||
61 | $ cat <<'EOF' >> .hgignore |
|
64 | $ cat <<'EOF' >> .hgignore | |
62 | > # full-line comment |
|
65 | > # full-line comment | |
63 | > # whitespace-only comment line |
|
66 | > # whitespace-only comment line | |
64 | > syntax# pattern, no whitespace, then comment |
|
67 | > syntax# pattern, no whitespace, then comment | |
65 | > a.c # pattern, then whitespace, then comment |
|
68 | > a.c # pattern, then whitespace, then comment | |
66 | > baz\\# # escaped comment character |
|
69 | > baz\\# # escaped comment character | |
67 | > foo\#b # escaped comment character |
|
70 | > foo\#b # escaped comment character | |
68 | > quux\## escaped comment character at end of name |
|
71 | > quux\## escaped comment character at end of name | |
69 | > EOF |
|
72 | > EOF | |
70 | $ hg status |
|
73 | $ hg status | |
71 | A dir/b.o |
|
74 | A dir/b.o | |
72 | ? .hgignore |
|
75 | ? .hgignore | |
73 |
$ rm 'foo#bar' 'quux#' |
|
76 | $ rm 'foo#bar' 'quux#' | |
|
77 | #if no-windows | |||
|
78 | $ rm 'baz\#wat' | |||
|
79 | #endif | |||
74 |
|
80 | |||
75 | Check it does not ignore the current directory '.': |
|
81 | Check it does not ignore the current directory '.': | |
76 |
|
82 | |||
77 | $ echo "^\." > .hgignore |
|
83 | $ echo "^\." > .hgignore | |
78 | $ hg status |
|
84 | $ hg status | |
79 | A dir/b.o |
|
85 | A dir/b.o | |
80 | ? a.c |
|
86 | ? a.c | |
81 | ? a.o |
|
87 | ? a.o | |
82 | ? dir/c.o |
|
88 | ? dir/c.o | |
83 | ? syntax |
|
89 | ? syntax | |
84 |
|
90 | |||
85 | Test that patterns from ui.ignore options are read: |
|
91 | Test that patterns from ui.ignore options are read: | |
86 |
|
92 | |||
87 | $ echo > .hgignore |
|
93 | $ echo > .hgignore | |
88 | $ cat >> $HGRCPATH << EOF |
|
94 | $ cat >> $HGRCPATH << EOF | |
89 | > [ui] |
|
95 | > [ui] | |
90 | > ignore.other = $TESTTMP/ignorerepo/.hg/testhgignore |
|
96 | > ignore.other = $TESTTMP/ignorerepo/.hg/testhgignore | |
91 | > EOF |
|
97 | > EOF | |
92 | $ echo "glob:**.o" > .hg/testhgignore |
|
98 | $ echo "glob:**.o" > .hg/testhgignore | |
93 | $ hg status |
|
99 | $ hg status | |
94 | A dir/b.o |
|
100 | A dir/b.o | |
95 | ? .hgignore |
|
101 | ? .hgignore | |
96 | ? a.c |
|
102 | ? a.c | |
97 | ? syntax |
|
103 | ? syntax | |
98 |
|
104 | |||
99 | empty out testhgignore |
|
105 | empty out testhgignore | |
100 | $ echo > .hg/testhgignore |
|
106 | $ echo > .hg/testhgignore | |
101 |
|
107 | |||
102 | Test relative ignore path (issue4473): |
|
108 | Test relative ignore path (issue4473): | |
103 |
|
109 | |||
104 | $ cat >> $HGRCPATH << EOF |
|
110 | $ cat >> $HGRCPATH << EOF | |
105 | > [ui] |
|
111 | > [ui] | |
106 | > ignore.relative = .hg/testhgignorerel |
|
112 | > ignore.relative = .hg/testhgignorerel | |
107 | > EOF |
|
113 | > EOF | |
108 | $ echo "glob:*.o" > .hg/testhgignorerel |
|
114 | $ echo "glob:*.o" > .hg/testhgignorerel | |
109 | $ cd dir |
|
115 | $ cd dir | |
110 | $ hg status |
|
116 | $ hg status | |
111 | A dir/b.o |
|
117 | A dir/b.o | |
112 | ? .hgignore |
|
118 | ? .hgignore | |
113 | ? a.c |
|
119 | ? a.c | |
114 | ? syntax |
|
120 | ? syntax | |
115 |
|
121 | |||
116 | $ cd .. |
|
122 | $ cd .. | |
117 | $ echo > .hg/testhgignorerel |
|
123 | $ echo > .hg/testhgignorerel | |
118 | $ echo "syntax: glob" > .hgignore |
|
124 | $ echo "syntax: glob" > .hgignore | |
119 | $ echo "re:.*\.o" >> .hgignore |
|
125 | $ echo "re:.*\.o" >> .hgignore | |
120 | $ hg status |
|
126 | $ hg status | |
121 | A dir/b.o |
|
127 | A dir/b.o | |
122 | ? .hgignore |
|
128 | ? .hgignore | |
123 | ? a.c |
|
129 | ? a.c | |
124 | ? syntax |
|
130 | ? syntax | |
125 |
|
131 | |||
126 | $ echo "syntax: invalid" > .hgignore |
|
132 | $ echo "syntax: invalid" > .hgignore | |
127 | $ hg status |
|
133 | $ hg status | |
128 | $TESTTMP/ignorerepo/.hgignore: ignoring invalid syntax 'invalid' (glob) |
|
134 | $TESTTMP/ignorerepo/.hgignore: ignoring invalid syntax 'invalid' (glob) | |
129 | A dir/b.o |
|
135 | A dir/b.o | |
130 | ? .hgignore |
|
136 | ? .hgignore | |
131 | ? a.c |
|
137 | ? a.c | |
132 | ? a.o |
|
138 | ? a.o | |
133 | ? dir/c.o |
|
139 | ? dir/c.o | |
134 | ? syntax |
|
140 | ? syntax | |
135 |
|
141 | |||
136 | $ echo "syntax: glob" > .hgignore |
|
142 | $ echo "syntax: glob" > .hgignore | |
137 | $ echo "*.o" >> .hgignore |
|
143 | $ echo "*.o" >> .hgignore | |
138 | $ hg status |
|
144 | $ hg status | |
139 | A dir/b.o |
|
145 | A dir/b.o | |
140 | ? .hgignore |
|
146 | ? .hgignore | |
141 | ? a.c |
|
147 | ? a.c | |
142 | ? syntax |
|
148 | ? syntax | |
143 |
|
149 | |||
144 | $ echo "relglob:syntax*" > .hgignore |
|
150 | $ echo "relglob:syntax*" > .hgignore | |
145 | $ hg status |
|
151 | $ hg status | |
146 | A dir/b.o |
|
152 | A dir/b.o | |
147 | ? .hgignore |
|
153 | ? .hgignore | |
148 | ? a.c |
|
154 | ? a.c | |
149 | ? a.o |
|
155 | ? a.o | |
150 | ? dir/c.o |
|
156 | ? dir/c.o | |
151 |
|
157 | |||
152 | $ echo "relglob:*" > .hgignore |
|
158 | $ echo "relglob:*" > .hgignore | |
153 | $ hg status |
|
159 | $ hg status | |
154 | A dir/b.o |
|
160 | A dir/b.o | |
155 |
|
161 | |||
156 | $ cd dir |
|
162 | $ cd dir | |
157 | $ hg status . |
|
163 | $ hg status . | |
158 | A b.o |
|
164 | A b.o | |
159 |
|
165 | |||
160 | $ hg debugignore |
|
166 | $ hg debugignore | |
161 | (?:(?:|.*/)[^/]*(?:/|$)) |
|
167 | (?:(?:|.*/)[^/]*(?:/|$)) | |
162 |
|
168 | |||
163 | $ cd .. |
|
169 | $ cd .. | |
164 |
|
170 | |||
165 | Check patterns that match only the directory |
|
171 | Check patterns that match only the directory | |
166 |
|
172 | |||
167 | $ echo "^dir\$" > .hgignore |
|
173 | $ echo "^dir\$" > .hgignore | |
168 | $ hg status |
|
174 | $ hg status | |
169 | A dir/b.o |
|
175 | A dir/b.o | |
170 | ? .hgignore |
|
176 | ? .hgignore | |
171 | ? a.c |
|
177 | ? a.c | |
172 | ? a.o |
|
178 | ? a.o | |
173 | ? syntax |
|
179 | ? syntax | |
174 |
|
180 | |||
175 | Check recursive glob pattern matches no directories (dir/**/c.o matches dir/c.o) |
|
181 | Check recursive glob pattern matches no directories (dir/**/c.o matches dir/c.o) | |
176 |
|
182 | |||
177 | $ echo "syntax: glob" > .hgignore |
|
183 | $ echo "syntax: glob" > .hgignore | |
178 | $ echo "dir/**/c.o" >> .hgignore |
|
184 | $ echo "dir/**/c.o" >> .hgignore | |
179 | $ touch dir/c.o |
|
185 | $ touch dir/c.o | |
180 | $ mkdir dir/subdir |
|
186 | $ mkdir dir/subdir | |
181 | $ touch dir/subdir/c.o |
|
187 | $ touch dir/subdir/c.o | |
182 | $ hg status |
|
188 | $ hg status | |
183 | A dir/b.o |
|
189 | A dir/b.o | |
184 | ? .hgignore |
|
190 | ? .hgignore | |
185 | ? a.c |
|
191 | ? a.c | |
186 | ? a.o |
|
192 | ? a.o | |
187 | ? syntax |
|
193 | ? syntax | |
188 |
|
194 | |||
189 | Check using 'include:' in ignore file |
|
195 | Check using 'include:' in ignore file | |
190 |
|
196 | |||
191 | $ hg purge --all --config extensions.purge= |
|
197 | $ hg purge --all --config extensions.purge= | |
192 | $ touch foo.included |
|
198 | $ touch foo.included | |
193 |
|
199 | |||
194 | $ echo ".*.included" > otherignore |
|
200 | $ echo ".*.included" > otherignore | |
195 | $ hg status -I "include:otherignore" |
|
201 | $ hg status -I "include:otherignore" | |
196 | ? foo.included |
|
202 | ? foo.included | |
197 |
|
203 | |||
198 | $ echo "include:otherignore" >> .hgignore |
|
204 | $ echo "include:otherignore" >> .hgignore | |
199 | $ hg status |
|
205 | $ hg status | |
200 | A dir/b.o |
|
206 | A dir/b.o | |
201 | ? .hgignore |
|
207 | ? .hgignore | |
202 | ? otherignore |
|
208 | ? otherignore | |
203 |
|
209 | |||
204 | Check recursive uses of 'include:' |
|
210 | Check recursive uses of 'include:' | |
205 |
|
211 | |||
206 | $ echo "include:nested/ignore" >> otherignore |
|
212 | $ echo "include:nested/ignore" >> otherignore | |
207 | $ mkdir nested |
|
213 | $ mkdir nested | |
208 | $ echo "glob:*ignore" > nested/ignore |
|
214 | $ echo "glob:*ignore" > nested/ignore | |
209 | $ hg status |
|
215 | $ hg status | |
210 | A dir/b.o |
|
216 | A dir/b.o | |
211 |
|
217 | |||
212 | $ cp otherignore goodignore |
|
218 | $ cp otherignore goodignore | |
213 | $ echo "include:badignore" >> otherignore |
|
219 | $ echo "include:badignore" >> otherignore | |
214 | $ hg status |
|
220 | $ hg status | |
215 | skipping unreadable pattern file 'badignore': No such file or directory |
|
221 | skipping unreadable pattern file 'badignore': No such file or directory | |
216 | A dir/b.o |
|
222 | A dir/b.o | |
217 |
|
223 | |||
218 | $ mv goodignore otherignore |
|
224 | $ mv goodignore otherignore | |
219 |
|
225 | |||
220 | Check using 'include:' while in a non-root directory |
|
226 | Check using 'include:' while in a non-root directory | |
221 |
|
227 | |||
222 | $ cd .. |
|
228 | $ cd .. | |
223 | $ hg -R ignorerepo status |
|
229 | $ hg -R ignorerepo status | |
224 | A dir/b.o |
|
230 | A dir/b.o | |
225 | $ cd ignorerepo |
|
231 | $ cd ignorerepo | |
226 |
|
232 | |||
227 | Check including subincludes |
|
233 | Check including subincludes | |
228 |
|
234 | |||
229 | $ hg revert -q --all |
|
235 | $ hg revert -q --all | |
230 | $ hg purge --all --config extensions.purge= |
|
236 | $ hg purge --all --config extensions.purge= | |
231 | $ echo ".hgignore" > .hgignore |
|
237 | $ echo ".hgignore" > .hgignore | |
232 | $ mkdir dir1 dir2 |
|
238 | $ mkdir dir1 dir2 | |
233 | $ touch dir1/file1 dir1/file2 dir2/file1 dir2/file2 |
|
239 | $ touch dir1/file1 dir1/file2 dir2/file1 dir2/file2 | |
234 | $ echo "subinclude:dir2/.hgignore" >> .hgignore |
|
240 | $ echo "subinclude:dir2/.hgignore" >> .hgignore | |
235 | $ echo "glob:file*2" > dir2/.hgignore |
|
241 | $ echo "glob:file*2" > dir2/.hgignore | |
236 | $ hg status |
|
242 | $ hg status | |
237 | ? dir1/file1 |
|
243 | ? dir1/file1 | |
238 | ? dir1/file2 |
|
244 | ? dir1/file2 | |
239 | ? dir2/file1 |
|
245 | ? dir2/file1 | |
240 |
|
246 | |||
241 | Check including subincludes with regexs |
|
247 | Check including subincludes with regexs | |
242 |
|
248 | |||
243 | $ echo "subinclude:dir1/.hgignore" >> .hgignore |
|
249 | $ echo "subinclude:dir1/.hgignore" >> .hgignore | |
244 | $ echo "regexp:f.le1" > dir1/.hgignore |
|
250 | $ echo "regexp:f.le1" > dir1/.hgignore | |
245 |
|
251 | |||
246 | $ hg status |
|
252 | $ hg status | |
247 | ? dir1/file2 |
|
253 | ? dir1/file2 | |
248 | ? dir2/file1 |
|
254 | ? dir2/file1 | |
249 |
|
255 | |||
250 | Check multiple levels of sub-ignores |
|
256 | Check multiple levels of sub-ignores | |
251 |
|
257 | |||
252 | $ mkdir dir1/subdir |
|
258 | $ mkdir dir1/subdir | |
253 | $ touch dir1/subdir/subfile1 dir1/subdir/subfile3 dir1/subdir/subfile4 |
|
259 | $ touch dir1/subdir/subfile1 dir1/subdir/subfile3 dir1/subdir/subfile4 | |
254 | $ echo "subinclude:subdir/.hgignore" >> dir1/.hgignore |
|
260 | $ echo "subinclude:subdir/.hgignore" >> dir1/.hgignore | |
255 | $ echo "glob:subfil*3" >> dir1/subdir/.hgignore |
|
261 | $ echo "glob:subfil*3" >> dir1/subdir/.hgignore | |
256 |
|
262 | |||
257 | $ hg status |
|
263 | $ hg status | |
258 | ? dir1/file2 |
|
264 | ? dir1/file2 | |
259 | ? dir1/subdir/subfile4 |
|
265 | ? dir1/subdir/subfile4 | |
260 | ? dir2/file1 |
|
266 | ? dir2/file1 | |
261 |
|
267 | |||
262 | Check include subignore at the same level |
|
268 | Check include subignore at the same level | |
263 |
|
269 | |||
264 | $ mv dir1/subdir/.hgignore dir1/.hgignoretwo |
|
270 | $ mv dir1/subdir/.hgignore dir1/.hgignoretwo | |
265 | $ echo "regexp:f.le1" > dir1/.hgignore |
|
271 | $ echo "regexp:f.le1" > dir1/.hgignore | |
266 | $ echo "subinclude:.hgignoretwo" >> dir1/.hgignore |
|
272 | $ echo "subinclude:.hgignoretwo" >> dir1/.hgignore | |
267 | $ echo "glob:file*2" > dir1/.hgignoretwo |
|
273 | $ echo "glob:file*2" > dir1/.hgignoretwo | |
268 |
|
274 | |||
269 | $ hg status | grep file2 |
|
275 | $ hg status | grep file2 | |
270 | [1] |
|
276 | [1] |
General Comments 0
You need to be logged in to leave comments.
Login now