Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 147766 | Differences between
and this patch

Collapse All | Expand All

(-)portage.pdepend/bin/emerge (-58 / +54 lines)
Lines 1197-1235 Link Here
1197
		return 1
1197
		return 1
1198
1198
1199
1199
1200
	def altlist(self):
1200
	def altlist(self, reversed=False):
1201
		mygraph=self.digraph.copy()
1201
		mygraph=self.digraph.copy()
1202
		dolist=["/"]
1203
		retlist=[]
1202
		retlist=[]
1204
		for x in self.trees.keys():
1203
		while not mygraph.empty():
1205
			self.trees[x]["merge"] = []
1204
			if reversed:
1206
			if x not in dolist:
1205
				nodes = mygraph.root_nodes()
1207
				dolist.append(x)
1206
				if not nodes:
1208
		while (not mygraph.empty()):
1207
					nodes = mygraph.root_nodes(ignore_soft_deps=True)
1209
			mycurkey=mygraph.firstzero()
1208
				if nodes:
1210
			if not mycurkey:
1209
					next_node = nodes[-1]
1211
				installables = mygraph.leaf_nodes(ignore_soft_deps=True)
1210
				else:
1212
				if not installables:
1211
					next_node = None
1213
					print "!!! Error: circular dependencies:"
1212
			else:
1214
					print
1213
				nodes = mygraph.leaf_nodes()
1215
					for x in mygraph.allnodes():
1214
				if not nodes:
1216
						for y in mygraph.parent_nodes(x):
1215
					nodes = mygraph.leaf_nodes(ignore_soft_deps=True)
1217
							print y,"depends on",x
1216
				if nodes:
1218
						print
1217
					next_node = nodes[0]
1219
					sys.exit(1)
1218
				else:
1220
				mycurkey = installables[0]
1219
					next_node = None
1221
			splitski=string.split(mycurkey)
1220
			if not next_node:
1222
			#I'm not sure of the significance of the following lines (vestigal?) so I'm commenting 'em out.
1221
				print "!!! Error: circular dependencies:"
1223
			#These lines remove already-merged things from our alt-list
1222
				print
1224
			#if "--update" in myopts:
1223
				mygraph.debug_print()
1225
			#	if not portage.db["/"]["vartree"].exists_specific(splitski[2]):
1224
				sys.exit(1)
1226
			#		portage.db["/"]["merge"].append(splitski)
1225
			retlist.append(next_node.split())
1227
			#else:
1226
			mygraph.remove(next_node)
1228
			self.trees[splitski[1]]["merge"].append(splitski)
1229
			mygraph.delnode(mycurkey)
1230
		for x in dolist:
1231
			for y in self.trees[x]["merge"]:
1232
				retlist.append(y)
1233
		return retlist
1227
		return retlist
1234
1228
1235
	def xcreate(self,mode="system"):
1229
	def xcreate(self,mode="system"):
Lines 1394-1422 Link Here
1394
			overlays_real = [os.path.realpath(t) \
1388
			overlays_real = [os.path.realpath(t) \
1395
				for t in self.settings["PORTDIR_OVERLAY"].split()]
1389
				for t in self.settings["PORTDIR_OVERLAY"].split()]
1396
1390
1397
		if "--tree" in self.myopts:
1391
		tree_nodes = []
1398
			mylist.reverse()
1392
		node_depth = {}
1399
			mygraph=self.digraph.copy()
1400
1401
		i = 0
1393
		i = 0
1402
		while i < len(mylist):
1394
		depth = 0
1403
			if mylist[i][-1]=="nomerge":
1395
		for x in mylist:
1404
				if "--tree" not in self.myopts:
1396
			graph_key = " ".join(x)
1405
					# we don't care about this elements
1397
			if "--tree" in self.myopts:
1406
					mylist.pop(i)
1398
				depth = len(tree_nodes)
1407
					continue
1399
				while depth:
1408
				if (i == (len(mylist) - 1)) \
1400
					if graph_key in self.digraph.child_nodes(tree_nodes[depth-1]):
1409
				   or (mygraph.depth(string.join(mylist[i])) \
1401
						break
1410
				       >= mygraph.depth(string.join(mylist[i+1]))):
1402
					depth -= 1
1411
					# end of a useless branch (may be the last one)
1403
				tree_nodes = tree_nodes[:depth]
1412
					# -> delete the element and test the previous one
1404
				tree_nodes.append(graph_key)
1413
					mylist.pop(i)
1405
			node_depth[graph_key] = depth
1414
					if i > 0:
1406
1415
						i -= 1
1407
		last_merge_depth = 0
1416
					continue
1408
		for i in xrange(len(mylist)-1,-1,-1):
1417
			# the branch continues, or we've found a good element.
1409
			graph_key = " ".join(mylist[i])
1418
			# -> let's see what's next, if anything
1410
			if mylist[i][3] != "nomerge":
1419
			i += 1
