aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndré Erdmann <dywi@mailerd.de>2013-07-17 19:58:11 +0200
committerAndré Erdmann <dywi@mailerd.de>2013-07-17 20:00:00 +0200
commita01c5b354610331bdd684aa3632a1f692a44d6cb (patch)
treee4c05a67ad9fdcd6c4a0669b2f8eb0e4e9d3e6dd
parentroverlay/interface: in-code documentation (diff)
downloadR_overlay-a01c5b354610331bdd684aa3632a1f692a44d6cb.tar.gz
R_overlay-a01c5b354610331bdd684aa3632a1f692a44d6cb.tar.bz2
R_overlay-a01c5b354610331bdd684aa3632a1f692a44d6cb.zip
fix versiontuple (again)
The le/lt/ge/gt comparision functions were completely wrong, which caused selfdep validation to misbehave. Checking "(0,97) <= (1,1,2)" always returned False (but 0 < 1!), whereas "(1,1,2) >= (0,97)" returned False, too (which is be correct, but "neither less nor greater nor equal" makes no sense at all). In a second (incremental) run, all comparisions would then evaluate to true, because PackageInfo created normal tuples for scanned ebuilds, for which IntVersionTuple returns NotImplemented (when comparing). And bool( NotImplemented ) <=> True, so even IntVersionTuple(1,1) was "less than" tuple(0,0). This commit fixes this issue.
-rw-r--r--roverlay/packageinfo.py9
-rw-r--r--roverlay/versiontuple.py52
2 files changed, 45 insertions, 16 deletions
diff --git a/roverlay/packageinfo.py b/roverlay/packageinfo.py
index 0224d6c..feee360 100644
--- a/roverlay/packageinfo.py
+++ b/roverlay/packageinfo.py
@@ -108,7 +108,7 @@ class PackageInfo ( object ):
'has_suggests',
))
_UPDATE_KEYS_SIMPLE_INITIAL = frozenset ((
- 'package_filename',
+ 'package_filename', 'name',
))
_UPDATE_KEYS_FILTER_NONE = frozenset ((
'src_uri_base',
@@ -810,9 +810,10 @@ class PackageInfo ( object ):
)
)
# non-digit chars in pv are unsupported, too
-
- self._info ['version'] = tuple ( int ( z ) for z in pv.split ( '.' ) )
- self._info ['rev'] = int ( pr_str ) if pr_str else 0
+ self._info ['version'] = roverlay.versiontuple.IntVersionTuple (
+ int ( z ) for z in pv.split ( '.' )
+ )
+ self._info ['rev'] = int ( pr_str ) if pr_str else 0
self._info ['ebuild_verstr'] = pvr
# --- end of _use_pvr (...) ---
diff --git a/roverlay/versiontuple.py b/roverlay/versiontuple.py
index 0ca902a..20d5cf8 100644
--- a/roverlay/versiontuple.py
+++ b/roverlay/versiontuple.py
@@ -166,36 +166,64 @@ class IntVersionTuple ( VersionTuple ):
def __le__ ( self, other ):
if isinstance ( other, self.__class__ ):
- return all ( a <= b
- for a, b in _zip_longest ( self, other, fillvalue=0 )
- )
+ #
+ # ( k0, k1, ..., kN ) x ( l0, l1, ..., lN )
+ #
+ # from left to right (high to low)
+ # if k_j < l_j
+ # return True (k <= j)
+ # elif k_j == l_j
+ # continue with next
+ # else
+ # return False (k > j)
+ #
+ # return True if last pair was equal
+ for a, b in _zip_longest ( self, other, fillvalue=0 ):
+ if a < b:
+ return True
+ elif a > b:
+ return False
+ else:
+ return True
else:
return NotImplemented
# --- end of __le__ (...) ---
def __ge__ ( self, other ):
if isinstance ( other, self.__class__ ):
- return all ( a >= b
- for a, b in _zip_longest ( self, other, fillvalue=0 )
- )
+ for a, b in _zip_longest ( self, other, fillvalue=0 ):
+ if a > b:
+ return True
+ elif a < b:
+ return False
+ else:
+ return True
else:
return NotImplemented
# --- end of __ge__ (...) ---
def __lt__ ( self, other ):
if isinstance ( other, self.__class__ ):
- return all ( a < b
- for a, b in _zip_longest ( self, other, fillvalue=0 )
- )
+ for a, b in _zip_longest ( self, other, fillvalue=0 ):
+ if a < b:
+ return True
+ elif a > b:
+ return False
+ else:
+ return False
else:
return NotImplemented
# --- end of __lt__ (...) ---
def __gt__ ( self, other ):
if isinstance ( other, self.__class__ ):
- return all ( a > b
- for a, b in _zip_longest ( self, other, fillvalue=0 )
- )
+ for a, b in _zip_longest ( self, other, fillvalue=0 ):
+ if a > b:
+ return True
+ elif a < b:
+ return False
+ else:
+ return False
else:
return NotImplemented
# --- end of __gt__ (...) ---