View | Details | Raw Unified
Collapse All | Expand All

(-) portage.pdepend/bin/emerge (-58 / +54 lines)
 Lines 1197-1235    Link Here 
		return 1
		return 1
	def altlist(self):
	def altlist(self, reversed=False):
		mygraph=self.digraph.copy()
		mygraph=self.digraph.copy()
		dolist=["/"]
		retlist=[]
		retlist=[]
		for x in self.trees.keys():
		while not mygraph.empty():
			self.trees[x]["merge"] = []
			if reversed:
			if x not in dolist:
				nodes = mygraph.root_nodes()
				dolist.append(x)
				if not nodes:
		while (not mygraph.empty()):
					nodes = mygraph.root_nodes(ignore_soft_deps=True)
			mycurkey=mygraph.firstzero()
				if nodes:
			if not mycurkey:
					next_node = nodes[-1]
				installables = mygraph.leaf_nodes(ignore_soft_deps=True)
				else:
				if not installables:
					next_node = None
					print "!!! Error: circular dependencies:"
			else:
					print
				nodes = mygraph.leaf_nodes()
					for x in mygraph.allnodes():
				if not nodes:
						for y in mygraph.parent_nodes(x):
					nodes = mygraph.leaf_nodes(ignore_soft_deps=True)
							print y,"depends on",x
				if nodes:
						print
					next_node = nodes[0]
					sys.exit(1)
				else:
				mycurkey = installables[0]
					next_node = None
			splitski=string.split(mycurkey)
			if not next_node:
			#I'm not sure of the significance of the following lines (vestigal?) so I'm commenting 'em out.
				print "!!! Error: circular dependencies:"
			#These lines remove already-merged things from our alt-list
				print
			#if "--update" in myopts:
				mygraph.debug_print()
			#	if not portage.db["/"]["vartree"].exists_specific(splitski[2]):
				sys.exit(1)
			#		portage.db["/"]["merge"].append(splitski)
			retlist.append(next_node.split())
			#else:
			mygraph.remove(next_node)
			self.trees[splitski[1]]["merge"].append(splitski)
			mygraph.delnode(mycurkey)
		for x in dolist:
			for y in self.trees[x]["merge"]:
				retlist.append(y)
		return retlist
		return retlist
	def xcreate(self,mode="system"):
	def xcreate(self,mode="system"):
 Lines 1394-1422    Link Here 
			overlays_real = [os.path.realpath(t) \
			overlays_real = [os.path.realpath(t) \
				for t in self.settings["PORTDIR_OVERLAY"].split()]
				for t in self.settings["PORTDIR_OVERLAY"].split()]
		if "--tree" in self.myopts:
		tree_nodes = []
			mylist.reverse()
		node_depth = {}
			mygraph=self.digraph.copy()
		i = 0
		i = 0
		while i < len(mylist):
		depth = 0
			if mylist[i][-1]=="nomerge":
		for x in mylist:
				if "--tree" not in self.myopts:
			graph_key = " ".join(x)
					# we don't care about this elements
			if "--tree" in self.myopts:
					mylist.pop(i)
				depth = len(tree_nodes)
					continue
				while depth:
				if (i == (len(mylist) - 1)) \
					if graph_key in self.digraph.child_nodes(tree_nodes[depth-1]):
				   or (mygraph.depth(string.join(mylist[i])) \
						break
				       >= mygraph.depth(string.join(mylist[i+1]))):
					depth -= 1
					# end of a useless branch (may be the last one)
				tree_nodes = tree_nodes[:depth]
					# -> delete the element and test the previous one
				tree_nodes.append(graph_key)
					mylist.pop(i)
			node_depth[graph_key] = depth
					if i > 0:
						i -= 1
		last_merge_depth = 0
					continue
		for i in xrange(len(mylist)-1,-1,-1):
			# the branch continues, or we've found a good element.
			graph_key = " ".join(mylist[i])
			# -> let's see what's next, if anything
			if mylist[i][3] != "nomerge":
			i += 1
				last_merge_depth = node_depth[graph_key]
				continue
			if node_depth[graph_key] >= last_merge_depth or \
					i != len(mylist)-1 and node_depth[graph_key] >= node_depth[" ".join(mylist[i+1])]:
				del mylist[i]
				del node_depth[graph_key]
		del tree_nodes
		display_overlays=False
		display_overlays=False
		# files to fetch list - avoids counting a same file twice
		# files to fetch list - avoids counting a same file twice
 Lines 1637-1645    Link Here 
				oldlp=mywidth-30
				oldlp=mywidth-30
				newlp=oldlp-30
				newlp=oldlp-30
				indent=""
				indent=" "*node_depth[" ".join(x)]
				if "--tree" in self.myopts:
					indent=" "*mygraph.depth(string.join(x))
				if myoldbest:
				if myoldbest:
					myoldbest=portage.pkgsplit(myoldbest)[1]+"-"+portage.pkgsplit(myoldbest)[2]
					myoldbest=portage.pkgsplit(myoldbest)[1]+"-"+portage.pkgsplit(myoldbest)[2]
 Lines 3514-3520    Link Here 
			mydepgraph.display(mymergelist)
			mydepgraph.display(mymergelist)
			prompt="Would you like to resume merging these packages?"
			prompt="Would you like to resume merging these packages?"
		else:
		else:
			mydepgraph.display(mydepgraph.altlist())
			mydepgraph.display(mydepgraph.altlist(reversed=("--tree" in myopts)))
			mergecount=0
			mergecount=0
			for x in mydepgraph.altlist():
			for x in mydepgraph.altlist():
				if x[3]!="nomerge":
				if x[3]!="nomerge":
 Lines 3558-3564    Link Here 
				sys.exit(0)
				sys.exit(0)
			mydepgraph.display(mymergelist)
			mydepgraph.display(mymergelist)
		else:
		else:
			mydepgraph.display(mydepgraph.altlist())
			mydepgraph.display(mydepgraph.altlist(reversed=("--tree" in myopts)))
	else:
	else:
		if ("--buildpkgonly" in myopts):
		if ("--buildpkgonly" in myopts):
			if not mydepgraph.digraph.hasallzeros():
			if not mydepgraph.digraph.hasallzeros():
