1 |
commit: b67367d3e7d11a0d7d62e48d433c76eae64e5f99 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Apr 29 15:04:13 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Apr 29 15:04:13 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b67367d3 |
7 |
|
8 |
action_info: eliminate duplicate info_pkgs match |
9 |
|
10 |
Currently, sys-kernel/linux-headers is matched by both a plain |
11 |
sys-kernel/linux-headers atom and by the virtual/os-headers new-style |
12 |
virtual. For backward compatibility, we're going to have duplicates |
13 |
like this for at least a few months (see bug #364673, comment #5). |
14 |
Therefore, automatically eliminate duplicates in the display. Entries |
15 |
that include virtual provider info are preferred over those that do |
16 |
not. |
17 |
|
18 |
--- |
19 |
pym/_emerge/actions.py | 31 +++++++++++++++++++++---------- |
20 |
1 files changed, 21 insertions(+), 10 deletions(-) |
21 |
|
22 |
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py |
23 |
index 59db58d..6379b36 100644 |
24 |
--- a/pym/_emerge/actions.py |
25 |
+++ b/pym/_emerge/actions.py |
26 |
@@ -1427,13 +1427,26 @@ def action_info(settings, trees, myopts, myfiles): |
27 |
|
28 |
portdb = trees["/"]["porttree"].dbapi |
29 |
main_repo = portdb.getRepositoryName(portdb.porttree_root) |
30 |
+ cp_map = {} |
31 |
+ cp_max_len = 0 |
32 |
|
33 |
for orig_atom, x in myvars: |
34 |
pkg_matches = vardb.match(x) |
35 |
|
36 |
versions = [] |
37 |
for cpv in pkg_matches: |
38 |
+ matched_cp = portage.versions.cpv_getkey(cpv) |
39 |
ver = portage.versions.cpv_getversion(cpv) |
40 |
+ ver_map = cp_map.setdefault(matched_cp, {}) |
41 |
+ prev_match = ver_map.get(ver) |
42 |
+ if prev_match is not None: |
43 |
+ if prev_match.provide_suffix: |
44 |
+ # prefer duplicate matches that include |
45 |
+ # additional virtual provider info |
46 |
+ continue |
47 |
+ |
48 |
+ if len(matched_cp) > cp_max_len: |
49 |
+ cp_max_len = len(matched_cp) |
50 |
repo = vardb.aux_get(cpv, ["repository"])[0] |
51 |
if repo == main_repo: |
52 |
repo_suffix = "" |
53 |
@@ -1441,22 +1454,20 @@ def action_info(settings, trees, myopts, myfiles): |
54 |
repo_suffix = "::<unknown repository>" |
55 |
else: |
56 |
repo_suffix = "::" + repo |
57 |
- |
58 |
- matched_cp = portage.versions.cpv_getkey(cpv) |
59 |
+ |
60 |
if matched_cp == orig_atom.cp: |
61 |
provide_suffix = "" |
62 |
else: |
63 |
provide_suffix = " (%s)" % (orig_atom,) |
64 |
|
65 |
- versions.append( |
66 |
- _info_pkgs_ver(ver, repo_suffix, provide_suffix)) |
67 |
- |
68 |
- versions.sort() |
69 |
+ ver_map[ver] = _info_pkgs_ver(ver, repo_suffix, provide_suffix) |
70 |
|
71 |
- if versions: |
72 |
- versions = ", ".join(ver.toString() for ver in versions) |
73 |
- writemsg_stdout("%-20s %s\n" % (x+":", versions), |
74 |
- noiselevel=-1) |
75 |
+ for cp in sorted(cp_map): |
76 |
+ versions = sorted(cp_map[cp].values()) |
77 |
+ versions = ", ".join(ver.toString() for ver in versions) |
78 |
+ writemsg_stdout("%s %s\n" % \ |
79 |
+ ((cp + ":").ljust(cp_max_len + 1), versions), |
80 |
+ noiselevel=-1) |
81 |
|
82 |
libtool_vers = ",".join(trees["/"]["vartree"].dbapi.match("sys-devel/libtool")) |