# Validate counters and timestamps.
slot_counters = {}
- root = self.root
+ root_config = self._pkg_root_config
validation_keys = ["COUNTER", "_mtime_"]
for cpv in current_cpv_set:
- pkg_hash_key = ("installed", root, cpv, "nomerge")
+ pkg_hash_key = Package._gen_hash_key(cpv=cpv,
+ installed=True, root_config=root_config,
+ type_name="installed")
pkg = pkg_vardb.get(pkg_hash_key)
if pkg is not None:
counter, mtime = real_vardb.aux_get(cpv, validation_keys)
else:
self.operation = "merge"
- self._hash_key = \
- (self.type_name, self.root, self.cpv, self.operation)
+ self._hash_key = Package._gen_hash_key(cpv=self.cpv,
+ installed=self.installed, onlydeps=self.onlydeps,
+ operation=self.operation,
+ root_config=self.root_config,
+ type_name=self.type_name)
self._hash_value = hash(self._hash_key)
+ @classmethod
+ def _gen_hash_key(cls, cpv=None, installed=None, onlydeps=None,
+ operation=None, repo_name=None, root_config=None,
+ type_name=None, **kwargs):
+
+ if operation is None:
+ if installed or onlydeps:
+ operation = "nomerge"
+ else:
+ operation = "merge"
+
+ root = None
+ if root_config is not None:
+ root = root_config.root
+ else:
+ raise TypeError("root_config argument is required")
+
+ return (type_name, root, cpv, operation)
+
def _validate_deps(self):
"""
Validate deps. This does not trigger USE calculation since that
failures for some reason (package does not exist or is
corrupt).
"""
- if operation is None:
- if installed:
- operation = "nomerge"
- else:
- operation = "merge"
# Reuse existing instance when available.
- pkg = self._pkg_cache.get(
- (type_name, root_config.root, cpv, operation))
+ pkg = self._pkg_cache.get(Package._gen_hash_key(cpv=cpv,
+ type_name=type_name, root_config=root_config,
+ installed=installed, operation=operation))
+
if pkg is not None:
return pkg
failures for some reason (package does not exist or is
corrupt).
"""
- operation = "merge"
- if installed or onlydeps:
- operation = "nomerge"
+
# Ensure that we use the specially optimized RootConfig instance
# that refers to FakeVartree instead of the real vartree.
root_config = self._frozen_config.roots[root_config.root]
pkg = self._frozen_config._pkg_cache.get(
- (type_name, root_config.root, cpv, operation))
+ Package._gen_hash_key(cpv=cpv, type_name=type_name,
+ root_config=root_config,
+ installed=installed, onlydeps=onlydeps))
if pkg is None and onlydeps and not installed:
# Maybe it already got pulled in as a "merge" node.
pkg = self._dynamic_config.mydbapi[root_config.root].get(
- (type_name, root_config.root, cpv, 'merge'))
+ Package._gen_hash_key(cpv=cpv, type_name=type_name,
+ root_config=root_config,
+ installed=installed, onlydeps=False))
if pkg is None:
tree_type = self.pkg_tree_map[type_name]