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