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