From 08e4b487bfe1d5d04b197007e334129e3a47e72c Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Mon, 18 Nov 2013 15:08:15 +0100 Subject: [PATCH] [entropy.db] API change, handlePackage(forcedRevision -> revision) --- client/solo/commands/rescue.py | 2 +- lib/entropy/client/interfaces/db.py | 18 +++++++++--------- lib/entropy/client/interfaces/package.py | 2 +- lib/entropy/db/mysql.py | 4 ++-- lib/entropy/db/skel.py | 8 ++++---- lib/entropy/db/sql.py | 4 ++-- lib/entropy/db/sqlite.py | 2 +- lib/entropy/server/interfaces/db.py | 19 ++++++++++--------- 8 files changed, 30 insertions(+), 29 deletions(-) diff --git a/client/solo/commands/rescue.py b/client/solo/commands/rescue.py index f4a96909d..0c43ca921 100644 --- a/client/solo/commands/rescue.py +++ b/client/solo/commands/rescue.py @@ -783,7 +783,7 @@ Tools to rescue the running system. del data['original_repository'] new_package_id = inst_repo.handlePackage( - data, forcedRevision = data['revision']) + data, revision = data['revision']) inst_repo.storeInstalledPackage(new_package_id, etpConst['spmdbid']) diff --git a/lib/entropy/client/interfaces/db.py b/lib/entropy/client/interfaces/db.py index 323289602..87b38f8b5 100644 --- a/lib/entropy/client/interfaces/db.py +++ b/lib/entropy/client/interfaces/db.py @@ -134,8 +134,8 @@ class InstalledPackagesRepository(CachedRepository): const_setup_file(self._db, etpConst['entropygid'], 0o644, uid = etpConst['uid']) - def handlePackage(self, pkg_data, forcedRevision = -1, - formattedContent = False): + def handlePackage(self, pkg_data, revision = None, + formattedContent = False): """ Reimplemented from EntropyRepository. """ @@ -145,7 +145,7 @@ class InstalledPackagesRepository(CachedRepository): ) for r_package_id in removelist: self.removePackage(r_package_id) - return self.addPackage(pkg_data, revision = forcedRevision, + return self.addPackage(pkg_data, revision = revision, formatted_content = formattedContent) @@ -2712,8 +2712,8 @@ class AvailablePackagesRepository(CachedRepository, MaskableRepository): return AvailablePackagesRepositoryUpdater(TextInterface(), repository_id, False, False).remote_revision() - def handlePackage(self, pkg_data, forcedRevision = -1, - formattedContent = False): + def handlePackage(self, pkg_data, revision = None, + formattedContent = False): """ Reimplemented from EntropyRepository """ @@ -2752,8 +2752,8 @@ class GenericRepository(CachedRepository, MaskableRepository): in fail-safe mode. """ - def handlePackage(self, pkg_data, forcedRevision = -1, - formattedContent = False): + def handlePackage(self, pkg_data, revision = None, + formattedContent = False): """ Reimplemented from EntropyRepository. It is supposed that a generic repository should not support @@ -2766,8 +2766,8 @@ class GenericRepository(CachedRepository, MaskableRepository): raise PermissionDenied( "cannot execute handlePackage on this repository") - return self.addPackage(pkg_data, revision = forcedRevision, - formatted_content = formattedContent) + return self.addPackage(pkg_data, revision = revision, + formatted_content = formattedContent) def maskFilter(self, package_id, live = True): """ diff --git a/lib/entropy/client/interfaces/package.py b/lib/entropy/client/interfaces/package.py index 4dbbdbd17..a310e9a4f 100644 --- a/lib/entropy/client/interfaces/package.py +++ b/lib/entropy/client/interfaces/package.py @@ -2570,7 +2570,7 @@ class Package: data['content_safety'] = Package.FileContentSafetyReader( content_safety_file) idpackage = inst_repo.handlePackage( - data, forcedRevision = data['revision'], + data, revision = data['revision'], formattedContent = True) finally: if data['content'] is not None: diff --git a/lib/entropy/db/mysql.py b/lib/entropy/db/mysql.py index 490062551..82fe4d6c6 100644 --- a/lib/entropy/db/mysql.py +++ b/lib/entropy/db/mysql.py @@ -831,8 +831,8 @@ class EntropyMySQLRepository(EntropySQLRepository): REPLACE INTO counters SET counter = ? %s WHERE idpackage = ?""" % (branchstring,), insertdata) - def handlePackage(self, pkg_data, forcedRevision = -1, - formattedContent = False): + def handlePackage(self, pkg_data, revision = None, + formattedContent = False): """ Reimplemented from EntropySQLRepository. """ diff --git a/lib/entropy/db/skel.py b/lib/entropy/db/skel.py index d00b8ce59..d0788a0b1 100644 --- a/lib/entropy/db/skel.py +++ b/lib/entropy/db/skel.py @@ -668,8 +668,8 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore): return new_actions - def handlePackage(self, pkg_data, forcedRevision = -1, - formattedContent = False): + def handlePackage(self, pkg_data, revision = None, + formattedContent = False): """ Update or add a package to repository automatically handling its scope and thus removal of previous versions if requested by @@ -725,8 +725,8 @@ class EntropyRepositoryBase(TextInterface, EntropyRepositoryPluginStore): @param pkg_data: Entropy package metadata dict @type pkg_data: dict - @keyword forcedRevision: force a specific package revision - @type forcedRevision: int + @keyword revision: force a specific package revision + @type revision: int @keyword formattedContent: tells whether content metadata is already formatted for insertion @type formattedContent: bool diff --git a/lib/entropy/db/sql.py b/lib/entropy/db/sql.py index beb0ee7d8..0e014a9ed 100644 --- a/lib/entropy/db/sql.py +++ b/lib/entropy/db/sql.py @@ -1026,8 +1026,8 @@ class EntropySQLRepository(EntropyRepositoryBase): """ super(EntropySQLRepository, self).initializeRepository() - def handlePackage(self, pkg_data, forcedRevision = -1, - formattedContent = False): + def handlePackage(self, pkg_data, revision = None, + formattedContent = False): """ Reimplemented from EntropyRepositoryBase. Raises NotImplementedError. Subclasses have to reimplement this. diff --git a/lib/entropy/db/sqlite.py b/lib/entropy/db/sqlite.py index c47d41a30..e16087668 100644 --- a/lib/entropy/db/sqlite.py +++ b/lib/entropy/db/sqlite.py @@ -518,7 +518,7 @@ class EntropySQLiteRepository(EntropySQLRepository): self._clearLiveCache("_doesColumnInTableExist") super(EntropySQLiteRepository, self).initializeRepository() - def handlePackage(self, pkg_data, forcedRevision = -1, + def handlePackage(self, pkg_data, revision = None, formattedContent = False): """ Reimplemented from EntropySQLRepository. diff --git a/lib/entropy/server/interfaces/db.py b/lib/entropy/server/interfaces/db.py index 20485c73f..0b5560357 100644 --- a/lib/entropy/server/interfaces/db.py +++ b/lib/entropy/server/interfaces/db.py @@ -241,8 +241,8 @@ class ServerPackagesRepository(CachedRepository): return super(ServerPackagesRepository, self)._runConfigurationFilesUpdate( actions, files, protect_overwrite = False) - def handlePackage(self, pkg_data, forcedRevision = -1, - formattedContent = False): + def handlePackage(self, pkg_data, revision = None, + formattedContent = False): """ Reimplemented from EntropyRepository. """ @@ -252,24 +252,25 @@ class ServerPackagesRepository(CachedRepository): pkg_data['category'], pkg_data['name'], pkg_data['version'], pkg_data['versiontag']) - current_rev = forcedRevision + if revision is None: + current_rev = -1 + else: + current_rev = revision manual_deps = set() # Remove entries in the same scope. for package_id in self.getPackageIds(pkgatom): - if forcedRevision == -1: - myrev = self.retrieveRevision(package_id) - if myrev > current_rev: - current_rev = myrev + if revision is None: + pkg_revision = self.retrieveRevision(package_id) + current_rev = max(pkg_revision, current_rev) - # manual_deps |= self.retrieveManualDependencies(package_id, resolve_conditional_deps = False) # injected packages wouldn't be removed by addPackage self.removePackage(package_id) - if forcedRevision == -1: + if revision is None: current_rev += 1 # manual dependencies handling