From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 9F0421380DC for ; Wed, 5 Feb 2014 19:42:18 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 82D59E0CF5; Wed, 5 Feb 2014 19:42:15 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id CF386E0CF0 for ; Wed, 5 Feb 2014 19:42:14 +0000 (UTC) Received: from spoonbill.gentoo.org (spoonbill.gentoo.org [81.93.255.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id A35BE33F94F for ; Wed, 5 Feb 2014 19:42:13 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id E5EE618889 for ; Wed, 5 Feb 2014 19:42:09 +0000 (UTC) From: "Sebastian Luther" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sebastian Luther" Message-ID: <1391629161.f9473424cb810bc946ff5a63fcce1e9ebfa86bf9.few@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/resolver/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/resolver/slot_collision.py X-VCS-Directories: pym/_emerge/resolver/ X-VCS-Committer: few X-VCS-Committer-Name: Sebastian Luther X-VCS-Revision: f9473424cb810bc946ff5a63fcce1e9ebfa86bf9 X-VCS-Branch: master Date: Wed, 5 Feb 2014 19:42:09 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 34b8d4fb-73b1-428b-b1ab-660e31c1fb7d X-Archives-Hash: b4faa79e43191bf9737918d49353599d commit: f9473424cb810bc946ff5a63fcce1e9ebfa86bf9 Author: Sebastian Luther gmx de> AuthorDate: Mon Jan 27 23:00:49 2014 +0000 Commit: Sebastian Luther gmx de > CommitDate: Wed Feb 5 19:39:21 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f9473424 Some small output fixes for the slot conflict handler * unmatched atom printing now uses ^^ markers * unmatched atom printing properly supports sub-slots * Fix spurious "no parents" message caused by AtomArg parents --- pym/_emerge/resolver/slot_collision.py | 119 ++++++++++++++++++++++++++------- 1 file changed, 96 insertions(+), 23 deletions(-) diff --git a/pym/_emerge/resolver/slot_collision.py b/pym/_emerge/resolver/slot_collision.py index ca3fb74..c5936ad 100644 --- a/pym/_emerge/resolver/slot_collision.py +++ b/pym/_emerge/resolver/slot_collision.py @@ -1,4 +1,4 @@ -# Copyright 2010-2013 Gentoo Foundation +# Copyright 2010-2014 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function, unicode_literals @@ -273,12 +273,14 @@ class slot_conflict_handler(object): for ppkg, atom in parent_atoms: atom_set = InternalPackageSet(initial_atoms=(atom,)) atom_without_use_set = InternalPackageSet(initial_atoms=(atom.without_use,)) + atom_without_use_and_slot_set = InternalPackageSet(initial_atoms=( + atom.without_use.without_slot,)) for other_pkg in pkgs: if other_pkg == pkg: continue - if not atom_without_use_set.findAtomForPackage(other_pkg, \ + if not atom_without_use_and_slot_set.findAtomForPackage(other_pkg, \ modified_use=_pkg_use_enabled(other_pkg)): if atom.operator is not None: # The version range does not match. @@ -295,9 +297,11 @@ class slot_conflict_handler(object): atoms.add((ppkg, atom, other_pkg)) num_all_specific_atoms += 1 collision_reasons[key] = atoms - else: - # The sub_slot does not match. - key = ("sub-slot", atom.sub_slot) + + elif not atom_without_use_set.findAtomForPackage(other_pkg, \ + modified_use=_pkg_use_enabled(other_pkg)): + # The slot and/or sub_slot does not match. + key = ("slot", (atom.slot, atom.sub_slot, atom.slot_operator)) atoms = collision_reasons.get(key, set()) atoms.add((ppkg, atom, other_pkg)) num_all_specific_atoms += 1 @@ -342,6 +346,11 @@ class slot_conflict_handler(object): atoms.add((ppkg, atom, other_pkg)) collision_reasons[("use", flag)] = atoms num_all_specific_atoms += 1 + elif isinstance(ppkg, AtomArg) and other_pkg.installed: + parent_atoms = collision_reasons.get(("AtomArg", None), set()) + parent_atoms.add((ppkg, atom)) + collision_reasons[("AtomArg", None)] = parent_atoms + num_all_specific_atoms += 1 msg.append(" pulled in by\n") @@ -372,9 +381,11 @@ class slot_conflict_handler(object): if not verboseconflicts: selected_for_display.update( best_matches.values()) - elif type == "sub-slot": + elif type == "slot": for ppkg, atom, other_pkg in parents: selected_for_display.add((ppkg, atom)) + if not verboseconflicts: + break elif type == "use": #Prefer atoms with unconditional use deps over, because it's #not possible to change them on the parent, which means there @@ -416,21 +427,50 @@ class slot_conflict_handler(object): # If the list is long, people can simply # use a pager. selected_for_display.add((ppkg, atom)) + elif type == "AtomArg": + for ppkg, atom in parents: + selected_for_display.add((ppkg, atom)) - def highlight_violations(atom, version, use=[]): + def highlight_violations(atom, version, use, slot_violated): """Colorize parts of an atom""" atom_str = "%s" % (atom,) + colored_idx = set() if version: op = atom.operator ver = None if atom.cp != atom.cpv: ver = cpv_getversion(atom.cpv) slot = atom.slot + sub_slot = atom.sub_slot + slot_operator = atom.slot_operator if op == "=*": op = "=" ver += "*" + slot_str = "" + if slot: + slot_str = ":" + slot + if sub_slot: + slot_str += "/" + sub_slot + if slot_operator: + slot_str += slot_operator + + # Compute color_idx before adding the color codes + # as these change the indices of the letters. + if op is not None: + colored_idx.update(range(len(op))) + + if ver is not None: + start = atom_str.rfind(ver) + end = start + len(ver) + colored_idx.update(range(start, end)) + + if slot_str: + ii = atom_str.find(slot_str) + colored_idx.update(range(ii, ii + len(slot_str))) + + if op is not None: atom_str = atom_str.replace(op, colorize("BAD", op), 1) @@ -440,25 +480,48 @@ class slot_conflict_handler(object): atom_str = atom_str[:start] + \ colorize("BAD", ver) + \ atom_str[end:] + + if slot_str: + atom_str = atom_str.replace(slot_str, colorize("BAD", slot_str), 1) + + elif slot_violated: + slot = atom.slot + sub_slot = atom.sub_slot + slot_operator = atom.slot_operator + + slot_str = "" if slot: - atom_str = atom_str.replace(":" + slot, colorize("BAD", ":" + slot)) + slot_str = ":" + slot + if sub_slot: + slot_str += "/" + sub_slot + if slot_operator: + slot_str += slot_operator + + if slot_str: + ii = atom_str.find(slot_str) + colored_idx.update(range(ii, ii + len(slot_str))) + atom_str = atom_str.replace(slot_str, colorize("BAD", slot_str), 1) if use and atom.use.tokens: use_part_start = atom_str.find("[") use_part_end = atom_str.find("]") new_tokens = [] + # Compute start index in non-colored atom. + ii = str(atom).find("[") + 1 for token in atom.use.tokens: if token.lstrip("-!").rstrip("=?") in use: new_tokens.append(colorize("BAD", token)) + colored_idx.update(range(ii, ii + len(token))) else: new_tokens.append(token) + ii += 1 + len(token) atom_str = atom_str[:use_part_start] \ + "[%s]" % (",".join(new_tokens),) + \ atom_str[use_part_end+1:] - return atom_str + return atom_str, colored_idx # Show unconditional use deps first, since those # are more problematic than the conditional kind. @@ -469,37 +532,48 @@ class slot_conflict_handler(object): ordered_list.append(parent_atom) for parent_atom in ordered_list: parent, atom = parent_atom - msg.append(2*indent) - if isinstance(parent, - (PackageArg, AtomArg)): - # For PackageArg and AtomArg types, it's + if isinstance(parent, PackageArg): + # For PackageArg it's # redundant to display the atom attribute. - msg.append("%s" % (parent,)) + msg.append("%s\n" % (parent,)) + elif isinstance(parent, AtomArg): + msg.append("%s (Argument)\n" % (atom,)) else: # Display the specific atom from SetArg or # Package types. version_violated = False - sub_slot_violated = False + slot_violated = False use = [] for (type, sub_type), parents in collision_reasons.items(): for x in parents: if parent == x[0] and atom == x[1]: if type == "version": version_violated = True - elif type == "sub-slot": - sub_slot_violated = True + elif type == "slot": + slot_violated = True elif type == "use": use.append(sub_type) break - atom_str = highlight_violations(atom.unevaluated_atom, version_violated, use) + atom_str, colored_idx = highlight_violations(atom.unevaluated_atom, + version_violated, use, slot_violated) - if version_violated or sub_slot_violated: + if version_violated or slot_violated: self.is_a_version_conflict = True - msg.append("%s required by %s" % (atom_str, parent)) - msg.append("\n") - + cur_line = "%s required by %s\n" % (atom_str, parent) + marker_line = "" + for ii in range(len(cur_line)): + if ii in colored_idx: + marker_line += "^" + else: + marker_line += " " + marker_line += "\n" + msg.append(2*indent) + msg.append(cur_line) + msg.append(2*indent) + msg.append(marker_line) + if not selected_for_display: msg.append(2*indent) msg.append("(no parents that aren't satisfied by other packages in this slot)\n") @@ -519,7 +593,6 @@ class slot_conflict_handler(object): def get_explanation(self): msg = "" - _pkg_use_enabled = self.depgraph._pkg_use_enabled if self.is_a_version_conflict: return None