diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2418,7 +2418,10 @@ def remove(ui, repo, m, prefix, after, f else: warn = False - for subpath in sorted(wctx.substate): + subs = sorted(wctx.substate) + total = len(subs) + count = 0 + for subpath in subs: def matchessubrepo(matcher, subpath): if matcher.exact(subpath): return True @@ -2427,7 +2430,10 @@ def remove(ui, repo, m, prefix, after, f return True return False + count += 1 if subrepos or matchessubrepo(m, subpath): + ui.progress(_('searching'), count, total=total, unit=_('subrepos')) + sub = wctx.sub(subpath) try: submatch = matchmod.subdirmatcher(subpath, m) @@ -2437,16 +2443,22 @@ def remove(ui, repo, m, prefix, after, f except error.LookupError: warnings.append(_("skipping missing subrepository: %s\n") % join(subpath)) + ui.progress(_('searching'), None) # warn about failure to delete explicit files/dirs deleteddirs = util.dirs(deleted) - for f in m.files(): + files = m.files() + total = len(files) + count = 0 + for f in files: def insubrepo(): for subpath in wctx.substate: if f.startswith(subpath): return True return False + count += 1 + ui.progress(_('deleting'), count, total=total, unit=_('files')) isdir = f in deleteddirs or wctx.hasdir(f) if f in repo.dirstate or isdir or f == '.' or insubrepo(): continue @@ -2460,28 +2472,49 @@ def remove(ui, repo, m, prefix, after, f % m.rel(f)) # missing files will generate a warning elsewhere ret = 1 + ui.progress(_('deleting'), None) if force: list = modified + deleted + clean + added elif after: list = deleted - for f in modified + added + clean: - warnings.append(_('not removing %s: file still exists\n') % m.rel(f)) + remaining = modified + added + clean + total = len(remaining) + count = 0 + for f in remaining: + count += 1 + ui.progress(_('skipping'), count, total=total, unit=_('files')) + warnings.append(_('not removing %s: file still exists\n') + % m.rel(f)) ret = 1 + ui.progress(_('skipping'), None) else: list = deleted + clean + total = len(modified) + len(added) + count = 0 for f in modified: + count += 1 + ui.progress(_('skipping'), count, total=total, unit=_('files')) warnings.append(_('not removing %s: file is modified (use -f' ' to force removal)\n') % m.rel(f)) ret = 1 for f in added: + count += 1 + ui.progress(_('skipping'), count, total=total, unit=_('files')) warnings.append(_('not removing %s: file has been marked for add' ' (use forget to undo)\n') % m.rel(f)) ret = 1 - - for f in sorted(list): + ui.progress(_('skipping'), None) + + list = sorted(list) + total = len(list) + count = 0 + for f in list: + count += 1 if ui.verbose or not m.exact(f): + ui.progress(_('deleting'), count, total=total, unit=_('files')) ui.status(_('removing %s\n') % m.rel(f)) + ui.progress(_('deleting'), None) with repo.wlock(): if not after: diff --git a/tests/test-remove.t b/tests/test-remove.t --- a/tests/test-remove.t +++ b/tests/test-remove.t @@ -26,6 +26,9 @@ file not managed $ remove foo + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) not removing foo: file is untracked exit code: 1 ? foo @@ -41,6 +44,12 @@ 00 state added, options none $ echo b > bar $ hg add bar $ remove bar + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + skipping [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) not removing bar: file has been marked for add (use forget to undo) exit code: 1 A bar @@ -54,6 +63,9 @@ 00 state added, options none 01 state clean, options none $ remove foo + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) exit code: 0 R foo ? bar @@ -67,6 +79,12 @@ 02 state modified, options none $ echo b >> foo $ remove foo + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + skipping [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) not removing foo: file is modified (use -f to force removal) exit code: 1 M foo @@ -82,6 +100,9 @@ 03 state missing, options none $ rm foo $ remove foo + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) exit code: 0 R foo ? bar @@ -96,6 +117,9 @@ 10 state added, options -f $ echo b > bar $ hg add bar $ remove -f bar + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) exit code: 0 ? bar ./bar @@ -106,6 +130,9 @@ 10 state added, options -f 11 state clean, options -f $ remove -f foo + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) exit code: 0 R foo \r (no-eol) (esc) @@ -117,6 +144,9 @@ 12 state modified, options -f $ echo b >> foo $ remove -f foo + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) exit code: 0 R foo \r (no-eol) (esc) @@ -128,6 +158,9 @@ 13 state missing, options -f $ rm foo $ remove -f foo + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) exit code: 0 R foo \r (no-eol) (esc) @@ -140,6 +173,12 @@ 20 state added, options -A $ echo b > bar $ hg add bar $ remove -A bar + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + skipping [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) not removing bar: file still exists exit code: 1 A bar @@ -153,6 +192,12 @@ 20 state added, options -A 21 state clean, options -A $ remove -A foo + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + skipping [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) not removing foo: file still exists exit code: 1 ? bar @@ -164,6 +209,12 @@ 22 state modified, options -A $ echo b >> foo $ remove -A foo + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + skipping [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) not removing foo: file still exists exit code: 1 M foo @@ -179,6 +230,9 @@ 23 state missing, options -A $ rm foo $ remove -A foo + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) exit code: 0 R foo ? bar @@ -193,6 +247,9 @@ 30 state added, options -Af $ echo b > bar $ hg add bar $ remove -Af bar + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) exit code: 0 ? bar ./bar @@ -203,6 +260,9 @@ 30 state added, options -Af 31 state clean, options -Af $ remove -Af foo + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) exit code: 0 R foo ./foo @@ -215,6 +275,9 @@ 32 state modified, options -Af $ echo b >> foo $ remove -Af foo + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) exit code: 0 R foo ./foo @@ -227,6 +290,9 @@ 33 state missing, options -Af $ rm foo $ remove -Af foo + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) exit code: 0 R foo \r (no-eol) (esc) @@ -247,6 +313,17 @@ dir, options none $ rm test/bar $ remove test + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + deleting [=====================> ] 1/2\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + deleting [===========================================>] 2/2\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) removing test/bar (glob) removing test/foo (glob) exit code: 0 @@ -262,6 +339,17 @@ dir, options -f $ rm test/bar $ remove -f test + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + deleting [=====================> ] 1/2\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + deleting [===========================================>] 2/2\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) removing test/bar (glob) removing test/foo (glob) exit code: 0 @@ -277,6 +365,17 @@ dir, options -A $ rm test/bar $ remove -A test + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + skipping [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) removing test/bar (glob) not removing test/foo: file still exists (glob) exit code: 1 @@ -292,6 +391,17 @@ dir, options -Af $ rm test/bar $ remove -Af test + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + deleting [=====================> ] 1/2\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + deleting [===========================================>] 2/2\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) removing test/bar (glob) removing test/foo (glob) exit code: 0 @@ -313,6 +423,14 @@ test remove dropping empty trees (issue1 adding issue1861/b/c/y adding issue1861/x $ hg rm issue1861/b + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) removing issue1861/b/c/y (glob) $ hg ci -m remove $ ls issue1861 @@ -333,11 +451,22 @@ handling of untracked directories and mi $ mkdir d1 $ echo a > d1/a $ hg rm --after d1 + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) not removing d1: no tracked files [1] $ hg add d1/a $ rm d1/a $ hg rm --after d1 + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) removing d1/a (glob) #if windows $ hg rm --after nosuch @@ -346,5 +475,8 @@ handling of untracked directories and mi #else $ hg rm --after nosuch nosuch: No such file or directory + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) [1] #endif diff --git a/tests/test-subrepo-deep-nested-change.t b/tests/test-subrepo-deep-nested-change.t --- a/tests/test-subrepo-deep-nested-change.t +++ b/tests/test-subrepo-deep-nested-change.t @@ -204,6 +204,18 @@ Check that deep archiving works .. but first take a detour through some deep removal testing $ hg remove -S -I 're:.*.txt' . + \r (no-eol) (esc) + searching [==========================================>] 1/1\r (no-eol) (esc) + searching [==========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + deleting [=====================> ] 1/2\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + deleting [===========================================>] 2/2\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) removing sub1/sub2/folder/test.txt (glob) removing sub1/sub2/test.txt (glob) $ hg status -S @@ -211,9 +223,37 @@ Check that deep archiving works R sub1/sub2/test.txt $ hg update -Cq $ hg remove -I 're:.*.txt' sub1 + \r (no-eol) (esc) + searching [==========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) $ hg status -S $ hg remove sub1/sub2/folder/test.txt + \r (no-eol) (esc) + searching [==========================================>] 1/1\r (no-eol) (esc) + searching [==========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) $ hg remove sub1/.hgsubstate + \r (no-eol) (esc) + searching [==========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) $ mv sub1/.hgsub sub1/x.hgsub $ hg status -S warning: subrepo spec file 'sub1/.hgsub' not found @@ -247,6 +287,9 @@ Test relative path printing + subrepos Archive wdir() with subrepos $ hg rm main + \r (no-eol) (esc) + deleting [===========================================>] 1/1\r (no-eol) (esc) + \r (no-eol) (esc) $ hg archive -S -r 'wdir()' ../wdir \r (no-eol) (esc) archiving [ ] 0/3\r (no-eol) (esc) @@ -853,6 +896,10 @@ Test a directory commit with a changed l Test .hgsubstate in the R state $ hg rm .hgsub .hgsubstate + \r (no-eol) (esc) + deleting [=====================> ] 1/2\r (no-eol) (esc) + deleting [===========================================>] 2/2\r (no-eol) (esc) + \r (no-eol) (esc) $ hg ci -m 'trash subrepo tracking' $ hg log -r "subrepo('re:sub\d+')" --style compact