Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/dbapi/
Date: Fri, 11 Jan 2019 10:15:00
Message-Id: 1547201662.cfa915d0d575379df4b9f17fd2db3594155861ca.grobian@gentoo
1 commit: cfa915d0d575379df4b9f17fd2db3594155861ca
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Mon Jan 7 14:19:15 2019 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Fri Jan 11 10:14:22 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=cfa915d0
7
8 collision_protect: use dynamic report interval
9
10 The reporting of files remaining can look somewhat odd since the report
11 interval is hardcoded to be per 1000 objects. Adjust this interval to
12 be time based. This means that modern (fast) machines likely will never
13 see the countdown messages at all. On slow setups the message will be
14 informative that there is progress, albeit rather slowly. While at it,
15 report percentage done.
16
17 Output before this patch:
18
19 * checking 6158 files for package collisions
20 5158 files remaining ...
21 4158 files remaining ...
22 3158 files remaining ...
23 2158 files remaining ...
24 1158 files remaining ...
25 158 files remaining ...
26
27 Possible output after this patch on a slower machine:
28
29 * checking 6158 files for package collisions
30 48% done, 3145 files remaining ...
31 96% done, 192 files remaining ...
32 100% done
33
34 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
35
36 lib/portage/dbapi/vartree.py | 15 +++++++++++++--
37 1 file changed, 13 insertions(+), 2 deletions(-)
38
39 diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py
40 index 9febf0c71..63389f9a3 100644
41 --- a/lib/portage/dbapi/vartree.py
42 +++ b/lib/portage/dbapi/vartree.py
43 @@ -35,6 +35,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
44 'portage.util.install_mask:install_mask_dir,InstallMask',
45 'portage.util.listdir:dircache,listdir',
46 'portage.util.movefile:movefile',
47 + 'portage.util.monotonic:monotonic',
48 'portage.util.path:first_existing,iter_parents',
49 'portage.util.writeable_check:get_ro_checker',
50 'portage.util._xattr:xattr',
51 @@ -3453,13 +3454,21 @@ class dblink(object):
52 symlink_collisions = []
53 destroot = self.settings['ROOT']
54 totfiles = len(file_list) + len(symlink_list)
55 + previous = monotonic()
56 + progress_shown = False
57 + report_interval = 1.7 # seconds
58 + falign = len("%d" % totfiles)
59 showMessage(_(" %s checking %d files for package collisions\n") % \
60 (colorize("GOOD", "*"), totfiles))
61 for i, (f, f_type) in enumerate(chain(
62 ((f, "reg") for f in file_list),
63 ((f, "sym") for f in symlink_list))):
64 - if i % 1000 == 0 and i != 0:
65 - showMessage(_("%d files remaining ...\n") % (totfiles - i))
66 + current = monotonic()
67 + if current - previous > report_interval:
68 + showMessage(_("%3d%% done, %*d files remaining ...\n") %
69 + (i * 100 / totfiles, falign, totfiles - i))
70 + previous = current
71 + progress_shown = True
72
73 dest_path = normalize_path(
74 os.path.join(destroot, f.lstrip(os.path.sep)))
75 @@ -3548,6 +3557,8 @@ class dblink(object):
76 break
77 if stopmerge:
78 collisions.append(f)
79 + if progress_shown:
80 + showMessage(_("100% done\n"))
81 return collisions, dirs_ro, symlink_collisions, plib_collisions
82
83 def _lstat_inode_map(self, path_iter):