##// END OF EJS Templates
hgignore: update \-escape test to reflect actual behavior...
Yuya Nishihara -
r42854:24f0023b default
parent child Browse files
Show More
@@ -1,363 +1,363
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'
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 comment character
102 > baz\\# # (escaped) backslash, then comment
103 > foo\#b # escaped comment character
103 > foo\#b # escaped comment character
104 > quux\## escaped comment character at end of name
104 > quux\## escaped comment character at end of name
105 > EOF
105 > EOF
106 $ hg status
106 $ hg status
107 A dir/b.o
107 A dir/b.o
108 ? .hgignore
108 ? .hgignore
109 $ rm 'foo#bar' 'quux#'
109 $ rm 'foo#bar' 'quux#'
110 #if no-windows
110 #if no-windows
111 $ rm 'baz\#wat'
111 $ rm 'baz\wat'
112 #endif
112 #endif
113
113
114 Check that '^\.' does not ignore the root directory:
114 Check that '^\.' does not ignore the root directory:
115
115
116 $ echo "^\." > .hgignore
116 $ echo "^\." > .hgignore
117 $ hg status
117 $ hg status
118 A dir/b.o
118 A dir/b.o
119 ? a.c
119 ? a.c
120 ? a.o
120 ? a.o
121 ? dir/c.o
121 ? dir/c.o
122 ? syntax
122 ? syntax
123
123
124 Test that patterns from ui.ignore options are read:
124 Test that patterns from ui.ignore options are read:
125
125
126 $ echo > .hgignore
126 $ echo > .hgignore
127 $ cat >> $HGRCPATH << EOF
127 $ cat >> $HGRCPATH << EOF
128 > [ui]
128 > [ui]
129 > ignore.other = $TESTTMP/ignorerepo/.hg/testhgignore
129 > ignore.other = $TESTTMP/ignorerepo/.hg/testhgignore
130 > EOF
130 > EOF
131 $ echo "glob:**.o" > .hg/testhgignore
131 $ echo "glob:**.o" > .hg/testhgignore
132 $ hg status
132 $ hg status
133 A dir/b.o
133 A dir/b.o
134 ? .hgignore
134 ? .hgignore
135 ? a.c
135 ? a.c
136 ? syntax
136 ? syntax
137
137
138 empty out testhgignore
138 empty out testhgignore
139 $ echo > .hg/testhgignore
139 $ echo > .hg/testhgignore
140
140
141 Test relative ignore path (issue4473):
141 Test relative ignore path (issue4473):
142
142
143 $ cat >> $HGRCPATH << EOF
143 $ cat >> $HGRCPATH << EOF
144 > [ui]
144 > [ui]
145 > ignore.relative = .hg/testhgignorerel
145 > ignore.relative = .hg/testhgignorerel
146 > EOF
146 > EOF
147 $ echo "glob:*.o" > .hg/testhgignorerel
147 $ echo "glob:*.o" > .hg/testhgignorerel
148 $ cd dir
148 $ cd dir
149 $ hg status
149 $ hg status
150 A dir/b.o
150 A dir/b.o
151 ? .hgignore
151 ? .hgignore
152 ? a.c
152 ? a.c
153 ? syntax
153 ? syntax
154
154
155 $ cd ..
155 $ cd ..
156 $ echo > .hg/testhgignorerel
156 $ echo > .hg/testhgignorerel
157 $ echo "syntax: glob" > .hgignore
157 $ echo "syntax: glob" > .hgignore
158 $ echo "re:.*\.o" >> .hgignore
158 $ echo "re:.*\.o" >> .hgignore
159 $ hg status
159 $ hg status
160 A dir/b.o
160 A dir/b.o
161 ? .hgignore
161 ? .hgignore
162 ? a.c
162 ? a.c
163 ? syntax
163 ? syntax
164
164
165 $ echo "syntax: invalid" > .hgignore
165 $ echo "syntax: invalid" > .hgignore
166 $ hg status
166 $ hg status
167 $TESTTMP/ignorerepo/.hgignore: ignoring invalid syntax 'invalid'
167 $TESTTMP/ignorerepo/.hgignore: ignoring invalid syntax 'invalid'
168 A dir/b.o
168 A dir/b.o
169 ? .hgignore
169 ? .hgignore
170 ? a.c
170 ? a.c
171 ? a.o
171 ? a.o
172 ? dir/c.o
172 ? dir/c.o
173 ? syntax
173 ? syntax
174
174
175 $ echo "syntax: glob" > .hgignore
175 $ echo "syntax: glob" > .hgignore
176 $ echo "*.o" >> .hgignore
176 $ echo "*.o" >> .hgignore
177 $ hg status
177 $ hg status
178 A dir/b.o
178 A dir/b.o
179 ? .hgignore
179 ? .hgignore
180 ? a.c
180 ? a.c
181 ? syntax
181 ? syntax
182
182
183 $ echo "relglob:syntax*" > .hgignore
183 $ echo "relglob:syntax*" > .hgignore
184 $ hg status
184 $ hg status
185 A dir/b.o
185 A dir/b.o
186 ? .hgignore
186 ? .hgignore
187 ? a.c
187 ? a.c
188 ? a.o
188 ? a.o
189 ? dir/c.o
189 ? dir/c.o
190
190
191 $ echo "relglob:*" > .hgignore
191 $ echo "relglob:*" > .hgignore
192 $ hg status
192 $ hg status
193 A dir/b.o
193 A dir/b.o
194
194
195 $ cd dir
195 $ cd dir
196 $ hg status .
196 $ hg status .
197 A b.o
197 A b.o
198
198
199 $ hg debugignore
199 $ hg debugignore
200 <includematcher includes='(?:|.*/)[^/]*(?:/|$)'>
200 <includematcher includes='(?:|.*/)[^/]*(?:/|$)'>
201
201
202 $ hg debugignore b.o
202 $ hg debugignore b.o
203 b.o is ignored
203 b.o is ignored
204 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: '*') (glob)
204 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 1: '*') (glob)
205
205
206 $ cd ..
206 $ cd ..
207
207
208 Check patterns that match only the directory
208 Check patterns that match only the directory
209
209
210 "(fsmonitor !)" below assumes that fsmonitor is enabled with
210 "(fsmonitor !)" below assumes that fsmonitor is enabled with
211 "walk_on_invalidate = false" (default), which doesn't involve
211 "walk_on_invalidate = false" (default), which doesn't involve
212 re-walking whole repository at detection of .hgignore change.
212 re-walking whole repository at detection of .hgignore change.
213
213
214 $ echo "^dir\$" > .hgignore
214 $ echo "^dir\$" > .hgignore
215 $ hg status
215 $ hg status
216 A dir/b.o
216 A dir/b.o
217 ? .hgignore
217 ? .hgignore
218 ? a.c
218 ? a.c
219 ? a.o
219 ? a.o
220 ? dir/c.o (fsmonitor !)
220 ? dir/c.o (fsmonitor !)
221 ? syntax
221 ? syntax
222
222
223 Check recursive glob pattern matches no directories (dir/**/c.o matches dir/c.o)
223 Check recursive glob pattern matches no directories (dir/**/c.o matches dir/c.o)
224
224
225 $ echo "syntax: glob" > .hgignore
225 $ echo "syntax: glob" > .hgignore
226 $ echo "dir/**/c.o" >> .hgignore
226 $ echo "dir/**/c.o" >> .hgignore
227 $ touch dir/c.o
227 $ touch dir/c.o
228 $ mkdir dir/subdir
228 $ mkdir dir/subdir
229 $ touch dir/subdir/c.o
229 $ touch dir/subdir/c.o
230 $ hg status
230 $ hg status
231 A dir/b.o
231 A dir/b.o
232 ? .hgignore
232 ? .hgignore
233 ? a.c
233 ? a.c
234 ? a.o
234 ? a.o
235 ? syntax
235 ? syntax
236 $ hg debugignore a.c
236 $ hg debugignore a.c
237 a.c is not ignored
237 a.c is not ignored
238 $ hg debugignore dir/c.o
238 $ hg debugignore dir/c.o
239 dir/c.o is ignored
239 dir/c.o is ignored
240 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 2: 'dir/**/c.o') (glob)
240 (ignore rule in $TESTTMP/ignorerepo/.hgignore, line 2: 'dir/**/c.o') (glob)
241
241
242 Check rooted globs
242 Check rooted globs
243
243
244 $ hg purge --all --config extensions.purge=
244 $ hg purge --all --config extensions.purge=
245 $ echo "syntax: rootglob" > .hgignore
245 $ echo "syntax: rootglob" > .hgignore
246 $ echo "a/*.ext" >> .hgignore
246 $ echo "a/*.ext" >> .hgignore
247 $ for p in a b/a aa; do mkdir -p $p; touch $p/b.ext; done
247 $ for p in a b/a aa; do mkdir -p $p; touch $p/b.ext; done
248 $ hg status -A 'set:**.ext'
248 $ hg status -A 'set:**.ext'
249 ? aa/b.ext
249 ? aa/b.ext
250 ? b/a/b.ext
250 ? b/a/b.ext
251 I a/b.ext
251 I a/b.ext
252
252
253 Check using 'include:' in ignore file
253 Check using 'include:' in ignore file
254
254
255 $ hg purge --all --config extensions.purge=
255 $ hg purge --all --config extensions.purge=
256 $ touch foo.included
256 $ touch foo.included
257
257
258 $ echo ".*.included" > otherignore
258 $ echo ".*.included" > otherignore
259 $ hg status -I "include:otherignore"
259 $ hg status -I "include:otherignore"
260 ? foo.included
260 ? foo.included
261
261
262 $ echo "include:otherignore" >> .hgignore
262 $ echo "include:otherignore" >> .hgignore
263 $ hg status
263 $ hg status
264 A dir/b.o
264 A dir/b.o
265 ? .hgignore
265 ? .hgignore
266 ? otherignore
266 ? otherignore
267
267
268 Check recursive uses of 'include:'
268 Check recursive uses of 'include:'
269
269
270 $ echo "include:nested/ignore" >> otherignore
270 $ echo "include:nested/ignore" >> otherignore
271 $ mkdir nested nested/more
271 $ mkdir nested nested/more
272 $ echo "glob:*ignore" > nested/ignore
272 $ echo "glob:*ignore" > nested/ignore
273 $ echo "rootglob:a" >> nested/ignore
273 $ echo "rootglob:a" >> nested/ignore
274 $ touch a nested/a nested/more/a
274 $ touch a nested/a nested/more/a
275 $ hg status
275 $ hg status
276 A dir/b.o
276 A dir/b.o
277 ? nested/a
277 ? nested/a
278 ? nested/more/a
278 ? nested/more/a
279 $ rm a nested/a nested/more/a
279 $ rm a nested/a nested/more/a
280
280
281 $ cp otherignore goodignore
281 $ cp otherignore goodignore
282 $ echo "include:badignore" >> otherignore
282 $ echo "include:badignore" >> otherignore
283 $ hg status
283 $ hg status
284 skipping unreadable pattern file 'badignore': $ENOENT$
284 skipping unreadable pattern file 'badignore': $ENOENT$
285 A dir/b.o
285 A dir/b.o
286
286
287 $ mv goodignore otherignore
287 $ mv goodignore otherignore
288
288
289 Check using 'include:' while in a non-root directory
289 Check using 'include:' while in a non-root directory
290
290
291 $ cd ..
291 $ cd ..
292 $ hg -R ignorerepo status
292 $ hg -R ignorerepo status
293 A dir/b.o
293 A dir/b.o
294 $ cd ignorerepo
294 $ cd ignorerepo
295
295
296 Check including subincludes
296 Check including subincludes
297
297
298 $ hg revert -q --all
298 $ hg revert -q --all
299 $ hg purge --all --config extensions.purge=
299 $ hg purge --all --config extensions.purge=
300 $ echo ".hgignore" > .hgignore
300 $ echo ".hgignore" > .hgignore
301 $ mkdir dir1 dir2
301 $ mkdir dir1 dir2
302 $ touch dir1/file1 dir1/file2 dir2/file1 dir2/file2
302 $ touch dir1/file1 dir1/file2 dir2/file1 dir2/file2
303 $ echo "subinclude:dir2/.hgignore" >> .hgignore
303 $ echo "subinclude:dir2/.hgignore" >> .hgignore
304 $ echo "glob:file*2" > dir2/.hgignore
304 $ echo "glob:file*2" > dir2/.hgignore
305 $ hg status
305 $ hg status
306 ? dir1/file1
306 ? dir1/file1
307 ? dir1/file2
307 ? dir1/file2
308 ? dir2/file1
308 ? dir2/file1
309
309
310 Check including subincludes with other patterns
310 Check including subincludes with other patterns
311
311
312 $ echo "subinclude:dir1/.hgignore" >> .hgignore
312 $ echo "subinclude:dir1/.hgignore" >> .hgignore
313
313
314 $ mkdir dir1/subdir
314 $ mkdir dir1/subdir
315 $ touch dir1/subdir/file1
315 $ touch dir1/subdir/file1
316 $ echo "rootglob:f?le1" > dir1/.hgignore
316 $ echo "rootglob:f?le1" > dir1/.hgignore
317 $ hg status
317 $ hg status
318 ? dir1/file2
318 ? dir1/file2
319 ? dir1/subdir/file1
319 ? dir1/subdir/file1
320 ? dir2/file1
320 ? dir2/file1
321 $ rm dir1/subdir/file1
321 $ rm dir1/subdir/file1
322
322
323 $ echo "regexp:f.le1" > dir1/.hgignore
323 $ echo "regexp:f.le1" > dir1/.hgignore
324 $ hg status
324 $ hg status
325 ? dir1/file2
325 ? dir1/file2
326 ? dir2/file1
326 ? dir2/file1
327
327
328 Check multiple levels of sub-ignores
328 Check multiple levels of sub-ignores
329
329
330 $ touch dir1/subdir/subfile1 dir1/subdir/subfile3 dir1/subdir/subfile4
330 $ touch dir1/subdir/subfile1 dir1/subdir/subfile3 dir1/subdir/subfile4
331 $ echo "subinclude:subdir/.hgignore" >> dir1/.hgignore
331 $ echo "subinclude:subdir/.hgignore" >> dir1/.hgignore
332 $ echo "glob:subfil*3" >> dir1/subdir/.hgignore
332 $ echo "glob:subfil*3" >> dir1/subdir/.hgignore
333
333
334 $ hg status
334 $ hg status
335 ? dir1/file2
335 ? dir1/file2
336 ? dir1/subdir/subfile4
336 ? dir1/subdir/subfile4
337 ? dir2/file1
337 ? dir2/file1
338
338
339 Check include subignore at the same level
339 Check include subignore at the same level
340
340
341 $ mv dir1/subdir/.hgignore dir1/.hgignoretwo
341 $ mv dir1/subdir/.hgignore dir1/.hgignoretwo
342 $ echo "regexp:f.le1" > dir1/.hgignore
342 $ echo "regexp:f.le1" > dir1/.hgignore
343 $ echo "subinclude:.hgignoretwo" >> dir1/.hgignore
343 $ echo "subinclude:.hgignoretwo" >> dir1/.hgignore
344 $ echo "glob:file*2" > dir1/.hgignoretwo
344 $ echo "glob:file*2" > dir1/.hgignoretwo
345
345
346 $ hg status | grep file2
346 $ hg status | grep file2
347 [1]
347 [1]
348 $ hg debugignore dir1/file2
348 $ hg debugignore dir1/file2
349 dir1/file2 is ignored
349 dir1/file2 is ignored
350 (ignore rule in dir2/.hgignore, line 1: 'file*2')
350 (ignore rule in dir2/.hgignore, line 1: 'file*2')
351
351
352 #if windows
352 #if windows
353
353
354 Windows paths are accepted on input
354 Windows paths are accepted on input
355
355
356 $ rm dir1/.hgignore
356 $ rm dir1/.hgignore
357 $ echo "dir1/file*" >> .hgignore
357 $ echo "dir1/file*" >> .hgignore
358 $ hg debugignore "dir1\file2"
358 $ hg debugignore "dir1\file2"
359 dir1/file2 is ignored
359 dir1/file2 is ignored
360 (ignore rule in $TESTTMP\ignorerepo\.hgignore, line 4: 'dir1/file*')
360 (ignore rule in $TESTTMP\ignorerepo\.hgignore, line 4: 'dir1/file*')
361 $ hg up -qC .
361 $ hg up -qC .
362
362
363 #endif
363 #endif
General Comments 0
You need to be logged in to leave comments. Login now