changeset 28608:62e73d42bd14

remove: add progress support
author timeless <timeless@mozdev.org>
date Thu, 17 Mar 2016 21:03:22 +0000
parents a88959ae5938
children c11f0992d124
files mercurial/cmdutil.py tests/test-remove.t tests/test-subrepo-deep-nested-change.t
diffstat 3 files changed, 218 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Thu Mar 17 18:19:36 2016 +0000
+++ b/mercurial/cmdutil.py	Thu Mar 17 21:03:22 2016 +0000
@@ -2418,7 +2418,10 @@
     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 @@
                     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 @@
             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 @@
                         % 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:
--- a/tests/test-remove.t	Thu Mar 17 18:19:36 2016 +0000
+++ b/tests/test-remove.t	Thu Mar 17 21:03:22 2016 +0000
@@ -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 @@
   $ 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 @@
 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 @@
 
   $ 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 @@
 
   $ 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 @@
   $ 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 @@
 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 @@
 
   $ 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 @@
 
   $ 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 @@
   $ 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 @@
 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 @@
 
   $ 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 @@
 
   $ 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 @@
   $ 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 @@
 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 @@
 
   $ 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 @@
 
   $ 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 @@
 
   $ 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 @@
 
   $ 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 @@
 
   $ 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 @@
 
   $ 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 @@
   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 @@
   $ 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 @@
 #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
--- a/tests/test-subrepo-deep-nested-change.t	Thu Mar 17 18:19:36 2016 +0000
+++ b/tests/test-subrepo-deep-nested-change.t	Thu Mar 17 21:03:22 2016 +0000
@@ -204,6 +204,18 @@
 .. 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 @@
   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 @@
 
 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 .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