Preserve elog message continuity during updates.
authorZac Medico <zmedico@gentoo.org>
Thu, 7 Oct 2010 19:15:15 +0000 (12:15 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 7 Oct 2010 19:18:22 +0000 (12:18 -0700)
pym/portage/dbapi/vartree.py
pym/portage/elog/__init__.py
pym/portage/elog/messages.py

index afdb339cb33a02bd717589d517f27253fa244d6c..83e3be601c6e4b2d86b7a3fa04492b7284cc26e0 100644 (file)
@@ -1639,7 +1639,8 @@ class dblink(object):
                                                        self._eerror(ebuild_phase, msg_lines)
 
                                                # process logs created during pre/postrm
-                                               elog_process(self.mycpv, self.settings)
+                                               elog_process(self.mycpv, self.settings,
+                                                       phasefilter=('prerm', 'postrm'))
 
                                        if retval == os.EX_OK:
                                                # myebuildpath might be None, so ensure
index 6bb52d0656a7f0cdeb1e5800a351b516e0e9a8c9..082acff9adca800bf77ea6b85f4a54d54d095479 100644 (file)
@@ -107,7 +107,7 @@ def elog_process(cpv, mysettings, phasefilter=None):
                # A build dir isn't necessarily required since the messages.e*
                # functions allow messages to be generated in-memory.
                ebuild_logentries = {}
-       all_logentries = collect_messages(key=cpv)
+       all_logentries = collect_messages(key=cpv, phasefilter=phasefilter)
        if cpv in all_logentries:
                # Messages generated by the python elog implementation are assumed
                # to come first. For example, this ensures correct order for einfo
@@ -124,10 +124,6 @@ def elog_process(cpv, mysettings, phasefilter=None):
                        all_logentries[key] = _preserve_logentries[key]
                del _preserve_logentries[key]
 
-       if phasefilter != None:
-               for key in all_logentries:
-                       all_logentries[key], _preserve_logentries[key] = phasefilter(all_logentries[key])
-
        my_elog_classes = set(mysettings.get("PORTAGE_ELOG_CLASSES", "").split())
        logsystems = {}
        for token in mysettings.get("PORTAGE_ELOG_SYSTEM", "").split():
index bee0a7747699d846bd3e82035a0b0aca09c37e0e..a8a3e9a5f657b84b9f2f1e45b48fffb23d3a2cb7 100644 (file)
@@ -121,7 +121,7 @@ def _elog_base(level, msg, phase="other", key=None, color=None, out=None):
 
        #raise NotImplementedError()
 
-def collect_messages(key=None):
+def collect_messages(key=None, phasefilter=None):
        global _msgbuffer
 
        if key is None:
@@ -130,7 +130,17 @@ def collect_messages(key=None):
        else:
                rValue = {}
                if key in _msgbuffer:
-                       rValue[key] = _msgbuffer.pop(key)
+                       if phasefilter is None:
+                               rValue[key] = _msgbuffer.pop(key)
+                       else:
+                               rValue[key] = {}
+                               for phase in phasefilter:
+                                       try:
+                                               rValue[key][phase] = _msgbuffer[key].pop(phase)
+                                       except KeyError:
+                                               pass
+                               if not _msgbuffer[key]:
+                                       del _msgbuffer[key]
        return rValue
 
 def _reset_buffer():