(-) portage.pdepend/pym/portage.py (-23 / +17 lines)
 Lines 397-402    Link Here 
				leaf_nodes.append(node)
				leaf_nodes.append(node)
		return leaf_nodes
		return leaf_nodes
	def root_nodes(self, ignore_soft_deps=False):
		"""Return all nodes that have no children
		
		If ignore_soft_deps is True, soft deps are not counted as
		children in calculations."""
		
		root_nodes = []
		for node in self.order:
			is_root_node = True
			for child in self.nodes[node][1]:
				if not (ignore_soft_deps and self.nodes[node][1][child]):
					is_root_node = False
					break
			if is_root_node:
				root_nodes.append(node)
		return root_nodes
	def is_empty(self):
	def is_empty(self):
		"""Checks if the digraph is empty"""
		"""Checks if the digraph is empty"""
		return len(self.nodes) == 0
		return len(self.nodes) == 0
 Lines 430-458    Link Here 
	def hasallzeros(self):
	def hasallzeros(self):
		return len(self.leaf_nodes() == 0)
		return len(self.leaf_nodes() == 0)
	def depth(self, node):
		"""Find how many nodes are in the parent chain of the passed node
		
		This method doesn't make sense unless there is no more than one
		parent for each node. As this digraph is capable of having multiple
		parents on a node, this implementation chooses an arbitrary parent
		for calculations, stopping as soon as a loop is detected in order
		to mimic the sorts of counts that would have previously been
		returned.
		
		This method is only used by emerge's --tree option. That option
		needs to be reworked to not use this so that this method can be
		removed altogether."""
		
		parents = {}
		while self.nodes[node][1]:
			parent = self.nodes[node][1].keys()[0]
			if parent in parents:
				break
			parents[parent] = True
			node = parent
		return len(parents)
	
	def debug_print(self):
	def debug_print(self):
		for node in self.nodes:
		for node in self.nodes:
			print node,
			print node,