From: Zac Medico Date: Sun, 9 Jun 2013 00:22:50 +0000 (-0700) Subject: match_from_list: =* op with revision, bug #467826 X-Git-Tag: v2.2.0_alpha179~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=889e19d27ac978dbbc9699bac152657675569ebd;p=portage.git match_from_list: =* op with revision, bug #467826 --- diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py index 7776f8958..798903f11 100644 --- a/pym/portage/dep/__init__.py +++ b/pym/portage/dep/__init__.py @@ -2164,15 +2164,37 @@ def match_from_list(mydep, candidate_list): myver = mycpv_cps[2].lstrip("0") if not myver or not myver[0].isdigit(): myver = "0"+myver - mycpv_cmp = mycpv_cps[0] + "/" + mycpv_cps[1] + "-" + myver + if myver == mycpv_cps[2]: + mycpv_cmp = mycpv + else: + # Use replace to preserve the revision part if it exists + # (mycpv_cps[3] can't be trusted because in contains r0 + # even when the input has no revision part). + mycpv_cmp = mycpv.replace( + mydep.cp + "-" + mycpv_cps[2], + mydep.cp + "-" + myver, 1) for x in candidate_list: - xs = getattr(x, "cpv_split", None) - if xs is None: - xs = catpkgsplit(remove_slot(x)) + try: + x.cp + except AttributeError: + try: + pkg = _pkg_str(remove_slot(x)) + except InvalidData: + continue + else: + pkg = x + + xs = pkg.cpv_split myver = xs[2].lstrip("0") if not myver or not myver[0].isdigit(): myver = "0"+myver - xcpv = xs[0]+"/"+xs[1]+"-"+myver + if myver == xs[2]: + xcpv = pkg.cpv + else: + # Use replace to preserve the revision part if it exists. + xcpv = pkg.cpv.replace( + pkg.cp + "-" + xs[2], + pkg.cp + "-" + myver, 1) if xcpv.startswith(mycpv_cmp): mylist.append(x) diff --git a/pym/portage/tests/dep/test_match_from_list.py b/pym/portage/tests/dep/test_match_from_list.py index b64862447..8a1c9e22a 100644 --- a/pym/portage/tests/dep/test_match_from_list.py +++ b/pym/portage/tests/dep/test_match_from_list.py @@ -1,4 +1,4 @@ -# Copyright 2006-2012 Gentoo Foundation +# Copyright 2006-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import sys @@ -71,6 +71,11 @@ class Test_match_from_list(TestCase): (">sys-apps/portage-047", ["sys-apps/portage-046-r1"], []), ("sys-apps/portage:0", [Package("=sys-apps/portage-045:0")], ["sys-apps/portage-045"]), ("sys-apps/portage:0", [Package("=sys-apps/portage-045:1")], []), + ("=cat/pkg-1-r1*", ["cat/pkg-1_alpha1"], []), + ("=cat/pkg-1-r1*", ["cat/pkg-1-r11"], ["cat/pkg-1-r11"]), + ("=cat/pkg-1-r1*", ["cat/pkg-01-r11"], ["cat/pkg-01-r11"]), + ("=cat/pkg-01-r1*", ["cat/pkg-1-r11"], ["cat/pkg-1-r11"]), + ("=cat/pkg-01-r1*", ["cat/pkg-001-r11"], ["cat/pkg-001-r11"]), ("=sys-fs/udev-1*", ["sys-fs/udev-123"], ["sys-fs/udev-123"]), ("=sys-fs/udev-4*", ["sys-fs/udev-456"], ["sys-fs/udev-456"]), ("*/*", ["sys-fs/udev-456"], ["sys-fs/udev-456"]),