From 4eefede7c6b231fff67dd0c63ca62f223112a4b5 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Tue, 12 May 2009 14:14:02 +0200 Subject: [PATCH] entropy.Client: rework calculate_world_updates when using ignore-spm-downgrades So we have several nasty issues when using ignore-spm-downgrades here. First of all, calculate_world_updates should get the setting directly from SystemSettings instead of bugging developer asking for it. Secondly, calculate_world_updates should return a 4D tuple, also containing the matches ignored when ignore-spm-downgrades is enabled. Moreover, Spritz packages.py getPackageItem featured an unused argument, which has been dropped. I know this commit is a bitch because we are talking about changing API and affecting several files at once. --- libraries/entropy/client/interfaces/cache.py | 17 ++++++++++---- libraries/entropy/client/interfaces/dep.py | 24 +++++++++----------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/libraries/entropy/client/interfaces/cache.py b/libraries/entropy/client/interfaces/cache.py index 772bc3510..684de5d6f 100644 --- a/libraries/entropy/client/interfaces/cache.py +++ b/libraries/entropy/client/interfaces/cache.py @@ -86,8 +86,8 @@ class CacheMixin: # we can barely ignore any exception from here # especially cases where client db does not exist try: - update, remove, fine = self.calculate_world_updates() - del fine, remove + update, remove, fine, spm_fine = self.calculate_world_updates() + del fine, spm_fine, remove if do_install_queue: self.get_install_queue(update, False, False) self.calculate_available_packages() @@ -174,18 +174,25 @@ class CacheMixin: return self.Cacher.pop("%s%s" % (etpCache['world_available'],myhash)) def get_world_update_cache(self, empty_deps, branch = None, - db_digest = None, ignore_spm_downgrades = False): + db_digest = None): if branch == None: branch = self.SystemSettings['repositories']['branch'] + + sys_settings_plg_id = \ + etpConst['system_settings_plugins_ids']['client_plugin'] + misc_settings = self.SystemSettings[sys_settings_plg_id]['misc'] + ignore_spm_downgrades = misc_settings['ignore_spm_downgrades'] if self.xcache: if db_digest == None: db_digest = self.all_repositories_checksum() c_hash = "%s%s" % (etpCache['world_update'], - self.get_world_update_cache_hash(db_digest, empty_deps, branch, ignore_spm_downgrades),) + self.get_world_update_cache_hash(db_digest, empty_deps, branch, + ignore_spm_downgrades),) disk_cache = self.Cacher.pop(c_hash) if disk_cache != None: try: - return disk_cache['r'] + if len(disk_cache['r']) == 4: + return disk_cache['r'] except (KeyError, TypeError): return None diff --git a/libraries/entropy/client/interfaces/dep.py b/libraries/entropy/client/interfaces/dep.py index 1b30c1028..89653382e 100644 --- a/libraries/entropy/client/interfaces/dep.py +++ b/libraries/entropy/client/interfaces/dep.py @@ -1233,27 +1233,21 @@ class CalculatorsMixin: return available def calculate_world_updates(self, empty_deps = False, branch = None, - ignore_spm_downgrades = None, use_cache = True): + use_cache = True): if branch == None: branch = self.SystemSettings['repositories']['branch'] - if ignore_spm_downgrades == None: - sys_set_plg_id = \ - etpConst['system_settings_plugins_ids']['client_plugin'] - client_sys_settings = self.SystemSettings[sys_set_plg_id]['misc'] - ignore_spm_downgrades = client_sys_settings['ignore_spm_downgrades'] - db_digest = self.all_repositories_checksum() if use_cache and self.xcache: cached = self.get_world_update_cache(empty_deps = empty_deps, - branch = branch, db_digest = db_digest, - ignore_spm_downgrades = ignore_spm_downgrades) + branch = branch, db_digest = db_digest) if cached != None: return cached update = [] remove = [] fine = [] + spm_fine = [] # get all the installed packages idpackages = self.clientDbconn.listAllIdpackages(order_by = 'atom') @@ -1323,6 +1317,8 @@ class CalculatorsMixin: if cl_revision == 9999 and ignore_spm_downgrades: # no difference, we're ignoring revision 9999 fine.append(cl_atom) + if (m_idpackage,repoid) not in update: + spm_fine.append((m_idpackage,repoid)) continue else: if (m_idpackage,repoid) not in update: @@ -1361,13 +1357,13 @@ class CalculatorsMixin: c_hash = self.get_world_update_cache_hash(db_digest, empty_deps, branch, ignore_spm_downgrades) data = { - 'r': (update, remove, fine,), + 'r': (update, remove, fine, spm_fine,), 'empty_deps': empty_deps, } self.Cacher.push("%s%s" % (etpCache['world_update'],c_hash,), data, async = False) - return update, remove, fine + return update, remove, fine, spm_fine def check_package_update(self, atom, deep = False): @@ -1409,7 +1405,8 @@ class CalculatorsMixin: def get_world_queue(self, empty_deps = False, branch = None): if branch == None: branch = self.SystemSettings['repositories']['branch'] - update, remove, fine = self.calculate_world_updates(empty_deps = empty_deps, branch = branch) + update, remove, fine, spm_fine = self.calculate_world_updates( + empty_deps = empty_deps, branch = branch) del fine data = {} data['removed'] = list(remove) @@ -1418,7 +1415,8 @@ class CalculatorsMixin: status = -1 if update: # calculate install+removal queues - install, removal, status = self.get_install_queue(update, empty_deps, deep_deps = False) + install, removal, status = self.get_install_queue( + update, empty_deps, deep_deps = False) # update data['removed'] data['removed'] = [x for x in data['removed'] if x not in removal] data['runQueue'] += install