Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/dbapi/, /
Date: Thu, 01 Dec 2022 07:08:08
Message-Id: 1669878482.66f64d08ffb13ca24cfc11584fe667b1c391fbe8.sam@gentoo
1 commit: 66f64d08ffb13ca24cfc11584fe667b1c391fbe8
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Thu Dec 1 06:31:53 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Thu Dec 1 07:08:02 2022 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=66f64d08
7
8 vartree: use ewarn if merging despite collisions
9
10 Use ewarn, not eerror, if merge is going ahead despite collisions.
11
12 Collisions aren't always fatal - say if FEATURES="protect-owned unmerge-orphans"
13 and the collision is over an orphaned file.
14
15 This changes the colors used once we discover that all relevant files
16 are orphaned to be warning rather than an error, to make it less scary
17 and distinguish from other situations.
18
19 Closes: https://github.com/gentoo/portage/pull/952
20 Signed-off-by: Sam James <sam <AT> gentoo.org>
21
22 NEWS | 4 +++-
23 lib/portage/dbapi/vartree.py | 18 +++++++++++++++---
24 2 files changed, 18 insertions(+), 4 deletions(-)
25
26 diff --git a/NEWS b/NEWS
27 index d64fcac91..a907526aa 100644
28 --- a/NEWS
29 +++ b/NEWS
30 @@ -2,7 +2,9 @@ portage-3.0.41 (UNRELEASED)
31 --------------
32
33 Features:
34 -* TODO
35 +* vartree: On collisions which are non-fatal (e.g. orphaned files when using
36 + FEATURES="protect-owned"), Portage now has friendlier output
37 + by using ewarn rather than eerror.
38
39 Bug fixes:
40 * TODO
41
42 diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py
43 index a95d60691..139424c0a 100644
44 --- a/lib/portage/dbapi/vartree.py
45 +++ b/lib/portage/dbapi/vartree.py
46 @@ -4187,6 +4187,9 @@ class dblink:
47 def _eqawarn(self, phase, lines):
48 self._elog("eqawarn", phase, lines)
49
50 + def _ewarn(self, phase, lines):
51 + self._elog("ewarn", phase, lines)
52 +
53 def _eerror(self, phase, lines):
54 self._elog("eerror", phase, lines)
55
56 @@ -4388,6 +4391,9 @@ class dblink:
57 ],
58 )
59
60 + def ewarn(lines):
61 + self._ewarn("preinst", lines)
62 +
63 def eerror(lines):
64 self._eerror("preinst", lines)
65
66 @@ -4884,6 +4890,10 @@ class dblink:
67 finally:
68 self.unlockdb()
69
70 + collision_message_type = ewarn
71 + if collision_protect or protect_owned and owners:
72 + collision_message_type = eerror
73 +
74 for pkg, owned_files in owners.items():
75 msg = []
76 msg.append(pkg_info_strs[pkg.mycpv])
77 @@ -4892,10 +4902,10 @@ class dblink:
78 "\t%s" % os.path.join(destroot, f.lstrip(os.path.sep))
79 )
80 msg.append("")
81 - eerror(msg)
82 + collision_message_type(msg)
83
84 if not owners:
85 - eerror(
86 + collision_message_type(
87 [_("None of the installed" " packages claim the file(s)."), ""]
88 )
89
90 @@ -4935,10 +4945,12 @@ class dblink:
91 " If necessary, refer to your elog "
92 "messages for the whole content of the above message."
93 )
94 - eerror(wrap(msg, 70))
95
96 if abort:
97 + eerror(wrap(msg, 70))
98 return 1
99 + else:
100 + ewarn(wrap(msg, 70))
101
102 # The merge process may move files out of the image directory,
103 # which causes invalidation of the .installed flag.