##// END OF EJS Templates
remove: add progress support
timeless -
r28608:62e73d42 default
parent child Browse files
Show More
@@ -2418,7 +2418,10 b' def remove(ui, repo, m, prefix, after, f'
2418 else:
2418 else:
2419 warn = False
2419 warn = False
2420
2420
2421 for subpath in sorted(wctx.substate):
2421 subs = sorted(wctx.substate)
2422 total = len(subs)
2423 count = 0
2424 for subpath in subs:
2422 def matchessubrepo(matcher, subpath):
2425 def matchessubrepo(matcher, subpath):
2423 if matcher.exact(subpath):
2426 if matcher.exact(subpath):
2424 return True
2427 return True
@@ -2427,7 +2430,10 b' def remove(ui, repo, m, prefix, after, f'
2427 return True
2430 return True
2428 return False
2431 return False
2429
2432
2433 count += 1
2430 if subrepos or matchessubrepo(m, subpath):
2434 if subrepos or matchessubrepo(m, subpath):
2435 ui.progress(_('searching'), count, total=total, unit=_('subrepos'))
2436
2431 sub = wctx.sub(subpath)
2437 sub = wctx.sub(subpath)
2432 try:
2438 try:
2433 submatch = matchmod.subdirmatcher(subpath, m)
2439 submatch = matchmod.subdirmatcher(subpath, m)
@@ -2437,16 +2443,22 b' def remove(ui, repo, m, prefix, after, f'
2437 except error.LookupError:
2443 except error.LookupError:
2438 warnings.append(_("skipping missing subrepository: %s\n")
2444 warnings.append(_("skipping missing subrepository: %s\n")
2439 % join(subpath))
2445 % join(subpath))
2446 ui.progress(_('searching'), None)
2440
2447
2441 # warn about failure to delete explicit files/dirs
2448 # warn about failure to delete explicit files/dirs
2442 deleteddirs = util.dirs(deleted)
2449 deleteddirs = util.dirs(deleted)
2443 for f in m.files():
2450 files = m.files()
2451 total = len(files)
2452 count = 0
2453 for f in files:
2444 def insubrepo():
2454 def insubrepo():
2445 for subpath in wctx.substate:
2455 for subpath in wctx.substate:
2446 if f.startswith(subpath):
2456 if f.startswith(subpath):
2447 return True
2457 return True
2448 return False
2458 return False
2449
2459
2460 count += 1
2461 ui.progress(_('deleting'), count, total=total, unit=_('files'))
2450 isdir = f in deleteddirs or wctx.hasdir(f)
2462 isdir = f in deleteddirs or wctx.hasdir(f)
2451 if f in repo.dirstate or isdir or f == '.' or insubrepo():
2463 if f in repo.dirstate or isdir or f == '.' or insubrepo():
2452 continue
2464 continue
@@ -2460,28 +2472,49 b' def remove(ui, repo, m, prefix, after, f'
2460 % m.rel(f))
2472 % m.rel(f))
2461 # missing files will generate a warning elsewhere
2473 # missing files will generate a warning elsewhere
2462 ret = 1
2474 ret = 1
2475 ui.progress(_('deleting'), None)
2463
2476
2464 if force:
2477 if force:
2465 list = modified + deleted + clean + added
2478 list = modified + deleted + clean + added
2466 elif after:
2479 elif after:
2467 list = deleted
2480 list = deleted
2468 for f in modified + added + clean:
2481 remaining = modified + added + clean
2469 warnings.append(_('not removing %s: file still exists\n') % m.rel(f))
2482 total = len(remaining)
2483 count = 0
2484 for f in remaining:
2485 count += 1
2486 ui.progress(_('skipping'), count, total=total, unit=_('files'))
2487 warnings.append(_('not removing %s: file still exists\n')
2488 % m.rel(f))
2470 ret = 1
2489 ret = 1
2490 ui.progress(_('skipping'), None)
2471 else:
2491 else:
2472 list = deleted + clean
2492 list = deleted + clean
2493 total = len(modified) + len(added)
2494 count = 0
2473 for f in modified:
2495 for f in modified:
2496 count += 1
2497 ui.progress(_('skipping'), count, total=total, unit=_('files'))
2474 warnings.append(_('not removing %s: file is modified (use -f'
2498 warnings.append(_('not removing %s: file is modified (use -f'
2475 ' to force removal)\n') % m.rel(f))
2499 ' to force removal)\n') % m.rel(f))
2476 ret = 1
2500 ret = 1
2477 for f in added:
2501 for f in added:
2502 count += 1
2503 ui.progress(_('skipping'), count, total=total, unit=_('files'))
2478 warnings.append(_('not removing %s: file has been marked for add'
2504 warnings.append(_('not removing %s: file has been marked for add'
2479 ' (use forget to undo)\n') % m.rel(f))
2505 ' (use forget to undo)\n') % m.rel(f))
2480 ret = 1
2506 ret = 1
2481
2507 ui.progress(_('skipping'), None)
2482 for f in sorted(list):
2508
2509 list = sorted(list)
2510 total = len(list)
2511 count = 0
2512 for f in list:
2513 count += 1
2483 if ui.verbose or not m.exact(f):
2514 if ui.verbose or not m.exact(f):
2515 ui.progress(_('deleting'), count, total=total, unit=_('files'))
2484 ui.status(_('removing %s\n') % m.rel(f))
2516 ui.status(_('removing %s\n') % m.rel(f))
2517 ui.progress(_('deleting'), None)
2485
2518
2486 with repo.wlock():
2519 with repo.wlock():
2487 if not after:
2520 if not after:
@@ -26,6 +26,9 b''
26 file not managed
26 file not managed
27
27
28 $ remove foo
28 $ remove foo
29 \r (no-eol) (esc)
30 deleting [===========================================>] 1/1\r (no-eol) (esc)
31 \r (no-eol) (esc)
29 not removing foo: file is untracked
32 not removing foo: file is untracked
30 exit code: 1
33 exit code: 1
31 ? foo
34 ? foo
@@ -41,6 +44,12 b' 00 state added, options none'
41 $ echo b > bar
44 $ echo b > bar
42 $ hg add bar
45 $ hg add bar
43 $ remove bar
46 $ remove bar
47 \r (no-eol) (esc)
48 deleting [===========================================>] 1/1\r (no-eol) (esc)
49 \r (no-eol) (esc)
50 \r (no-eol) (esc)
51 skipping [===========================================>] 1/1\r (no-eol) (esc)
52 \r (no-eol) (esc)
44 not removing bar: file has been marked for add (use forget to undo)
53 not removing bar: file has been marked for add (use forget to undo)
45 exit code: 1
54 exit code: 1
46 A bar
55 A bar
@@ -54,6 +63,9 b' 00 state added, options none'
54 01 state clean, options none
63 01 state clean, options none
55
64
56 $ remove foo
65 $ remove foo
66 \r (no-eol) (esc)
67 deleting [===========================================>] 1/1\r (no-eol) (esc)
68 \r (no-eol) (esc)
57 exit code: 0
69 exit code: 0
58 R foo
70 R foo
59 ? bar
71 ? bar
@@ -67,6 +79,12 b' 02 state modified, options none'
67
79
68 $ echo b >> foo
80 $ echo b >> foo
69 $ remove foo
81 $ remove foo
82 \r (no-eol) (esc)
83 deleting [===========================================>] 1/1\r (no-eol) (esc)
84 \r (no-eol) (esc)
85 \r (no-eol) (esc)
86 skipping [===========================================>] 1/1\r (no-eol) (esc)
87 \r (no-eol) (esc)
70 not removing foo: file is modified (use -f to force removal)
88 not removing foo: file is modified (use -f to force removal)
71 exit code: 1
89 exit code: 1
72 M foo
90 M foo
@@ -82,6 +100,9 b' 03 state missing, options none'
82
100
83 $ rm foo
101 $ rm foo
84 $ remove foo
102 $ remove foo
103 \r (no-eol) (esc)
104 deleting [===========================================>] 1/1\r (no-eol) (esc)
105 \r (no-eol) (esc)
85 exit code: 0
106 exit code: 0
86 R foo
107 R foo
87 ? bar
108 ? bar
@@ -96,6 +117,9 b' 10 state added, options -f'
96 $ echo b > bar
117 $ echo b > bar
97 $ hg add bar
118 $ hg add bar
98 $ remove -f bar
119 $ remove -f bar
120 \r (no-eol) (esc)
121 deleting [===========================================>] 1/1\r (no-eol) (esc)
122 \r (no-eol) (esc)
99 exit code: 0
123 exit code: 0
100 ? bar
124 ? bar
101 ./bar
125 ./bar
@@ -106,6 +130,9 b' 10 state added, options -f'
106 11 state clean, options -f
130 11 state clean, options -f
107
131
108 $ remove -f foo
132 $ remove -f foo
133 \r (no-eol) (esc)
134 deleting [===========================================>] 1/1\r (no-eol) (esc)
135 \r (no-eol) (esc)
109 exit code: 0
136 exit code: 0
110 R foo
137 R foo
111 \r (no-eol) (esc)
138 \r (no-eol) (esc)
@@ -117,6 +144,9 b' 12 state modified, options -f'
117
144
118 $ echo b >> foo
145 $ echo b >> foo
119 $ remove -f foo
146 $ remove -f foo
147 \r (no-eol) (esc)
148 deleting [===========================================>] 1/1\r (no-eol) (esc)
149 \r (no-eol) (esc)
120 exit code: 0
150 exit code: 0
121 R foo
151 R foo
122 \r (no-eol) (esc)
152 \r (no-eol) (esc)
@@ -128,6 +158,9 b' 13 state missing, options -f'
128
158
129 $ rm foo
159 $ rm foo
130 $ remove -f foo
160 $ remove -f foo
161 \r (no-eol) (esc)
162 deleting [===========================================>] 1/1\r (no-eol) (esc)
163 \r (no-eol) (esc)
131 exit code: 0
164 exit code: 0
132 R foo
165 R foo
133 \r (no-eol) (esc)
166 \r (no-eol) (esc)
@@ -140,6 +173,12 b' 20 state added, options -A'
140 $ echo b > bar
173 $ echo b > bar
141 $ hg add bar
174 $ hg add bar
142 $ remove -A bar
175 $ remove -A bar
176 \r (no-eol) (esc)
177 deleting [===========================================>] 1/1\r (no-eol) (esc)
178 \r (no-eol) (esc)
179 \r (no-eol) (esc)
180 skipping [===========================================>] 1/1\r (no-eol) (esc)
181 \r (no-eol) (esc)
143 not removing bar: file still exists
182 not removing bar: file still exists
144 exit code: 1
183 exit code: 1
145 A bar
184 A bar
@@ -153,6 +192,12 b' 20 state added, options -A'
153 21 state clean, options -A
192 21 state clean, options -A
154
193
155 $ remove -A foo
194 $ remove -A foo
195 \r (no-eol) (esc)
196 deleting [===========================================>] 1/1\r (no-eol) (esc)
197 \r (no-eol) (esc)
198 \r (no-eol) (esc)
199 skipping [===========================================>] 1/1\r (no-eol) (esc)
200 \r (no-eol) (esc)
156 not removing foo: file still exists
201 not removing foo: file still exists
157 exit code: 1
202 exit code: 1
158 ? bar
203 ? bar
@@ -164,6 +209,12 b' 22 state modified, options -A'
164
209
165 $ echo b >> foo
210 $ echo b >> foo
166 $ remove -A foo
211 $ remove -A foo
212 \r (no-eol) (esc)
213 deleting [===========================================>] 1/1\r (no-eol) (esc)
214 \r (no-eol) (esc)
215 \r (no-eol) (esc)
216 skipping [===========================================>] 1/1\r (no-eol) (esc)
217 \r (no-eol) (esc)
167 not removing foo: file still exists
218 not removing foo: file still exists
168 exit code: 1
219 exit code: 1
169 M foo
220 M foo
@@ -179,6 +230,9 b' 23 state missing, options -A'
179
230
180 $ rm foo
231 $ rm foo
181 $ remove -A foo
232 $ remove -A foo
233 \r (no-eol) (esc)
234 deleting [===========================================>] 1/1\r (no-eol) (esc)
235 \r (no-eol) (esc)
182 exit code: 0
236 exit code: 0
183 R foo
237 R foo
184 ? bar
238 ? bar
@@ -193,6 +247,9 b' 30 state added, options -Af'
193 $ echo b > bar
247 $ echo b > bar
194 $ hg add bar
248 $ hg add bar
195 $ remove -Af bar
249 $ remove -Af bar
250 \r (no-eol) (esc)
251 deleting [===========================================>] 1/1\r (no-eol) (esc)
252 \r (no-eol) (esc)
196 exit code: 0
253 exit code: 0
197 ? bar
254 ? bar
198 ./bar
255 ./bar
@@ -203,6 +260,9 b' 30 state added, options -Af'
203 31 state clean, options -Af
260 31 state clean, options -Af
204
261
205 $ remove -Af foo
262 $ remove -Af foo
263 \r (no-eol) (esc)
264 deleting [===========================================>] 1/1\r (no-eol) (esc)
265 \r (no-eol) (esc)
206 exit code: 0
266 exit code: 0
207 R foo
267 R foo
208 ./foo
268 ./foo
@@ -215,6 +275,9 b' 32 state modified, options -Af'
215
275
216 $ echo b >> foo
276 $ echo b >> foo
217 $ remove -Af foo
277 $ remove -Af foo
278 \r (no-eol) (esc)
279 deleting [===========================================>] 1/1\r (no-eol) (esc)
280 \r (no-eol) (esc)
218 exit code: 0
281 exit code: 0
219 R foo
282 R foo
220 ./foo
283 ./foo
@@ -227,6 +290,9 b' 33 state missing, options -Af'
227
290
228 $ rm foo
291 $ rm foo
229 $ remove -Af foo
292 $ remove -Af foo
293 \r (no-eol) (esc)
294 deleting [===========================================>] 1/1\r (no-eol) (esc)
295 \r (no-eol) (esc)
230 exit code: 0
296 exit code: 0
231 R foo
297 R foo
232 \r (no-eol) (esc)
298 \r (no-eol) (esc)
@@ -247,6 +313,17 b' dir, options none'
247
313
248 $ rm test/bar
314 $ rm test/bar
249 $ remove test
315 $ remove test
316 \r (no-eol) (esc)
317 deleting [===========================================>] 1/1\r (no-eol) (esc)
318 \r (no-eol) (esc)
319 \r (no-eol) (esc)
320 deleting [=====================> ] 1/2\r (no-eol) (esc)
321 \r (no-eol) (esc)
322 \r (no-eol) (esc)
323 deleting [===========================================>] 2/2\r (no-eol) (esc)
324 \r (no-eol) (esc)
325 \r (no-eol) (esc)
326 \r (no-eol) (esc)
250 removing test/bar (glob)
327 removing test/bar (glob)
251 removing test/foo (glob)
328 removing test/foo (glob)
252 exit code: 0
329 exit code: 0
@@ -262,6 +339,17 b' dir, options -f'
262
339
263 $ rm test/bar
340 $ rm test/bar
264 $ remove -f test
341 $ remove -f test
342 \r (no-eol) (esc)
343 deleting [===========================================>] 1/1\r (no-eol) (esc)
344 \r (no-eol) (esc)
345 \r (no-eol) (esc)
346 deleting [=====================> ] 1/2\r (no-eol) (esc)
347 \r (no-eol) (esc)
348 \r (no-eol) (esc)
349 deleting [===========================================>] 2/2\r (no-eol) (esc)
350 \r (no-eol) (esc)
351 \r (no-eol) (esc)
352 \r (no-eol) (esc)
265 removing test/bar (glob)
353 removing test/bar (glob)
266 removing test/foo (glob)
354 removing test/foo (glob)
267 exit code: 0
355 exit code: 0
@@ -277,6 +365,17 b' dir, options -A'
277
365
278 $ rm test/bar
366 $ rm test/bar
279 $ remove -A test
367 $ remove -A test
368 \r (no-eol) (esc)
369 deleting [===========================================>] 1/1\r (no-eol) (esc)
370 \r (no-eol) (esc)
371 \r (no-eol) (esc)
372 skipping [===========================================>] 1/1\r (no-eol) (esc)
373 \r (no-eol) (esc)
374 \r (no-eol) (esc)
375 deleting [===========================================>] 1/1\r (no-eol) (esc)
376 \r (no-eol) (esc)
377 \r (no-eol) (esc)
378 \r (no-eol) (esc)
280 removing test/bar (glob)
379 removing test/bar (glob)
281 not removing test/foo: file still exists (glob)
380 not removing test/foo: file still exists (glob)
282 exit code: 1
381 exit code: 1
@@ -292,6 +391,17 b' dir, options -Af'
292
391
293 $ rm test/bar
392 $ rm test/bar
294 $ remove -Af test
393 $ remove -Af test
394 \r (no-eol) (esc)
395 deleting [===========================================>] 1/1\r (no-eol) (esc)
396 \r (no-eol) (esc)
397 \r (no-eol) (esc)
398 deleting [=====================> ] 1/2\r (no-eol) (esc)
399 \r (no-eol) (esc)
400 \r (no-eol) (esc)
401 deleting [===========================================>] 2/2\r (no-eol) (esc)
402 \r (no-eol) (esc)
403 \r (no-eol) (esc)
404 \r (no-eol) (esc)
295 removing test/bar (glob)
405 removing test/bar (glob)
296 removing test/foo (glob)
406 removing test/foo (glob)
297 exit code: 0
407 exit code: 0
@@ -313,6 +423,14 b' test remove dropping empty trees (issue1'
313 adding issue1861/b/c/y
423 adding issue1861/b/c/y
314 adding issue1861/x
424 adding issue1861/x
315 $ hg rm issue1861/b
425 $ hg rm issue1861/b
426 \r (no-eol) (esc)
427 deleting [===========================================>] 1/1\r (no-eol) (esc)
428 \r (no-eol) (esc)
429 \r (no-eol) (esc)
430 deleting [===========================================>] 1/1\r (no-eol) (esc)
431 \r (no-eol) (esc)
432 \r (no-eol) (esc)
433 \r (no-eol) (esc)
316 removing issue1861/b/c/y (glob)
434 removing issue1861/b/c/y (glob)
317 $ hg ci -m remove
435 $ hg ci -m remove
318 $ ls issue1861
436 $ ls issue1861
@@ -333,11 +451,22 b' handling of untracked directories and mi'
333 $ mkdir d1
451 $ mkdir d1
334 $ echo a > d1/a
452 $ echo a > d1/a
335 $ hg rm --after d1
453 $ hg rm --after d1
454 \r (no-eol) (esc)
455 deleting [===========================================>] 1/1\r (no-eol) (esc)
456 \r (no-eol) (esc)
336 not removing d1: no tracked files
457 not removing d1: no tracked files
337 [1]
458 [1]
338 $ hg add d1/a
459 $ hg add d1/a
339 $ rm d1/a
460 $ rm d1/a
340 $ hg rm --after d1
461 $ hg rm --after d1
462 \r (no-eol) (esc)
463 deleting [===========================================>] 1/1\r (no-eol) (esc)
464 \r (no-eol) (esc)
465 \r (no-eol) (esc)
466 deleting [===========================================>] 1/1\r (no-eol) (esc)
467 \r (no-eol) (esc)
468 \r (no-eol) (esc)
469 \r (no-eol) (esc)
341 removing d1/a (glob)
470 removing d1/a (glob)
342 #if windows
471 #if windows
343 $ hg rm --after nosuch
472 $ hg rm --after nosuch
@@ -346,5 +475,8 b' handling of untracked directories and mi'
346 #else
475 #else
347 $ hg rm --after nosuch
476 $ hg rm --after nosuch
348 nosuch: No such file or directory
477 nosuch: No such file or directory
478 \r (no-eol) (esc)
479 deleting [===========================================>] 1/1\r (no-eol) (esc)
480 \r (no-eol) (esc)
349 [1]
481 [1]
350 #endif
482 #endif
@@ -204,6 +204,18 b' Check that deep archiving works'
204 .. but first take a detour through some deep removal testing
204 .. but first take a detour through some deep removal testing
205
205
206 $ hg remove -S -I 're:.*.txt' .
206 $ hg remove -S -I 're:.*.txt' .
207 \r (no-eol) (esc)
208 searching [==========================================>] 1/1\r (no-eol) (esc)
209 searching [==========================================>] 1/1\r (no-eol) (esc)
210 \r (no-eol) (esc)
211 \r (no-eol) (esc)
212 deleting [=====================> ] 1/2\r (no-eol) (esc)
213 \r (no-eol) (esc)
214 \r (no-eol) (esc)
215 deleting [===========================================>] 2/2\r (no-eol) (esc)
216 \r (no-eol) (esc)
217 \r (no-eol) (esc)
218 \r (no-eol) (esc)
207 removing sub1/sub2/folder/test.txt (glob)
219 removing sub1/sub2/folder/test.txt (glob)
208 removing sub1/sub2/test.txt (glob)
220 removing sub1/sub2/test.txt (glob)
209 $ hg status -S
221 $ hg status -S
@@ -211,9 +223,37 b' Check that deep archiving works'
211 R sub1/sub2/test.txt
223 R sub1/sub2/test.txt
212 $ hg update -Cq
224 $ hg update -Cq
213 $ hg remove -I 're:.*.txt' sub1
225 $ hg remove -I 're:.*.txt' sub1
226 \r (no-eol) (esc)
227 searching [==========================================>] 1/1\r (no-eol) (esc)
228 \r (no-eol) (esc)
229 \r (no-eol) (esc)
230 deleting [===========================================>] 1/1\r (no-eol) (esc)
231 \r (no-eol) (esc)
214 $ hg status -S
232 $ hg status -S
215 $ hg remove sub1/sub2/folder/test.txt
233 $ hg remove sub1/sub2/folder/test.txt
234 \r (no-eol) (esc)
235 searching [==========================================>] 1/1\r (no-eol) (esc)
236 searching [==========================================>] 1/1\r (no-eol) (esc)
237 \r (no-eol) (esc)
238 \r (no-eol) (esc)
239 deleting [===========================================>] 1/1\r (no-eol) (esc)
240 \r (no-eol) (esc)
241 \r (no-eol) (esc)
242 deleting [===========================================>] 1/1\r (no-eol) (esc)
243 \r (no-eol) (esc)
244 \r (no-eol) (esc)
245 deleting [===========================================>] 1/1\r (no-eol) (esc)
246 \r (no-eol) (esc)
216 $ hg remove sub1/.hgsubstate
247 $ hg remove sub1/.hgsubstate
248 \r (no-eol) (esc)
249 searching [==========================================>] 1/1\r (no-eol) (esc)
250 \r (no-eol) (esc)
251 \r (no-eol) (esc)
252 deleting [===========================================>] 1/1\r (no-eol) (esc)
253 \r (no-eol) (esc)
254 \r (no-eol) (esc)
255 deleting [===========================================>] 1/1\r (no-eol) (esc)
256 \r (no-eol) (esc)
217 $ mv sub1/.hgsub sub1/x.hgsub
257 $ mv sub1/.hgsub sub1/x.hgsub
218 $ hg status -S
258 $ hg status -S
219 warning: subrepo spec file 'sub1/.hgsub' not found
259 warning: subrepo spec file 'sub1/.hgsub' not found
@@ -247,6 +287,9 b' Test relative path printing + subrepos'
247
287
248 Archive wdir() with subrepos
288 Archive wdir() with subrepos
249 $ hg rm main
289 $ hg rm main
290 \r (no-eol) (esc)
291 deleting [===========================================>] 1/1\r (no-eol) (esc)
292 \r (no-eol) (esc)
250 $ hg archive -S -r 'wdir()' ../wdir
293 $ hg archive -S -r 'wdir()' ../wdir
251 \r (no-eol) (esc)
294 \r (no-eol) (esc)
252 archiving [ ] 0/3\r (no-eol) (esc)
295 archiving [ ] 0/3\r (no-eol) (esc)
@@ -853,6 +896,10 b' Test a directory commit with a changed l'
853 Test .hgsubstate in the R state
896 Test .hgsubstate in the R state
854
897
855 $ hg rm .hgsub .hgsubstate
898 $ hg rm .hgsub .hgsubstate
899 \r (no-eol) (esc)
900 deleting [=====================> ] 1/2\r (no-eol) (esc)
901 deleting [===========================================>] 2/2\r (no-eol) (esc)
902 \r (no-eol) (esc)
856 $ hg ci -m 'trash subrepo tracking'
903 $ hg ci -m 'trash subrepo tracking'
857
904
858 $ hg log -r "subrepo('re:sub\d+')" --style compact
905 $ hg log -r "subrepo('re:sub\d+')" --style compact
General Comments 0
You need to be logged in to leave comments. Login now