comparison mercurial/cmdutil.py @ 28608:62e73d42bd14

remove: add progress support
author timeless <timeless@mozdev.org>
date Thu, 17 Mar 2016 21:03:22 +0000
parents a88959ae5938
children 6433da9c96a9
comparison
equal deleted inserted replaced
28607:a88959ae5938 28608:62e73d42bd14
2416 warnings = [] 2416 warnings = []
2417 warn = True 2417 warn = True
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
2425 for f in matcher.files(): 2428 for f in matcher.files():
2426 if f.startswith(subpath): 2429 if f.startswith(subpath):
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)
2434 if sub.removefiles(submatch, prefix, after, force, subrepos, 2440 if sub.removefiles(submatch, prefix, after, force, subrepos,
2435 warnings): 2441 warnings):
2436 ret = 1 2442 ret = 1
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
2453 2465
2454 if repo.wvfs.exists(f): 2466 if repo.wvfs.exists(f):
2458 else: 2470 else:
2459 warnings.append(_('not removing %s: file is untracked\n') 2471 warnings.append(_('not removing %s: file is untracked\n')
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:
2488 for f in list: 2521 for f in list:
2489 if f in added: 2522 if f in added: