Gentoo Archives: gentoo-portage-dev

From: Fabian Groffen <grobian@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Fabian Groffen <grobian@g.o>
Subject: [gentoo-portage-dev] [PATCH] lib/portage/dbapi/vartree: use dynamic report interval in _collision_protect
Date: Mon, 07 Jan 2019 14:31:32
Message-Id: 20190107143113.7068-1-grobian@gentoo.org
1 The reporting of files remaining can look somewhat odd since the report
2 interval is hardcoded to be per 1000 objects. Adjust this interval to
3 be regular towards the end. While at it, report percentage done.
4
5 Output before this patch:
6
7 * checking 6111 files for package collisions
8 5111 files remaining ...
9 4111 files remaining ...
10 3111 files remaining ...
11 2111 files remaining ...
12 1111 files remaining ...
13 111 files remaining ...
14
15 After:
16
17 * checking 6158 files for package collisions
18 16% done, 5131 files remaining ...
19 33% done, 4104 files remaining ...
20 50% done, 3077 files remaining ...
21 66% done, 2050 files remaining ...
22 83% done, 1023 files remaining ...
23
24 Signed-off-by: Fabian Groffen <grobian@g.o>
25 ---
26 lib/portage/dbapi/vartree.py | 10 ++++++++--
27 1 file changed, 8 insertions(+), 2 deletions(-)
28
29 diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py
30 index 4b91caea8..4d0bf2789 100644
31 --- a/lib/portage/dbapi/vartree.py
32 +++ b/lib/portage/dbapi/vartree.py
33 @@ -3475,13 +3475,19 @@ class dblink(object):
34 symlink_collisions = []
35 destroot = self.settings['ROOT']
36 totfiles = len(file_list) + len(symlink_list)
37 + bucksize = 1000
38 + buckcnt = int(totfiles / bucksize)
39 + if buckcnt == 0 or totfiles % bucksize > int(bucksize / 2):
40 + buckcnt = buckcnt + 1
41 + bucksize = int(totfiles / buckcnt) + 1
42 showMessage(_(" %s checking %d files for package collisions\n") % \
43 (colorize("GOOD", "*"), totfiles))
44 for i, (f, f_type) in enumerate(chain(
45 ((f, "reg") for f in file_list),
46 ((f, "sym") for f in symlink_list))):
47 - if i % 1000 == 0 and i != 0:
48 - showMessage(_("%d files remaining ...\n") % (totfiles - i))
49 + if i % bucksize == 0 and i != 0:
50 + showMessage(_("%2d%% done, %d files remaining ...\n") %
51 + (i * 100 / totfiles, totfiles - i))
52
53 dest_path = normalize_path(
54 os.path.join(destroot, f.lstrip(os.path.sep)))
55 --
56 2.20.1

Replies