1411
				last_merge_depth = node_depth[graph_key]
1412
				continue
1413
			if node_depth[graph_key] >= last_merge_depth or \
1414
					i != len(mylist)-1 and node_depth[graph_key] >= node_depth[" ".join(mylist[i+1])]:
1415
				del mylist[i]
1416
				del node_depth[graph_key]
1417
		del tree_nodes
1420
1418
1421
		display_overlays=False
1419
		display_overlays=False
1422
		# files to fetch list - avoids counting a same file twice
1420
		# files to fetch list - avoids counting a same file twice
Lines 1637-1645 Link Here
1637
				oldlp=mywidth-30
1635
				oldlp=mywidth-30
1638
				newlp=oldlp-30
1636
				newlp=oldlp-30
1639
1637
1640
				indent=""
1638
				indent=" "*node_depth[" ".join(x)]
1641
				if "--tree" in self.myopts:
1642
					indent=" "*mygraph.depth(string.join(x))
1643
1639
1644
				if myoldbest:
1640
				if myoldbest:
1645
					myoldbest=portage.pkgsplit(myoldbest)[1]+"-"+portage.pkgsplit(myoldbest)[2]
1641
					myoldbest=portage.pkgsplit(myoldbest)[1]+"-"+portage.pkgsplit(myoldbest)[2]
Lines 3514-3520 Link Here
3514
			mydepgraph.display(mymergelist)
3510
			mydepgraph.display(mymergelist)
3515
			prompt="Would you like to resume merging these packages?"
3511
			prompt="Would you like to resume merging these packages?"
3516
		else:
3512
		else:
3517
			mydepgraph.display(mydepgraph.altlist())
3513
			mydepgraph.display(mydepgraph.altlist(reversed=("--tree" in myopts)))
3518
			mergecount=0
3514
			mergecount=0
3519
			for x in mydepgraph.altlist():
3515
			for x in mydepgraph.altlist():
3520
				if x[3]!="nomerge":
3516
				if x[3]!="nomerge":
Lines 3558-3564 Link Here
3558
				sys.exit(0)
3554
				sys.exit(0)
3559
			mydepgraph.display(mymergelist)
3555
			mydepgraph.display(mymergelist)
3560
		else:
3556
		else:
3561
			mydepgraph.display(mydepgraph.altlist())
3557
			mydepgraph.display(mydepgraph.altlist(reversed=("--tree" in myopts)))
3562
	else:
3558
	else:
3563
		if ("--buildpkgonly" in myopts):
3559
		if ("--buildpkgonly" in myopts):
3564
			if not mydepgraph.digraph.hasallzeros():
3560
			if not mydepgraph.digraph.hasallzeros():
(-)portage.pdepend/pym/portage.py (-23 / +17 lines)
Lines 397-402 Link Here
397
				leaf_nodes.append(node)
397
				leaf_nodes.append(node)
398
		return leaf_nodes
398
		return leaf_nodes
399
399
400
	def root_nodes(self, ignore_soft_deps=False):
401
		"""Return all nodes that have no children
402
		
403
		If ignore_soft_deps is True, soft deps are not counted as
404
		children in calculations."""
405
		
406
		root_nodes = []
407
		for node in self.order:
408
			is_root_node = True
409
			for child in self.nodes[node][1]:
410
				if not (ignore_soft_deps and self.nodes[node][1][child]):
411
					is_root_node = False
412
					break
413
			if is_root_node:
414
				root_nodes.append(node)
415
		return root_nodes
416
400
	def is_empty(self):
417
	def is_empty(self):
401
		"""Checks if the digraph is empty"""
418
		"""Checks if the digraph is empty"""
402
		return len(self.nodes) == 0
419
		return len(self.nodes) == 0
Lines 430-458 Link Here
430
	def hasallzeros(self):
447
	def hasallzeros(self):
431
		return len(self.leaf_nodes() == 0)
448
		return len(self.leaf_nodes() == 0)
432
449
433
	def depth(self, node):
434
		"""Find how many nodes are in the parent chain of the passed node
435
		
436
		This method doesn't make sense unless there is no more than one
437
		parent for each node. As this digraph is capable of having multiple
438
		parents on a node, this implementation chooses an arbitrary parent
439
		for calculations, stopping as soon as a loop is detected in order
440
		to mimic the sorts of counts that would have previously been
441
		returned.
442
		
443
		This method is only used by emerge's --tree option. That option
444
		needs to be reworked to not use this so that this method can be
445
		removed altogether."""
446
		
447
		parents = {}
448
		while self.nodes[node][1]:
449
			parent = self.nodes[node][1].keys()[0]
450
			if parent in parents:
451
				break
452
			parents[parent] = True
453
			node = parent
454
		return len(parents)
455
	
456
	def debug_print(self):
450
	def debug_print(self):
457
		for node in self.nodes:
451
		for node in self.nodes:
458
			print node,
452
			print node,

Return to bug 147766