From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org)
	by finch.gentoo.org with esmtp (Exim 4.60)
	(envelope-from <gentoo-commits+bounces-384331-garchives=archives.gentoo.org@lists.gentoo.org>)
	id 1R6t4t-00020g-OS
	for garchives@archives.gentoo.org; Thu, 22 Sep 2011 23:53:15 +0000
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id CAC92E0509;
	Thu, 22 Sep 2011 23:53:04 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	by pigeon.gentoo.org (Postfix) with ESMTP id 8E2C5E0509
	for <gentoo-commits@lists.gentoo.org>; Thu, 22 Sep 2011 23:53:04 +0000 (UTC)
Received: from pelican.gentoo.org (unknown [66.219.59.40])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 14E781B4015
	for <gentoo-commits@lists.gentoo.org>; Thu, 22 Sep 2011 23:53:04 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by pelican.gentoo.org (Postfix) with ESMTP id 390A480042
	for <gentoo-commits@lists.gentoo.org>; Thu, 22 Sep 2011 23:53:03 +0000 (UTC)
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" <zmedico@gentoo.org>
Message-ID: <c157d3b4ce32573263676c48659fd8fbe1cf122f.zmedico@gentoo>
Subject: [gentoo-commits] proj/portage:master commit in: bin/
X-VCS-Repository: proj/portage
X-VCS-Files: bin/portageq
X-VCS-Directories: bin/
X-VCS-Committer: zmedico
X-VCS-Committer-Name: Zac Medico
X-VCS-Revision: c157d3b4ce32573263676c48659fd8fbe1cf122f
Date: Thu, 22 Sep 2011 23:53:03 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: quoted-printable
X-Archives-Salt: 
X-Archives-Hash: f51338c3fcc01fad1588b4021cb13822

commit:     c157d3b4ce32573263676c48659fd8fbe1cf122f
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 22 23:52:47 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Sep 22 23:52:47 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a=
=3Dcommit;h=3Dc157d3b4

portageq best_visible: multi-repo support

This will fix bug #384063.

---
 bin/portageq |   46 ++++++++++++++++++++++++++++++++++------------
 1 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/bin/portageq b/bin/portageq
index 57a7c39..3ae29d1 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -48,6 +48,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
 	'_emerge.Package:Package',
 	'_emerge.RootConfig:RootConfig',
 	'portage.dbapi._expand_new_virt:expand_new_virt',
+	'portage._sets.base:InternalPackageSet',
 )
=20
 def eval_atom_use(atom):
@@ -462,19 +463,40 @@ def best_visible(argv):
 	root_config =3D RootConfig(portage.settings,
 		portage.db[portage.settings["ROOT"]], None)
=20
-	try:
+	if hasattr(db, "xmatch"):
+		cpv_list =3D db.xmatch("match-all", atom)
+	else:
+		cpv_list =3D db.match(atom)
+
+	if cpv_list:
 		# reversed, for descending order
-		for cpv in reversed(db.match(atom)):
-			metadata =3D dict(zip(Package.metadata_keys,
-				db.aux_get(cpv, Package.metadata_keys, myrepo=3Datom.repo)))
-			pkg =3D Package(built=3D(pkgtype !=3D "ebuild"), cpv=3Dcpv,
-				installed=3D(pkgtype=3D=3D"installed"), metadata=3Dmetadata,
-				root_config=3Droot_config, type_name=3Dpkgtype)
-			if pkg.visible:
-				writemsg_stdout("%s\n" % (pkg.cpv,), noiselevel=3D-1)
-				return os.EX_OK
-	except KeyError:
-		pass
+		cpv_list.reverse()
+		# verify match, since the atom may match the package
+		# for a given cpv from one repo but not another
+		atom_set =3D InternalPackageSet(initial_atoms=3D(atom,))
+
+		if atom.repo is None and hasattr(db, "getRepositories"):
+			repo_list =3D db.getRepositories()
+		else:
+			repo_list =3D [atom.repo]
+
+		for cpv in cpv_list:
+			for repo in repo_list:
+				try:
+					metadata =3D dict(zip(Package.metadata_keys,
+						db.aux_get(cpv, Package.metadata_keys, myrepo=3Drepo)))
+				except KeyError:
+					continue
+				pkg =3D Package(built=3D(pkgtype !=3D "ebuild"), cpv=3Dcpv,
+					installed=3D(pkgtype=3D=3D"installed"), metadata=3Dmetadata,
+					root_config=3Droot_config, type_name=3Dpkgtype)
+				if not atom_set.findAtomForPackage(pkg):
+					continue
+
+				if pkg.visible:
+					writemsg_stdout("%s\n" % (pkg.cpv,), noiselevel=3D-1)
+					return os.EX_OK
+
 	return 1
 best_visible.uses_root =3D True
=20