From 694d76dcb5fa8226833b438bb1e069c55039fdf2 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Wed, 22 Jul 2009 17:35:55 +0000 Subject: [PATCH] Merged from trunk -r13839:13846 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit | 13840 | Use a lazy reference to sys.stdout, in case the API consumer | | zmedico | has temporarily overridden stdout. | | 13841 | Move mtimedb resume list code from action_build() to | | zmedico | Scheduler._save_resume_list(). | | 13842 | Skip Blocker instances inside _add_prefetchers(). | | zmedico | | | 13843 | Remove empty log files inside dblink.unmerge(). Thanks to | | zmedico | Diego Pettenò for reporting. | | 13844 | FEATURES=unmerge-logs Keep logs from successful unmerge | | zmedico | phases. This is relevant only when PORT_LOGDIR is set. | | | Thanks to Diego Pettenò for the | | | suggestion. | | 13845 | Always pass encodings='utf_8' to codecs.open(), since | | zmedico | otherwise it can return non-unicode strings (at least in | | | some cases, observed with python-2.6.2). Don't use unicode | | | in portage.util.getconfig() for now, since shlex doesn't | | | seem to support it (spurious \0 characters). If we use | | | unicode for config variables, it breaks shlex.split() calls | | | on those variables due to the same issue (spurious \0 | | | characters). | | 13846 | Add comment in calc_depclean() about topological sort | | zmedico | optimization that minimizes issues with implicit deps. | svn path=/main/branches/prefix/; revision=13848 --- bin/repoman | 6 ++++-- cnf/make.globals | 2 +- man/make.conf.5 | 4 ++++ pym/_emerge/JobStatusDisplay.py | 11 ++++++++--- pym/_emerge/Scheduler.py | 12 +++++++++++- pym/_emerge/actions.py | 11 ++--------- pym/portage/__init__.py | 4 ++-- pym/portage/dbapi/vartree.py | 22 ++++++++++++++++++++++ pym/portage/env/loaders.py | 2 +- pym/portage/output.py | 3 ++- pym/portage/util.py | 14 ++++++++------ 11 files changed, 65 insertions(+), 26 deletions(-) diff --git a/bin/repoman b/bin/repoman index e921a0fe5..933504808 100755 --- a/bin/repoman +++ b/bin/repoman @@ -590,7 +590,8 @@ for path in portdb.porttrees: desc_path = os.path.join(path, 'profiles', 'profiles.desc') try: - desc_file = codecs.open(desc_path, mode='r', errors='replace') + desc_file = codecs.open(desc_path, mode='r', + encoding='utf_8', errors='replace') except EnvironmentError: pass else: @@ -960,7 +961,8 @@ for x in scanlist: continue try: line = 1 - for l in codecs.open(checkdir+"/"+y, "r", "utf8"): + for l in codecs.open(os.path.join(checkdir, y), mode='r', + encoding='utf_8'): line +=1 except UnicodeDecodeError, ue: stats["file.UTF8"] += 1 diff --git a/cnf/make.globals b/cnf/make.globals index 66935ca8f..8c9faa56d 100644 --- a/cnf/make.globals +++ b/cnf/make.globals @@ -39,7 +39,7 @@ RESUMECOMMAND="@PORTAGE_WGET@ -c -t 5 -T 60 --passive-ftp -O \"\${DISTDIR}/\${FI # Default user options FEATURES="assume-digests distlocks fixpackages parallel-fetch protect-owned - sandbox sfperms strict unmerge-orphans userfetch" + sandbox sfperms strict unmerge-logs unmerge-orphans userfetch" # Ignore file collisions in /lib/modules since files inside this directory # are never unmerged, and therefore collisions must be ignored in order for diff --git a/man/make.conf.5 b/man/make.conf.5 index 2b5a7645f..229e50b3f 100644 --- a/man/make.conf.5 +++ b/man/make.conf.5 @@ -373,6 +373,10 @@ continue to execute the remaining phases as if the failure had not occurred. Note that the test phase for a specific package may be disabled by masking the "test" \fBUSE\fR flag in \fBpackage.use.mask\fR (see \fBportage\fR(5)). .TP +.B unmerge\-logs +Keep logs from successful unmerge phases. This is relevant only when +\fBPORT_LOGDIR\fR is set. +.TP .B unmerge\-orphans If a file is not claimed by another package in the same slot and it is not protected by \fICONFIG_PROTECT\fR, unmerge it even if the modification time or diff --git a/pym/_emerge/JobStatusDisplay.py b/pym/_emerge/JobStatusDisplay.py index 35dac62fb..63c91e314 100644 --- a/pym/_emerge/JobStatusDisplay.py +++ b/pym/_emerge/JobStatusDisplay.py @@ -46,8 +46,7 @@ class JobStatusDisplay(object): 'newline' : 'nel', } - def __init__(self, out=sys.stdout, quiet=False, xterm_titles=True): - object.__setattr__(self, "out", out) + def __init__(self, quiet=False, xterm_titles=True): object.__setattr__(self, "quiet", quiet) object.__setattr__(self, "xterm_titles", xterm_titles) object.__setattr__(self, "maxval", 0) @@ -58,7 +57,7 @@ class JobStatusDisplay(object): object.__setattr__(self, "width", 80) self.reset() - isatty = hasattr(out, "isatty") and out.isatty() + isatty = hasattr(self.out, "isatty") and self.out.isatty() object.__setattr__(self, "_isatty", isatty) if not isatty or not self._init_term(): term_codes = {} @@ -70,6 +69,12 @@ class JobStatusDisplay(object): if not isinstance(v, basestring): self._term_codes[k] = v.decode(encoding, 'replace') + @property + def out(self): + """Use a lazy reference to sys.stdout, in case the API consumer has + temporarily overridden stdout.""" + return sys.stdout + def _init_term(self): """ Initialize term control codes. diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index 79bbaebd6..ed054b5b5 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -639,7 +639,8 @@ class Scheduler(PollScheduler): # at the beginning, which annoy users, never # spawn a prefetcher for the first package. for pkg in self._mergelist[1:]: - if pkg.operation == "uninstall": + # mergelist can contain solved Blocker instances + if not isinstance(pkg, Package) or pkg.operation == "uninstall": continue prefetcher = self._create_prefetcher(pkg) if prefetcher is not None: @@ -1426,6 +1427,15 @@ class Scheduler(PollScheduler): a non-essential package with a broken digest. """ mtimedb = self._mtimedb + + mtimedb["resume"] = {} + # Stored as a dict starting with portage-2.1.6_rc1, and supported + # by >=portage-2.1.3_rc8. Versions =portage-2.1.3_rc8. Versions