Bug #197905 - Preserve order of ebuild messages even between different
authorZac Medico <zmedico@gentoo.org>
Tue, 8 Apr 2008 04:54:35 +0000 (04:54 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 8 Apr 2008 04:54:35 +0000 (04:54 -0000)
message types. (trunk r9726 and r9747)

svn path=/main/branches/2.1.2/; revision=9748

bin/isolated-functions.sh
pym/portage.py

index 08d1fcb0e7871f94fc7c4a6f6843956dbaedb80d..96594d8fef6fe110eeb13c0d7cfec3f4f7521760 100644 (file)
@@ -164,7 +164,7 @@ elog_base() {
                        return 1
                        ;;
        esac
-       echo -e "$*" >> "${T}/logging/${EBUILD_PHASE:-other}.${messagetype}"
+       echo -e "${messagetype} $*" >> "${T}/logging/${EBUILD_PHASE:-other}"
        return 0
 }
 
index fecfec3dd817a461fa3cd592a420b99178150b0a..0cc187da16d2f4b41c1f1ca4ea519c5345031f7d 100644 (file)
@@ -520,23 +520,40 @@ def elog_process(cpv, mysettings):
                except ImportError:
                        pass
 
-       mylogfiles = listdir(mysettings["T"]+"/logging/")
+       path = os.path.join(mysettings["T"], "logging")
+       mylogfiles = None
+       try:
+               mylogfiles = os.listdir(path)
+       except OSError:
+               pass
        # shortcut for packages without any messages
        if len(mylogfiles) == 0:
                return
        # exploit listdir() file order so we process log entries in chronological order
        mylogfiles.reverse()
        all_logentries = {}
-       for f in mylogfiles:
-               msgfunction, msgtype = f.split(".")
+       for msgfunction in mylogfiles:
                if msgfunction not in portage_const.EBUILD_PHASES:
                        writemsg("!!! can't process invalid log file: %s\n" % f,
                                noiselevel=-1)
                        continue
                if not msgfunction in all_logentries:
                        all_logentries[msgfunction] = []
-               msgcontent = open(mysettings["T"]+"/logging/"+f, "r").readlines()
-               all_logentries[msgfunction].append((msgtype, msgcontent))
+               lastmsgtype = None
+               msgcontent = []
+               for l in open(os.path.join(path, msgfunction), "r").readlines():
+                       msgtype, msg = l.split(" ", 1)
+                       if lastmsgtype is None:
+                               lastmsgtype = msgtype
+                       if msgtype == lastmsgtype:
+                               msgcontent.append(msg)
+                       else:
+                               if msgcontent:
+                                       all_logentries[msgfunction].append((lastmsgtype, msgcontent))
+                               msgcontent = [msg]
+                       lastmsgtype = msgtype
+               if msgcontent:
+                       all_logentries[msgfunction].append((lastmsgtype, msgcontent))
 
        def filter_loglevels(logentries, loglevels):
                # remove unwanted entries from all logentries