##// END OF EJS Templates
test-hgignore.t: add tests for comments...
Bryan O'Sullivan -
r27326:ee2d7b5d default
parent child Browse files
Show More
@@ -1,253 +1,270 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:
59
60 $ touch 'foo#bar' 'quux#' 'baz\#wat'
61 $ cat <<'EOF' >> .hgignore
62 > # full-line comment
63 > # whitespace-only comment line
64 > syntax# pattern, no whitespace, then comment
65 > a.c # pattern, then whitespace, then comment
66 > baz\\# # escaped comment character
67 > foo\#b # escaped comment character
68 > quux\## escaped comment character at end of name
69 > EOF
70 $ hg status
71 A dir/b.o
72 ? .hgignore
73 $ rm 'foo#bar' 'quux#' 'baz\#wat'
74
58 Check it does not ignore the current directory '.':
75 Check it does not ignore the current directory '.':
59
76
60 $ echo "^\." > .hgignore
77 $ echo "^\." > .hgignore
61 $ hg status
78 $ hg status
62 A dir/b.o
79 A dir/b.o
63 ? a.c
80 ? a.c
64 ? a.o
81 ? a.o
65 ? dir/c.o
82 ? dir/c.o
66 ? syntax
83 ? syntax
67
84
68 Test that patterns from ui.ignore options are read:
85 Test that patterns from ui.ignore options are read:
69
86
70 $ echo > .hgignore
87 $ echo > .hgignore
71 $ cat >> $HGRCPATH << EOF
88 $ cat >> $HGRCPATH << EOF
72 > [ui]
89 > [ui]
73 > ignore.other = $TESTTMP/ignorerepo/.hg/testhgignore
90 > ignore.other = $TESTTMP/ignorerepo/.hg/testhgignore
74 > EOF
91 > EOF
75 $ echo "glob:**.o" > .hg/testhgignore
92 $ echo "glob:**.o" > .hg/testhgignore
76 $ hg status
93 $ hg status
77 A dir/b.o
94 A dir/b.o
78 ? .hgignore
95 ? .hgignore
79 ? a.c
96 ? a.c
80 ? syntax
97 ? syntax
81
98
82 empty out testhgignore
99 empty out testhgignore
83 $ echo > .hg/testhgignore
100 $ echo > .hg/testhgignore
84
101
85 Test relative ignore path (issue4473):
102 Test relative ignore path (issue4473):
86
103
87 $ cat >> $HGRCPATH << EOF
104 $ cat >> $HGRCPATH << EOF
88 > [ui]
105 > [ui]
89 > ignore.relative = .hg/testhgignorerel
106 > ignore.relative = .hg/testhgignorerel
90 > EOF
107 > EOF
91 $ echo "glob:*.o" > .hg/testhgignorerel
108 $ echo "glob:*.o" > .hg/testhgignorerel
92 $ cd dir
109 $ cd dir
93 $ hg status
110 $ hg status
94 A dir/b.o
111 A dir/b.o
95 ? .hgignore
112 ? .hgignore
96 ? a.c
113 ? a.c
97 ? syntax
114 ? syntax
98
115
99 $ cd ..
116 $ cd ..
100 $ echo > .hg/testhgignorerel
117 $ echo > .hg/testhgignorerel
101 $ echo "syntax: glob" > .hgignore
118 $ echo "syntax: glob" > .hgignore
102 $ echo "re:.*\.o" >> .hgignore
119 $ echo "re:.*\.o" >> .hgignore
103 $ hg status
120 $ hg status
104 A dir/b.o
121 A dir/b.o
105 ? .hgignore
122 ? .hgignore
106 ? a.c
123 ? a.c
107 ? syntax
124 ? syntax
108
125
109 $ echo "syntax: invalid" > .hgignore
126 $ echo "syntax: invalid" > .hgignore
110 $ hg status
127 $ hg status
111 $TESTTMP/ignorerepo/.hgignore: ignoring invalid syntax 'invalid' (glob)
128 $TESTTMP/ignorerepo/.hgignore: ignoring invalid syntax 'invalid' (glob)
112 A dir/b.o
129 A dir/b.o
113 ? .hgignore
130 ? .hgignore
114 ? a.c
131 ? a.c
115 ? a.o
132 ? a.o
116 ? dir/c.o
133 ? dir/c.o
117 ? syntax
134 ? syntax
118
135
119 $ echo "syntax: glob" > .hgignore
136 $ echo "syntax: glob" > .hgignore
120 $ echo "*.o" >> .hgignore
137 $ echo "*.o" >> .hgignore
121 $ hg status
138 $ hg status
122 A dir/b.o
139 A dir/b.o
123 ? .hgignore
140 ? .hgignore
124 ? a.c
141 ? a.c
125 ? syntax
142 ? syntax
126
143
127 $ echo "relglob:syntax*" > .hgignore
144 $ echo "relglob:syntax*" > .hgignore
128 $ hg status
145 $ hg status
129 A dir/b.o
146 A dir/b.o
130 ? .hgignore
147 ? .hgignore
131 ? a.c
148 ? a.c
132 ? a.o
149 ? a.o
133 ? dir/c.o
150 ? dir/c.o
134
151
135 $ echo "relglob:*" > .hgignore
152 $ echo "relglob:*" > .hgignore
136 $ hg status
153 $ hg status
137 A dir/b.o
154 A dir/b.o
138
155
139 $ cd dir
156 $ cd dir
140 $ hg status .
157 $ hg status .
141 A b.o
158 A b.o
142
159
143 $ hg debugignore
160 $ hg debugignore
144 (?:(?:|.*/)[^/]*(?:/|$))
161 (?:(?:|.*/)[^/]*(?:/|$))
145
162
146 $ cd ..
163 $ cd ..
147
164
148 Check patterns that match only the directory
165 Check patterns that match only the directory
149
166
150 $ echo "^dir\$" > .hgignore
167 $ echo "^dir\$" > .hgignore
151 $ hg status
168 $ hg status
152 A dir/b.o
169 A dir/b.o
153 ? .hgignore
170 ? .hgignore
154 ? a.c
171 ? a.c
155 ? a.o
172 ? a.o
156 ? syntax
173 ? syntax
157
174
158 Check recursive glob pattern matches no directories (dir/**/c.o matches dir/c.o)
175 Check recursive glob pattern matches no directories (dir/**/c.o matches dir/c.o)
159
176
160 $ echo "syntax: glob" > .hgignore
177 $ echo "syntax: glob" > .hgignore
161 $ echo "dir/**/c.o" >> .hgignore
178 $ echo "dir/**/c.o" >> .hgignore
162 $ touch dir/c.o
179 $ touch dir/c.o
163 $ mkdir dir/subdir
180 $ mkdir dir/subdir
164 $ touch dir/subdir/c.o
181 $ touch dir/subdir/c.o
165 $ hg status
182 $ hg status
166 A dir/b.o
183 A dir/b.o
167 ? .hgignore
184 ? .hgignore
168 ? a.c
185 ? a.c
169 ? a.o
186 ? a.o
170 ? syntax
187 ? syntax
171
188
172 Check using 'include:' in ignore file
189 Check using 'include:' in ignore file
173
190
174 $ hg purge --all --config extensions.purge=
191 $ hg purge --all --config extensions.purge=
175 $ touch foo.included
192 $ touch foo.included
176
193
177 $ echo ".*.included" > otherignore
194 $ echo ".*.included" > otherignore
178 $ hg status -I "include:otherignore"
195 $ hg status -I "include:otherignore"
179 ? foo.included
196 ? foo.included
180
197
181 $ echo "include:otherignore" >> .hgignore
198 $ echo "include:otherignore" >> .hgignore
182 $ hg status
199 $ hg status
183 A dir/b.o
200 A dir/b.o
184 ? .hgignore
201 ? .hgignore
185 ? otherignore
202 ? otherignore
186
203
187 Check recursive uses of 'include:'
204 Check recursive uses of 'include:'
188
205
189 $ echo "include:nested/ignore" >> otherignore
206 $ echo "include:nested/ignore" >> otherignore
190 $ mkdir nested
207 $ mkdir nested
191 $ echo "glob:*ignore" > nested/ignore
208 $ echo "glob:*ignore" > nested/ignore
192 $ hg status
209 $ hg status
193 A dir/b.o
210 A dir/b.o
194
211
195 $ cp otherignore goodignore
212 $ cp otherignore goodignore
196 $ echo "include:badignore" >> otherignore
213 $ echo "include:badignore" >> otherignore
197 $ hg status
214 $ hg status
198 skipping unreadable pattern file 'badignore': No such file or directory
215 skipping unreadable pattern file 'badignore': No such file or directory
199 A dir/b.o
216 A dir/b.o
200
217
201 $ mv goodignore otherignore
218 $ mv goodignore otherignore
202
219
203 Check using 'include:' while in a non-root directory
220 Check using 'include:' while in a non-root directory
204
221
205 $ cd ..
222 $ cd ..
206 $ hg -R ignorerepo status
223 $ hg -R ignorerepo status
207 A dir/b.o
224 A dir/b.o
208 $ cd ignorerepo
225 $ cd ignorerepo
209
226
210 Check including subincludes
227 Check including subincludes
211
228
212 $ hg revert -q --all
229 $ hg revert -q --all
213 $ hg purge --all --config extensions.purge=
230 $ hg purge --all --config extensions.purge=
214 $ echo ".hgignore" > .hgignore
231 $ echo ".hgignore" > .hgignore
215 $ mkdir dir1 dir2
232 $ mkdir dir1 dir2
216 $ touch dir1/file1 dir1/file2 dir2/file1 dir2/file2
233 $ touch dir1/file1 dir1/file2 dir2/file1 dir2/file2
217 $ echo "subinclude:dir2/.hgignore" >> .hgignore
234 $ echo "subinclude:dir2/.hgignore" >> .hgignore
218 $ echo "glob:file*2" > dir2/.hgignore
235 $ echo "glob:file*2" > dir2/.hgignore
219 $ hg status
236 $ hg status
220 ? dir1/file1
237 ? dir1/file1
221 ? dir1/file2
238 ? dir1/file2
222 ? dir2/file1
239 ? dir2/file1
223
240
224 Check including subincludes with regexs
241 Check including subincludes with regexs
225
242
226 $ echo "subinclude:dir1/.hgignore" >> .hgignore
243 $ echo "subinclude:dir1/.hgignore" >> .hgignore
227 $ echo "regexp:f.le1" > dir1/.hgignore
244 $ echo "regexp:f.le1" > dir1/.hgignore
228
245
229 $ hg status
246 $ hg status
230 ? dir1/file2
247 ? dir1/file2
231 ? dir2/file1
248 ? dir2/file1
232
249
233 Check multiple levels of sub-ignores
250 Check multiple levels of sub-ignores
234
251
235 $ mkdir dir1/subdir
252 $ mkdir dir1/subdir
236 $ touch dir1/subdir/subfile1 dir1/subdir/subfile3 dir1/subdir/subfile4
253 $ touch dir1/subdir/subfile1 dir1/subdir/subfile3 dir1/subdir/subfile4
237 $ echo "subinclude:subdir/.hgignore" >> dir1/.hgignore
254 $ echo "subinclude:subdir/.hgignore" >> dir1/.hgignore
238 $ echo "glob:subfil*3" >> dir1/subdir/.hgignore
255 $ echo "glob:subfil*3" >> dir1/subdir/.hgignore
239
256
240 $ hg status
257 $ hg status
241 ? dir1/file2
258 ? dir1/file2
242 ? dir1/subdir/subfile4
259 ? dir1/subdir/subfile4
243 ? dir2/file1
260 ? dir2/file1
244
261
245 Check include subignore at the same level
262 Check include subignore at the same level
246
263
247 $ mv dir1/subdir/.hgignore dir1/.hgignoretwo
264 $ mv dir1/subdir/.hgignore dir1/.hgignoretwo
248 $ echo "regexp:f.le1" > dir1/.hgignore
265 $ echo "regexp:f.le1" > dir1/.hgignore
249 $ echo "subinclude:.hgignoretwo" >> dir1/.hgignore
266 $ echo "subinclude:.hgignoretwo" >> dir1/.hgignore
250 $ echo "glob:file*2" > dir1/.hgignoretwo
267 $ echo "glob:file*2" > dir1/.hgignoretwo
251
268
252 $ hg status | grep file2
269 $ hg status | grep file2
253 [1]
270 [1]
General Comments 0
You need to be logged in to leave comments. Login now