From: Zac Medico Date: Tue, 8 Apr 2008 04:54:35 +0000 (-0000) Subject: Bug #197905 - Preserve order of ebuild messages even between different X-Git-Tag: v2.1.5~239 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c1bb5e536ded49fb6f799304f0d9ac7f6b4d1d90;p=portage.git Bug #197905 - Preserve order of ebuild messages even between different message types. (trunk r9726 and r9747) svn path=/main/branches/2.1.2/; revision=9748 --- diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index 08d1fcb0e..96594d8fe 100644 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -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 } diff --git a/pym/portage.py b/pym/portage.py index fecfec3dd..0cc187da1 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -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