From 39ae683a8f51662af9f6e781a7842d57a9c5c5a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fatih=20A=C5=9F=C4=B1c=C4=B1?= Date: Mon, 8 Mar 2010 12:09:37 +0000 Subject: [PATCH] Use make_version instead of Version class Also use int for release numbers. --- pisi/operations/build.py | 2 +- pisi/operations/upgrade.py | 14 +++++++++----- pisi/util.py | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/pisi/operations/build.py b/pisi/operations/build.py index ddbf0874..f1b5743c 100644 --- a/pisi/operations/build.py +++ b/pisi/operations/build.py @@ -589,7 +589,7 @@ class Builder: def check_versioning(self, version, release): try: int(release) - pisi.version.Version(version) + pisi.version.make_version(version) except (ValueError, InvalidVersionError): raise Error(_("%s-%s is not a valid PiSi version format") % (version, release)) diff --git a/pisi/operations/upgrade.py b/pisi/operations/upgrade.py index 9ebe9102..b954c0b6 100644 --- a/pisi/operations/upgrade.py +++ b/pisi/operations/upgrade.py @@ -67,10 +67,12 @@ def find_upgrades(packages, replaces): if not security_update: continue - if pkg.distribution == distro and pisi.version.Version(pkg.distributionRelease) > pisi.version.Version(distro_release): + if pkg.distribution == distro and \ + pisi.version.make_version(pkg.distributionRelease) > pisi.version.make_version(distro_release): Ap.append(i_pkg) + elif ignore_build or (not build) or (not pkg.build): - if pisi.version.Version(release) < pisi.version.Version(pkg.release): + if int(release) < int(pkg.release): Ap.append(i_pkg) else: ctx.ui.info(_('Package %s is already at the latest release %s.') @@ -308,13 +310,14 @@ def upgrade_base(A = set()): def is_upgradable(name, ignore_build = False): installdb = pisi.db.installdb.InstallDB() - packagedb = pisi.db.packagedb.PackageDB() if not installdb.has_package(name): return False (i_version, i_release, i_build, i_distro, i_distro_release) = installdb.get_version_and_distro_release(name) + packagedb = pisi.db.packagedb.PackageDB() + try: version, release, build, distro, distro_release = packagedb.get_version_and_distro_release(name, packagedb.which_repo(name)) except KeyboardInterrupt: @@ -322,9 +325,10 @@ def is_upgradable(name, ignore_build = False): except Exception: #FIXME: what exception could we catch here, replace with that. return False - if distro == i_distro and pisi.version.Version(distro_release) > pisi.version.Version(i_distro_release): + if distro == i_distro and \ + pisi.version.make_version(distro_release) > pisi.version.make_version(i_distro_release): return True elif ignore_build or (not i_build) or (not build): - return pisi.version.Version(i_release) < pisi.version.Version(release) + return int(i_release) < int(release) else: return i_build < build diff --git a/pisi/util.py b/pisi/util.py index 6dfc3bf9..a25d1655 100644 --- a/pisi/util.py +++ b/pisi/util.py @@ -661,8 +661,8 @@ def filter_latest_packages(package_paths): continue elif l_release == r_release: - l_version = pisi.version.Version(l_version) - r_version = pisi.version.Version(r_version) + l_version = pisi.version.make_version(l_version) + r_version = pisi.version.make_version(r_version) if l_version > r_version: continue