public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] portage r15230 - in main/branches/2.1.7/pym/portage: . tests/versions
@ 2010-01-29 18:44 Zac Medico (zmedico)
  0 siblings, 0 replies; only message in thread
From: Zac Medico (zmedico) @ 2010-01-29 18:44 UTC (permalink / raw
  To: gentoo-commits

Author: zmedico
Date: 2010-01-29 18:44:47 +0000 (Fri, 29 Jan 2010)
New Revision: 15230

Modified:
   main/branches/2.1.7/pym/portage/tests/versions/test_vercmp.py
   main/branches/2.1.7/pym/portage/versions.py
Log:
Fix vercmp so 1b > 1 and add corresponding tests. (trunk r15162)

Modified: main/branches/2.1.7/pym/portage/tests/versions/test_vercmp.py
===================================================================
--- main/branches/2.1.7/pym/portage/tests/versions/test_vercmp.py	2010-01-29 18:44:31 UTC (rev 15229)
+++ main/branches/2.1.7/pym/portage/tests/versions/test_vercmp.py	2010-01-29 18:44:47 UTC (rev 15230)
@@ -18,6 +18,7 @@
 			("999999999999999999999999999999", "999999999999999999999999999998"),
 			("1.0.0", "1.0"),
 			("1.0b", "1.0.0"),
+			("1b", "1"),
 			("12.2b", "12.2.5"),
 		]
 		for test in tests:
@@ -37,6 +38,7 @@
 			("1.0", "1.0-r1"),
 			("1.0", "1.0.0"),
 			("1.0.0", "1.0b"),
+			("1", "1b"),
 			("12.2.5", "12.2b"),
 		]
 		for test in tests:
@@ -63,6 +65,7 @@
 			("1.0", "1.0-r1"),
 			("1.0-r1", "1.0"),
 			("1.0", "1.0.0"),
+			("1b", "1"),
 			("12.2b", "12.2"),
 		]
 		for test in tests:

Modified: main/branches/2.1.7/pym/portage/versions.py
===================================================================
--- main/branches/2.1.7/pym/portage/versions.py	2010-01-29 18:44:31 UTC (rev 15229)
+++ main/branches/2.1.7/pym/portage/versions.py	2010-01-29 18:44:47 UTC (rev 15230)
@@ -100,10 +100,14 @@
 	list2 = [int(match2.group(2))]
 
 	# this part would greatly benefit from a fixed-length version pattern
-	if len(match1.group(3)) or len(match2.group(3)):
+	if match1.group(3) or match2.group(3):
 		vlist1 = match1.group(3)[1:].split(".")
 		vlist2 = match2.group(3)[1:].split(".")
+	else:
+		vlist1 = []
+		vlist2 = []
 
+	if match1.group(5) or match2.group(5):
 		# and now the final letter
 		if match1.group(5):
 			vlist1.append(str(ord(match1.group(5))))
@@ -114,6 +118,8 @@
 		else:
 			vlist2.append('0')
 
+	if vlist1 or vlist2:
+
 		for i in range(0, max(len(vlist1), len(vlist2))):
 			# Implcit .0 is given a value of -1, so that 1.0.0 > 1.0, since it
 			# would be ambiguous if two versions that aren't literally equal




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-01-29 18:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-29 18:44 [gentoo-commits] portage r15230 - in main/branches/2.1.7/pym/portage: . tests/versions Zac Medico (zmedico)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox