Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r10027 - main/branches/2.1.2/bin
Date: Mon, 28 Apr 2008 20:31:16
Message-Id: E1Jqa0H-00018X-Bx@stork.gentoo.org
1 Author: zmedico
2 Date: 2008-04-28 20:31:12 +0000 (Mon, 28 Apr 2008)
3 New Revision: 10027
4
5 Modified:
6 main/branches/2.1.2/bin/emerge
7 Log:
8 Add a Package.pv_split attibute to optimize version comparison
9 operators. (trunk r10026)
10
11
12 Modified: main/branches/2.1.2/bin/emerge
13 ===================================================================
14 --- main/branches/2.1.2/bin/emerge 2008-04-28 20:29:04 UTC (rev 10026)
15 +++ main/branches/2.1.2/bin/emerge 2008-04-28 20:31:12 UTC (rev 10027)
16 @@ -1404,12 +1404,13 @@
17 class Package(Task):
18 __slots__ = ("built", "cpv", "depth",
19 "installed", "metadata", "root", "onlydeps", "type_name",
20 - "cp", "cpv_slot", "slot_atom")
21 + "cp", "cpv_slot", "pv_split", "slot_atom")
22 def __init__(self, **kwargs):
23 Task.__init__(self, **kwargs)
24 self.cp = portage.cpv_getkey(self.cpv)
25 self.slot_atom = "%s:%s" % (self.cp, self.metadata["SLOT"])
26 self.cpv_slot = "%s:%s" % (self.cpv, self.metadata["SLOT"])
27 + self.pv_split = portage.catpkgsplit(self.cpv)[1:]
28
29 def _get_hash_key(self):
30 hash_key = getattr(self, "_hash_key", None)
31 @@ -1422,38 +1423,30 @@
32 return self._hash_key
33
34 def __lt__(self, other):
35 - other_split = portage.catpkgsplit(other.cpv)
36 - self_split = portage.catpkgsplit(self.cpv)
37 - if other_split[:2] != self_split[:2]:
38 + if other.cp != self.cp:
39 return False
40 - if portage.pkgcmp(self_split[1:], other_split[1:]) < 0:
41 + if portage.pkgcmp(self.pv_split, other.pv_split) < 0:
42 return True
43 return False
44
45 def __le__(self, other):
46 - other_split = portage.catpkgsplit(other.cpv)
47 - self_split = portage.catpkgsplit(self.cpv)
48 - if other_split[:2] != self_split[:2]:
49 + if other.cp != self.cp:
50 return False
51 - if portage.pkgcmp(self_split[1:], other_split[1:]) <= 0:
52 + if portage.pkgcmp(self.pv_split, other.pv_split) <= 0:
53 return True
54 return False
55
56 def __gt__(self, other):
57 - other_split = portage.catpkgsplit(other.cpv)
58 - self_split = portage.catpkgsplit(self.cpv)
59 - if other_split[:2] != self_split[:2]:
60 + if other.cp != self.cp:
61 return False
62 - if portage.pkgcmp(self_split[1:], other_split[1:]) > 0:
63 + if portage.pkgcmp(self.pv_split, other.pv_split) > 0:
64 return True
65 return False
66
67 def __ge__(self, other):
68 - other_split = portage.catpkgsplit(other.cpv)
69 - self_split = portage.catpkgsplit(self.cpv)
70 - if other_split[:2] != self_split[:2]:
71 + if other.cp != self.cp:
72 return False
73 - if portage.pkgcmp(self_split[1:], other_split[1:]) >= 0:
74 + if portage.pkgcmp(self.pv_split, other.pv_split) >= 0:
75 return True
76 return False
77
78
79 --
80 gentoo-commits@l.g.o mailing list