From: Zac Medico Date: Thu, 30 Apr 2009 06:49:33 +0000 (-0000) Subject: Add a cp_iter keyword argument to the MetadataRegen constructor, which can be X-Git-Tag: v2.1.6.12~140 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fa3e91b6804f4979e77a36a9ceaaf3bf2addfe3d;p=portage.git Add a cp_iter keyword argument to the MetadataRegen constructor, which can be used to do a regen for a subset of packages. TODO: Add support to cleanse cache for the specific cp values that are processed. (trunk r13254) svn path=/main/branches/2.1.6/; revision=13433 --- diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index eb90a769e..50e4f265b 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -11557,9 +11557,18 @@ class Scheduler(PollScheduler): class MetadataRegen(PollScheduler): - def __init__(self, portdb, max_jobs=None, max_load=None): + def __init__(self, portdb, cp_iter=None, max_jobs=None, max_load=None): PollScheduler.__init__(self) self._portdb = portdb + self._global_cleanse = False + if cp_iter is None: + cp_iter = self._iter_every_cp() + # We can globally cleanse stale cache only if we + # iterate over every single cp. TODO: Add support + # to cleanse cache for the specific cp values that + # are processed. + self._global_cleanse = True + self._cp_iter = cp_iter if max_jobs is None: max_jobs = 1 @@ -11576,14 +11585,20 @@ class MetadataRegen(PollScheduler): self.returncode = os.EX_OK self._error_count = 0 + def _iter_every_cp(self): + every_cp = self._portdb.cp_all() + every_cp.sort(reverse=True) + try: + while True: + yield every_cp.pop() + except IndexError: + pass + def _iter_metadata_processes(self): portdb = self._portdb valid_pkgs = self._valid_pkgs - every_cp = portdb.cp_all() - every_cp.sort(reverse=True) - while every_cp: - cp = every_cp.pop() + for cp in self._cp_iter: portage.writemsg_stdout("Processing %s\n" % cp) cpv_list = portdb.cp_list(cp) for cpv in cpv_list: @@ -11601,15 +11616,17 @@ class MetadataRegen(PollScheduler): from portage.cache.cache_errors import CacheError dead_nodes = {} - for mytree in portdb.porttrees: - try: - dead_nodes[mytree] = set(portdb.auxdb[mytree].iterkeys()) - except CacheError, e: - portage.writemsg("Error listing cache entries for " + \ - "'%s': %s, continuing...\n" % (mytree, e), noiselevel=-1) - del e - dead_nodes = None - break + if self._global_cleanse: + for mytree in portdb.porttrees: + try: + dead_nodes[mytree] = set(portdb.auxdb[mytree].iterkeys()) + except CacheError, e: + portage.writemsg("Error listing cache entries for " + \ + "'%s': %s, continuing...\n" % (mytree, e), + noiselevel=-1) + del e + dead_nodes = None + break while self._schedule(): self._poll_loop() @@ -11617,7 +11634,7 @@ class MetadataRegen(PollScheduler): while self._jobs: self._poll_loop() - if dead_nodes: + if self._global_cleanse and dead_nodes: for y in self._valid_pkgs: for mytree in portdb.porttrees: if portdb.findname2(y, mytree=mytree)[0]: