The reporting of files remaining can look somewhat odd since the report
interval is hardcoded to be per 1000 objects.  Adjust this interval to
be regular towards the end.  While at it, report percentage done.

Output before this patch:

 * checking 6111 files for package collisions
5111 files remaining ...
4111 files remaining ...
3111 files remaining ...
2111 files remaining ...
1111 files remaining ...
111 files remaining ...

After:

 * checking 6158 files for package collisions
16% done, 5131 files remaining ...
33% done, 4104 files remaining ...
50% done, 3077 files remaining ...
66% done, 2050 files remaining ...
83% done, 1023 files remaining ...

Signed-off-by: Fabian Groffen <grob...@gentoo.org>
---
 lib/portage/dbapi/vartree.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py
index 4b91caea8..4d0bf2789 100644
--- a/lib/portage/dbapi/vartree.py
+++ b/lib/portage/dbapi/vartree.py
@@ -3475,13 +3475,19 @@ class dblink(object):
                        symlink_collisions = []
                        destroot = self.settings['ROOT']
                        totfiles = len(file_list) + len(symlink_list)
+                       bucksize = 1000
+                       buckcnt = int(totfiles / bucksize)
+                       if buckcnt == 0 or totfiles % bucksize > int(bucksize / 
2):
+                               buckcnt = buckcnt + 1
+                       bucksize = int(totfiles / buckcnt) + 1
                        showMessage(_(" %s checking %d files for package 
collisions\n") % \
                                (colorize("GOOD", "*"), totfiles))
                        for i, (f, f_type) in enumerate(chain(
                                ((f, "reg") for f in file_list),
                                ((f, "sym") for f in symlink_list))):
-                               if i % 1000 == 0 and i != 0:
-                                       showMessage(_("%d files remaining 
...\n") % (totfiles - i))
+                               if i % bucksize == 0 and i != 0:
+                                       showMessage(_("%2d%% done, %d files 
remaining ...\n") %
+                                                       (i * 100 / totfiles, 
totfiles - i))
 
                                dest_path = normalize_path(
                                        os.path.join(destroot, 
f.lstrip(os.path.sep)))
-- 
2.20.1


Reply via email to