public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download: 
* [gentoo-portage-dev] [PATCH 04/10] Replace _slot_collision_info with _package_tracker
  @ 2014-01-29 15:33 99% ` Sebastian Luther
  0 siblings, 0 replies; 1+ results
From: Sebastian Luther @ 2014-01-29 15:33 UTC (permalink / raw
  To: gentoo-portage-dev

---
 pym/_emerge/depgraph.py                | 59 ++++++++++++----------------------
 pym/_emerge/resolver/slot_collision.py | 22 ++++++-------
 2 files changed, 31 insertions(+), 50 deletions(-)

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 9d234c2..484ac14 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -378,11 +378,6 @@ class _dynamic_depgraph_config(object):
 		# This use used to check if we have accounted for blockers
 		# relevant to a package.
 		self._traversed_pkg_deps = set()
-		# This should be ordered such that the backtracker will
-		# attempt to solve conflicts which occurred earlier first,
-		# since an earlier conflict can be the cause of a conflict
-		# which occurs later.
-		self._slot_collision_info = OrderedDict()
 		# Slot collision nodes are not allowed to block other packages since
 		# blocker validation is only able to account for one package per slot.
 		self._slot_collision_nodes = set()
@@ -915,7 +910,7 @@ class depgraph(object):
 		cases.
 		"""
 
-		if not self._dynamic_config._slot_collision_info:
+		if not any(self._dynamic_config._package_tracker.slot_conflicts()):
 			return
 
 		self._show_merge_list()
@@ -971,16 +966,18 @@ class depgraph(object):
 		is called, so that all relevant reverse dependencies are
 		available for use in backtracking decisions.
 		"""
-		for (slot_atom, root), slot_nodes in \
-			self._dynamic_config._slot_collision_info.items():
-			self._process_slot_conflict(root, slot_atom, slot_nodes)
+		for conflict in self._dynamic_config._package_tracker.slot_conflicts():
+			self._process_slot_conflict(conflict)
 
-	def _process_slot_conflict(self, root, slot_atom, slot_nodes):
+	def _process_slot_conflict(self, conflict):
 		"""
 		Process slot conflict data to identify specific atoms which
 		lead to conflict. These atoms only match a subset of the
 		packages that have been pulled into a given slot.
 		"""
+		root = conflict.root
+		slot_atom = conflict.atom
+		slot_nodes = conflict.pkgs
 
 		debug = "--debug" in self._frozen_config.myopts
 
@@ -1999,7 +1996,6 @@ class depgraph(object):
 
 			existing_node, existing_node_matches = \
 				self._check_slot_conflict(pkg, dep.atom)
-			slot_collision = False
 			if existing_node:
 				if existing_node_matches:
 					# The existing node can be reused.
@@ -2032,19 +2028,7 @@ class depgraph(object):
 							modified_use=self._pkg_use_enabled(existing_node))),
 							level=logging.DEBUG, noiselevel=-1)
 
-					slot_collision = True
-
-			if slot_collision:
-				# Now add this node to the graph so that self.display()
-				# can show use flags and --tree portage.output.  This node is
-				# only being partially added to the graph.  It must not be
-				# allowed to interfere with the other nodes that have been
-				# added.
-				# Even though the graph is now invalid, continue to process
-				# dependencies so that things like --fetchonly can still
-				# function despite collisions.
-				pass
-			elif not previously_added:
+			if not previously_added:
 				self._dynamic_config._package_tracker.add_pkg(pkg)
 				self._dynamic_config._filtered_trees[pkg.root]["porttree"].dbapi._clear_cache()
 				self._dynamic_config._highest_pkg_cache.clear()
@@ -2156,14 +2140,6 @@ class depgraph(object):
 
 	def _add_slot_conflict(self, pkg):
 		self._dynamic_config._slot_collision_nodes.add(pkg)
-		slot_key = (pkg.slot_atom, pkg.root)
-		slot_nodes = self._dynamic_config._slot_collision_info.get(slot_key)
-		if slot_nodes is None:
-			slot_nodes = set()
-			slot_nodes.update(self._dynamic_config._package_tracker.match(
-				pkg.root, pkg.slot_atom, installed=False))
-			self._dynamic_config._slot_collision_info[slot_key] = slot_nodes
-		slot_nodes.add(pkg)
 
 	def _add_pkg_deps(self, pkg, allow_unsatisfied=False):
 
@@ -3284,7 +3260,8 @@ class depgraph(object):
 		except self._unknown_internal_error:
 			return False, myfavorites
 
-		if (self._dynamic_config._slot_collision_info and
+		have_slot_conflict = any(self._dynamic_config._package_tracker.slot_conflicts())
+		if (have_slot_conflict and
 			not self._accept_blocker_conflicts()) or \
 			(self._dynamic_config._allow_backtracking and
 			"slot conflict" in self._dynamic_config._backtrack_infos):
@@ -6806,7 +6783,8 @@ class depgraph(object):
 			# conflicts (or by blind luck).
 			raise self._unknown_internal_error()
 
-		if self._dynamic_config._slot_collision_info and \
+		have_slot_conflict = any(self._dynamic_config._package_tracker.slot_conflicts())
+		if have_slot_conflict and \
 			not self._accept_blocker_conflicts():
 			self._dynamic_config._serialized_tasks_cache = retlist
 			self._dynamic_config._scheduler_graph = scheduler_graph
@@ -6881,13 +6859,17 @@ class depgraph(object):
 		# the reasons are not apparent from the normal merge list
 		# display.
 
-		slot_collision_info = self._dynamic_config._slot_collision_info
-
 		conflict_pkgs = {}
 		for blocker in blockers:
 			for pkg in chain(self._dynamic_config._blocked_pkgs.child_nodes(blocker), \
 				self._dynamic_config._blocker_parents.parent_nodes(blocker)):
-				if (pkg.slot_atom, pkg.root) in slot_collision_info:
+
+				is_slot_conflict_pkg = False
+				for conflict in self._dynamic_config._package_tracker.slot_conflicts():
+					if conflict.root == pkg.root and conflict.atom == pkg.slot_atom:
+						is_slot_conflict_pkg = True
+						break
+				if is_slot_conflict_pkg:
 					# The slot conflict display has better noise reduction
 					# than the unsatisfied blockers display, so skip
 					# unsatisfied blockers display for packages involved
@@ -7370,7 +7352,8 @@ class depgraph(object):
 				self._dynamic_config._circular_deps_for_display)
 
 		unresolved_conflicts = False
-		if self._dynamic_config._slot_collision_info:
+		have_slot_conflict = any(self._dynamic_config._package_tracker.slot_conflicts())
+		if have_slot_conflict:
 			unresolved_conflicts = True
 			self._show_slot_collision_notice()
 		if self._dynamic_config._unsatisfied_blockers_for_display is not None:
diff --git a/pym/_emerge/resolver/slot_collision.py b/pym/_emerge/resolver/slot_collision.py
index a193baa..ca3fb74 100644
--- a/pym/_emerge/resolver/slot_collision.py
+++ b/pym/_emerge/resolver/slot_collision.py
@@ -89,10 +89,11 @@ class slot_conflict_handler(object):
 		self.debug = "--debug" in self.myopts
 		if self.debug:
 			writemsg("Starting slot conflict handler\n", noiselevel=-1)
-		#slot_collision_info is a dict mapping (slot atom, root) to set
-		#of packages. The packages in the set all belong to the same
-		#slot.
-		self.slot_collision_info = depgraph._dynamic_config._slot_collision_info
+
+		# List of tuples, where each tuple represents a slot conflict.
+		self.all_conflicts = []
+		for conflict in depgraph._dynamic_config._package_tracker.slot_conflicts():
+			self.all_conflicts.append((conflict.root, conflict.atom, conflict.pkgs))
 		
 		#A dict mapping packages to pairs of parent package
 		#and parent atom
@@ -109,8 +110,7 @@ class slot_conflict_handler(object):
 		all_conflict_atoms_by_slotatom = []
 		
 		#fill conflict_pkgs, all_conflict_atoms_by_slotatom
-		for (atom, root), pkgs \
-			in self.slot_collision_info.items():
+		for root, atom, pkgs in self.all_conflicts:
 			conflict_pkgs.append(list(pkgs))
 			all_conflict_atoms_by_slotatom.append(set())
 			
@@ -249,8 +249,7 @@ class slot_conflict_handler(object):
 		msg.append("!!! into the dependency graph, resulting" + \
 			" in a slot conflict:\n\n")
 
-		for (slot_atom, root), pkgs \
-			in self.slot_collision_info.items():
+		for root, slot_atom, pkgs in self.all_conflicts:
 			msg.append("%s" % (slot_atom,))
 			if root != self.depgraph._frozen_config._running_root.root:
 				msg.append(" for %s" % (root,))
@@ -536,13 +535,13 @@ class slot_conflict_handler(object):
 			return None
 
 		if len(solutions)==1:
-			if len(self.slot_collision_info)==1:
+			if len(self.all_conflicts) == 1:
 				msg += "It might be possible to solve this slot collision\n"
 			else:
 				msg += "It might be possible to solve these slot collisions\n"
 			msg += "by applying all of the following changes:\n"
 		else:
-			if len(self.slot_collision_info)==1:
+			if len(self.all_conflicts) == 1:
 				msg += "It might be possible to solve this slot collision\n"
 			else:
 				msg += "It might be possible to solve these slot collisions\n"
@@ -583,8 +582,7 @@ class slot_conflict_handler(object):
 			if not pkg.installed:
 				continue
 
-			for (atom, root), pkgs \
-				in self.slot_collision_info.items():
+			for root, atom, pkgs in self.all_conflicts:
 				if pkg not in pkgs:
 					continue
 				for other_pkg in pkgs:
-- 
1.8.3.2



^ permalink raw reply related	[relevance 99%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2014-01-29 15:33     [gentoo-portage-dev] [PATCH 00/10] First steps to get rid of backtracking Sebastian Luther
2014-01-29 15:33 99% ` [gentoo-portage-dev] [PATCH 04/10] Replace _slot_collision_info with _package_tracker Sebastian Luther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox