changeset 4:190ce22e7e83

scour the log and format it like a civilized human being
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 16 Jul 2010 16:18:06 -0700
parents 4d38d14cf1d4
children 0bfbd062765d
files gut/main.py
diffstat 1 files changed, 32 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/gut/main.py	Fri Jul 16 16:00:56 2010 -0700
+++ b/gut/main.py	Fri Jul 16 16:18:06 2010 -0700
@@ -75,7 +75,38 @@
             output = self.branch() + '.diff'
         diff = diff['stdout']
         log = log['stdout']
-        f = file(output) # write the output to a patch file
+
+        # format the log
+        lines = []
+        oldline = None
+        for line in log.splitlines():
+            if not line:
+                continue
+            if line[0].strip():
+                if oldline:
+                    lines.append(oldline)
+                    oldline = None
+                incomment = False
+                continue
+            line = line.strip()
+            if line.startswith('*'):
+                if oldline:
+                    lines.append(oldline)
+                    oldline = None
+                lines.append(line[1:].strip())
+                continue
+            if oldline:
+                oldline = oldline + ' ' + line
+            else:
+                oldline = line
+        else:
+            if oldline:
+                lines.append(oldline)
+        log = '\n\n'.join(['* %s' % line for line in lines])
+                
+        f = file(output, 'w') # write the output to a patch file
+        print >> f, diff
+        f.close()
         return log
 
     def branch(self):