##// END OF EJS Templates
hgignore: add a few more weird patterns to test case
Yuya Nishihara -
r42855:c67e3f96 default
parent child Browse files
Show More
@@ -1,363 +1,365 b''
1 $ hg init ignorerepo
1 $ hg init ignorerepo
2 $ cd ignorerepo
2 $ cd ignorerepo
3
3
4 debugignore with no hgignore should be deterministic:
4 debugignore with no hgignore should be deterministic:
5 $ hg debugignore
5 $ hg debugignore
6 <nevermatcher>
6 <nevermatcher>
7
7
8 Issue562: .hgignore requires newline at end:
8 Issue562: .hgignore requires newline at end:
9
9
10 $ touch foo
10 $ touch foo
11 $ touch bar
11 $ touch bar
12 $ touch baz
12 $ touch baz
13 $ cat > makeignore.py <<EOF
13 $ cat > makeignore.py <<EOF
14 > f = open(".hgignore", "w")
14 > f = open(".hgignore", "w")
15 > f.write("ignore\n")
15 > f.write("ignore\n")
16 > f.write("foo\n")
16 > f.write("foo\n")
17 > # No EOL here
17 > # No EOL here
18 > f.write("bar")
18 > f.write("bar")
19 > f.close()
19 > f.close()
20 > EOF
20 > EOF
21
21
22 $ "$PYTHON" makeignore.py
22 $ "$PYTHON" makeignore.py
23
23
24 Should display baz only:
24 Should display baz only:
25
25
26 $ hg status
26 $ hg status
27 ? baz
27 ? baz
28
28
29 $ rm foo bar baz .hgignore makeignore.py
29 $ rm foo bar baz .hgignore makeignore.py
30
30
31 $ touch a.o
31 $ touch a.o
32 $ touch a.c
32 $ touch a.c
33 $ touch syntax
33 $ touch syntax
34 $ mkdir dir
34 $ mkdir dir
35 $ touch dir/a.o
35 $ touch dir/a.o
36 $ touch dir/b.o
36 $ touch dir/b.o
37 $ touch dir/c.o
37 $ touch dir/c.o
38
38
39 $ hg add dir/a.o
39 $ hg add dir/a.o
40 $ hg commit -m 0
40 $ hg commit -m 0
41 $ hg add dir/b.o
41 $ hg add dir/b.o
42
42
43 $ hg status
43 $ hg status
44 A dir/b.o
44 A dir/b.o
45 ? a.c
45 ? a.c
46 ? a.o
46 ? a.o
47 ? dir/c.o
47 ? dir/c.o
48 ? syntax
48 ? syntax
49
49
50 $ echo "*.o" > .hgignore
50 $ echo "*.o" > .hgignore
51 $ hg status
51 $ hg status
52 abort: $TESTTMP/ignorerepo/.hgignore: invalid pattern (relre): *.o (glob)
52 abort: $TESTTMP/ignorerepo/.hgignore: invalid pattern (relre): *.o (glob)
53 [255]
53 [255]
54
54
55 Ensure given files are relative to cwd
55 Ensure given files are relative to cwd
56
56
57 $ echo "dir/.*\.o" > .hgignore
57 $ echo "dir/.*\.o" > .hgignore
58 $ hg status -i
58 $ hg status -i
59 I dir/c.o
59 I dir/c.o
60
60
61 $ hg debugignore dir/c.o dir/missing.o
61 $ hg debugignore dir/c.o dir/missing.o
62 dir/c.o is ignored
62 dir/c.o is ignored
63 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: 'dir/.*\.o') (glob)
63 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: 'dir/.*\.o') (glob)
64 dir/missing.o is ignored
64 dir/missing.o is ignored
65 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: 'dir/.*\.o') (glob)
65 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: 'dir/.*\.o') (glob)
66 $ cd dir
66 $ cd dir
67 $ hg debugignore c.o missing.o
67 $ hg debugignore c.o missing.o
68 c.o is ignored
68 c.o is ignored
69 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: 'dir/.*\.o') (glob)
69 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: 'dir/.*\.o') (glob)
70 missing.o is ignored
70 missing.o is ignored
71 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: 'dir/.*\.o') (glob)
71 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: 'dir/.*\.o') (glob)
72
72
73 For icasefs, inexact matches also work, except for missing files
73 For icasefs, inexact matches also work, except for missing files
74
74
75 #if icasefs
75 #if icasefs
76 $ hg debugignore c.O missing.O
76 $ hg debugignore c.O missing.O
77 c.o is ignored
77 c.o is ignored
78 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: 'dir/.*\.o') (glob)
78 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: 'dir/.*\.o') (glob)
79 missing.O is not ignored
79 missing.O is not ignored
80 #endif
80 #endif
81
81
82 $ cd ..
82 $ cd ..
83
83
84 $ echo ".*\.o" > .hgignore
84 $ echo ".*\.o" > .hgignore
85 $ hg status
85 $ hg status
86 A dir/b.o
86 A dir/b.o
87 ? .hgignore
87 ? .hgignore
88 ? a.c
88 ? a.c
89 ? syntax
89 ? syntax
90
90
91 Ensure that comments work:
91 Ensure that comments work:
92
92
93 $ touch 'foo#bar' 'quux#'
93 $ touch 'foo#bar' 'quux#'
94 #if no-windows
94 #if no-windows
95 $ touch 'baz\wat'
95 $ touch 'baz\wat' 'ba0\#wat' 'ba1\\wat'
96 #endif
96 #endif
97 $ cat <<'EOF' >> .hgignore
97 $ cat <<'EOF' >> .hgignore
98 > # full-line comment
98 > # full-line comment
99 > # whitespace-only comment line
99 > # whitespace-only comment line
100 > syntax# pattern, no whitespace, then comment
100 > syntax# pattern, no whitespace, then comment
101 > a.c # pattern, then whitespace, then comment
101 > a.c # pattern, then whitespace, then comment
102 > baz\\# # (escaped) backslash, then comment
102 > baz\\# # (escaped) backslash, then comment
103 > ba0\\\#w # (escaped) backslash, escaped comment character, then comment
104 > ba1\\\\# # (escaped) backslashes, then comment
103 > foo\#b # escaped comment character
105 > foo\#b # escaped comment character
104 > quux\## escaped comment character at end of name
106 > quux\## escaped comment character at end of name
105 > EOF
107 > EOF
106 $ hg status
108 $ hg status
107 A dir/b.o
109 A dir/b.o
108 ? .hgignore
110 ? .hgignore
109 $ rm 'foo#bar' 'quux#'
111 $ rm 'foo#bar' 'quux#'
110 #if no-windows
112 #if no-windows
111 $ rm 'baz\wat'
113 $ rm 'baz\wat' 'ba0\#wat' 'ba1\\wat'
112 #endif
114 #endif
113
115
114 Check that '^\.' does not ignore the root directory:
116 Check that '^\.' does not ignore the root directory:
115
117
116 $ echo "^\." > .hgignore
118 $ echo "^\." > .hgignore
117 $ hg status
119 $ hg status
118 A dir/b.o
120 A dir/b.o
119 ? a.c
121 ? a.c
120 ? a.o
122 ? a.o
121 ? dir/c.o
123 ? dir/c.o
122 ? syntax
124 ? syntax
123
125
124 Test that patterns from ui.ignore options are read:
126 Test that patterns from ui.ignore options are read:
125
127
126 $ echo > .hgignore
128 $ echo > .hgignore
127 $ cat >> $HGRCPATH << EOF
129 $ cat >> $HGRCPATH << EOF
128 > [ui]
130 > [ui]
129 > ignore.other = $TESTTMP/ignorerepo/.hg/testhgignore
131 > ignore.other = $TESTTMP/ignorerepo/.hg/testhgignore
130 > EOF
132 > EOF
131 $ echo "glob:**.o" > .hg/testhgignore
133 $ echo "glob:**.o" > .hg/testhgignore
132 $ hg status
134 $ hg status
133 A dir/b.o
135 A dir/b.o
134 ? .hgignore
136 ? .hgignore
135 ? a.c
137 ? a.c
136 ? syntax
138 ? syntax
137
139
138 empty out testhgignore
140 empty out testhgignore
139 $ echo > .hg/testhgignore
141 $ echo > .hg/testhgignore
140
142
141 Test relative ignore path (issue4473):
143 Test relative ignore path (issue4473):
142
144
143 $ cat >> $HGRCPATH << EOF
145 $ cat >> $HGRCPATH << EOF
144 > [ui]
146 > [ui]
145 > ignore.relative = .hg/testhgignorerel
147 > ignore.relative = .hg/testhgignorerel
146 > EOF
148 > EOF
147 $ echo "glob:*.o" > .hg/testhgignorerel
149 $ echo "glob:*.o" > .hg/testhgignorerel
148 $ cd dir
150 $ cd dir
149 $ hg status
151 $ hg status
150 A dir/b.o
152 A dir/b.o
151 ? .hgignore
153 ? .hgignore
152 ? a.c
154 ? a.c
153 ? syntax
155 ? syntax
154
156
155 $ cd ..
157 $ cd ..
156 $ echo > .hg/testhgignorerel
158 $ echo > .hg/testhgignorerel
157 $ echo "syntax: glob" > .hgignore
159 $ echo "syntax: glob" > .hgignore
158 $ echo "re:.*\.o" >> .hgignore
160 $ echo "re:.*\.o" >> .hgignore
159 $ hg status
161 $ hg status
160 A dir/b.o
162 A dir/b.o
161 ? .hgignore
163 ? .hgignore
162 ? a.c
164 ? a.c
163 ? syntax
165 ? syntax
164
166
165 $ echo "syntax: invalid" > .hgignore
167 $ echo "syntax: invalid" > .hgignore
166 $ hg status
168 $ hg status
167 $TESTTMP/ignorerepo/.hgignore: ignoring invalid syntax 'invalid'
169 $TESTTMP/ignorerepo/.hgignore: ignoring invalid syntax 'invalid'
168 A dir/b.o
170 A dir/b.o
169 ? .hgignore
171 ? .hgignore
170 ? a.c
172 ? a.c
171 ? a.o
173 ? a.o
172 ? dir/c.o
174 ? dir/c.o
173 ? syntax
175 ? syntax
174
176
175 $ echo "syntax: glob" > .hgignore
177 $ echo "syntax: glob" > .hgignore
176 $ echo "*.o" >> .hgignore
178 $ echo "*.o" >> .hgignore
177 $ hg status
179 $ hg status
178 A dir/b.o
180 A dir/b.o
179 ? .hgignore
181 ? .hgignore
180 ? a.c
182 ? a.c
181 ? syntax
183 ? syntax
182
184
183 $ echo "relglob:syntax*" > .hgignore
185 $ echo "relglob:syntax*" > .hgignore
184 $ hg status
186 $ hg status
185 A dir/b.o
187 A dir/b.o
186 ? .hgignore
188 ? .hgignore
187 ? a.c
189 ? a.c
188 ? a.o
190 ? a.o
189 ? dir/c.o
191 ? dir/c.o
190
192
191 $ echo "relglob:*" > .hgignore
193 $ echo "relglob:*" > .hgignore
192 $ hg status
194 $ hg status
193 A dir/b.o
195 A dir/b.o
194
196
195 $ cd dir
197 $ cd dir
196 $ hg status .
198 $ hg status .
197 A b.o
199 A b.o
198
200
199 $ hg debugignore
201 $ hg debugignore
200 <includematcher includes='(?:|.*/)[^/]*(?:/|$)'>
202 <includematcher includes='(?:|.*/)[^/]*(?:/|$)'>
201
203
202 $ hg debugignore b.o
204 $ hg debugignore b.o
203 b.o is ignored
205 b.o is ignored
204 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: '*') (glob)
206 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: '*') (glob)
205
207
206 $ cd ..
208 $ cd ..
207
209
208 Check patterns that match only the directory
210 Check patterns that match only the directory
209
211
210 "(fsmonitor !)" below assumes that fsmonitor is enabled with
212 "(fsmonitor !)" below assumes that fsmonitor is enabled with
211 "walk_on_invalidate = false" (default), which doesn't involve
213 "walk_on_invalidate = false" (default), which doesn't involve
212 re-walking whole repository at detection of .hgignore change.
214 re-walking whole repository at detection of .hgignore change.
213
215
214 $ echo "^dir\$" > .hgignore
216 $ echo "^dir\$" > .hgignore
215 $ hg status
217 $ hg status
216 A dir/b.o
218 A dir/b.o
217 ? .hgignore
219 ? .hgignore
218 ? a.c
220 ? a.c
219 ? a.o
221 ? a.o
220 ? dir/c.o (fsmonitor !)
222 ? dir/c.o (fsmonitor !)
221 ? syntax
223 ? syntax
222
224
223 Check recursive glob pattern matches no directories (dir/**/c.o matches dir/c.o)
225 Check recursive glob pattern matches no directories (dir/**/c.o matches dir/c.o)
224
226
225 $ echo "syntax: glob" > .hgignore
227 $ echo "syntax: glob" > .hgignore
226 $ echo "dir/**/c.o" >> .hgignore
228 $ echo "dir/**/c.o" >> .hgignore
227 $ touch dir/c.o
229 $ touch dir/c.o
228 $ mkdir dir/subdir
230 $ mkdir dir/subdir
229 $ touch dir/subdir/c.o
231 $ touch dir/subdir/c.o
230 $ hg status
232 $ hg status
231 A dir/b.o
233 A dir/b.o
232 ? .hgignore
234 ? .hgignore
233 ? a.c
235 ? a.c
234 ? a.o
236 ? a.o
235 ? syntax
237 ? syntax
236 $ hg debugignore a.c
238 $ hg debugignore a.c
237 a.c is not ignored
239 a.c is not ignored
238 $ hg debugignore dir/c.o
240 $ hg debugignore dir/c.o
239 dir/c.o is ignored
241 dir/c.o is ignored
240 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 2: 'dir/**/c.o') (glob)
242 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 2: 'dir/**/c.o') (glob)
241
243
242 Check rooted globs
244 Check rooted globs
243
245
244 $ hg purge --all --config extensions.purge=
246 $ hg purge --all --config extensions.purge=
245 $ echo "syntax: rootglob" > .hgignore
247 $ echo "syntax: rootglob" > .hgignore
246 $ echo "a/*.ext" >> .hgignore
248 $ echo "a/*.ext" >> .hgignore
247 $ for p in a b/a aa; do mkdir -p $p; touch $p/b.ext; done
249 $ for p in a b/a aa; do mkdir -p $p; touch $p/b.ext; done
248 $ hg status -A 'set:**.ext'
250 $ hg status -A 'set:**.ext'
249 ? aa/b.ext
251 ? aa/b.ext
250 ? b/a/b.ext
252 ? b/a/b.ext
251 I a/b.ext
253 I a/b.ext
252
254
253 Check using 'include:' in ignore file
255 Check using 'include:' in ignore file
254
256
255 $ hg purge --all --config extensions.purge=
257 $ hg purge --all --config extensions.purge=
256 $ touch foo.included
258 $ touch foo.included
257
259
258 $ echo ".*.included" > otherignore
260 $ echo ".*.included" > otherignore
259 $ hg status -I "include:otherignore"
261 $ hg status -I "include:otherignore"
260 ? foo.included
262 ? foo.included
261
263
262 $ echo "include:otherignore" >> .hgignore
264 $ echo "include:otherignore" >> .hgignore
263 $ hg status
265 $ hg status
264 A dir/b.o
266 A dir/b.o
265 ? .hgignore
267 ? .hgignore
266 ? otherignore
268 ? otherignore
267
269
268 Check recursive uses of 'include:'
270 Check recursive uses of 'include:'
269
271
270 $ echo "include:nested/ignore" >> otherignore
272 $ echo "include:nested/ignore" >> otherignore
271 $ mkdir nested nested/more
273 $ mkdir nested nested/more
272 $ echo "glob:*ignore" > nested/ignore
274 $ echo "glob:*ignore" > nested/ignore
273 $ echo "rootglob:a" >> nested/ignore
275 $ echo "rootglob:a" >> nested/ignore
274 $ touch a nested/a nested/more/a
276 $ touch a nested/a nested/more/a
275 $ hg status
277 $ hg status
276 A dir/b.o
278 A dir/b.o
277 ? nested/a
279 ? nested/a
278 ? nested/more/a
280 ? nested/more/a
279 $ rm a nested/a nested/more/a
281 $ rm a nested/a nested/more/a
280
282
281 $ cp otherignore goodignore
283 $ cp otherignore goodignore
282 $ echo "include:badignore" >> otherignore
284 $ echo "include:badignore" >> otherignore
283 $ hg status
285 $ hg status
284 skipping unreadable pattern file 'badignore': $ENOENT$
286 skipping unreadable pattern file 'badignore': $ENOENT$
285 A dir/b.o
287 A dir/b.o
286
288
287 $ mv goodignore otherignore
289 $ mv goodignore otherignore
288
290
289 Check using 'include:' while in a non-root directory
291 Check using 'include:' while in a non-root directory
290
292
291 $ cd ..
293 $ cd ..
292 $ hg -R ignorerepo status
294 $ hg -R ignorerepo status
293 A dir/b.o
295 A dir/b.o
294 $ cd ignorerepo
296 $ cd ignorerepo
295
297
296 Check including subincludes
298 Check including subincludes
297
299
298 $ hg revert -q --all
300 $ hg revert -q --all
299 $ hg purge --all --config extensions.purge=
301 $ hg purge --all --config extensions.purge=
300 $ echo ".hgignore" > .hgignore
302 $ echo ".hgignore" > .hgignore
301 $ mkdir dir1 dir2
303 $ mkdir dir1 dir2
302 $ touch dir1/file1 dir1/file2 dir2/file1 dir2/file2
304 $ touch dir1/file1 dir1/file2 dir2/file1 dir2/file2
303 $ echo "subinclude:dir2/.hgignore" >> .hgignore
305 $ echo "subinclude:dir2/.hgignore" >> .hgignore
304 $ echo "glob:file*2" > dir2/.hgignore
306 $ echo "glob:file*2" > dir2/.hgignore
305 $ hg status
307 $ hg status
306 ? dir1/file1
308 ? dir1/file1
307 ? dir1/file2
309 ? dir1/file2
308 ? dir2/file1
310 ? dir2/file1
309
311
310 Check including subincludes with other patterns
312 Check including subincludes with other patterns
311
313
312 $ echo "subinclude:dir1/.hgignore" >> .hgignore
314 $ echo "subinclude:dir1/.hgignore" >> .hgignore
313
315
314 $ mkdir dir1/subdir
316 $ mkdir dir1/subdir
315 $ touch dir1/subdir/file1
317 $ touch dir1/subdir/file1
316 $ echo "rootglob:f?le1" > dir1/.hgignore
318 $ echo "rootglob:f?le1" > dir1/.hgignore
317 $ hg status
319 $ hg status
318 ? dir1/file2
320 ? dir1/file2
319 ? dir1/subdir/file1
321 ? dir1/subdir/file1
320 ? dir2/file1
322 ? dir2/file1
321 $ rm dir1/subdir/file1
323 $ rm dir1/subdir/file1
322
324
323 $ echo "regexp:f.le1" > dir1/.hgignore
325 $ echo "regexp:f.le1" > dir1/.hgignore
324 $ hg status
326 $ hg status
325 ? dir1/file2
327 ? dir1/file2
326 ? dir2/file1
328 ? dir2/file1
327
329
328 Check multiple levels of sub-ignores
330 Check multiple levels of sub-ignores
329
331
330 $ touch dir1/subdir/subfile1 dir1/subdir/subfile3 dir1/subdir/subfile4
332 $ touch dir1/subdir/subfile1 dir1/subdir/subfile3 dir1/subdir/subfile4
331 $ echo "subinclude:subdir/.hgignore" >> dir1/.hgignore
333 $ echo "subinclude:subdir/.hgignore" >> dir1/.hgignore
332 $ echo "glob:subfil*3" >> dir1/subdir/.hgignore
334 $ echo "glob:subfil*3" >> dir1/subdir/.hgignore
333
335
334 $ hg status
336 $ hg status
335 ? dir1/file2
337 ? dir1/file2
336 ? dir1/subdir/subfile4
338 ? dir1/subdir/subfile4
337 ? dir2/file1
339 ? dir2/file1
338
340
339 Check include subignore at the same level
341 Check include subignore at the same level
340
342
341 $ mv dir1/subdir/.hgignore dir1/.hgignoretwo
343 $ mv dir1/subdir/.hgignore dir1/.hgignoretwo
342 $ echo "regexp:f.le1" > dir1/.hgignore
344 $ echo "regexp:f.le1" > dir1/.hgignore
343 $ echo "subinclude:.hgignoretwo" >> dir1/.hgignore
345 $ echo "subinclude:.hgignoretwo" >> dir1/.hgignore
344 $ echo "glob:file*2" > dir1/.hgignoretwo
346 $ echo "glob:file*2" > dir1/.hgignoretwo
345
347
346 $ hg status | grep file2
348 $ hg status | grep file2
347 [1]
349 [1]
348 $ hg debugignore dir1/file2
350 $ hg debugignore dir1/file2
349 dir1/file2 is ignored
351 dir1/file2 is ignored
350 (ignore rule in dir2/.hgignore, line 1: 'file*2')
352 (ignore rule in dir2/.hgignore, line 1: 'file*2')
351
353
352 #if windows
354 #if windows
353
355
354 Windows paths are accepted on input
356 Windows paths are accepted on input
355
357
356 $ rm dir1/.hgignore
358 $ rm dir1/.hgignore
357 $ echo "dir1/file*" >> .hgignore
359 $ echo "dir1/file*" >> .hgignore
358 $ hg debugignore "dir1\file2"
360 $ hg debugignore "dir1\file2"
359 dir1/file2 is ignored
361 dir1/file2 is ignored
360 (ignore rule in $TESTTMP\ignorerepo\.hgignore, line 4: 'dir1/file*')
362 (ignore rule in $TESTTMP\ignorerepo\.hgignore, line 4: 'dir1/file*')
361 $ hg up -qC .
363 $ hg up -qC .
362
364
363 #endif
365 #endif
General Comments 0
You need to be logged in to leave comments. Login now