Mercurial > hg > gut
comparison gut/main.py @ 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 | ef895ddba2d3 |
comparison
equal
deleted
inserted
replaced
3:4d38d14cf1d4 | 4:190ce22e7e83 |
---|---|
73 return | 73 return |
74 if not output: | 74 if not output: |
75 output = self.branch() + '.diff' | 75 output = self.branch() + '.diff' |
76 diff = diff['stdout'] | 76 diff = diff['stdout'] |
77 log = log['stdout'] | 77 log = log['stdout'] |
78 f = file(output) # write the output to a patch file | 78 |
79 # format the log | |
80 lines = [] | |
81 oldline = None | |
82 for line in log.splitlines(): | |
83 if not line: | |
84 continue | |
85 if line[0].strip(): | |
86 if oldline: | |
87 lines.append(oldline) | |
88 oldline = None | |
89 incomment = False | |
90 continue | |
91 line = line.strip() | |
92 if line.startswith('*'): | |
93 if oldline: | |
94 lines.append(oldline) | |
95 oldline = None | |
96 lines.append(line[1:].strip()) | |
97 continue | |
98 if oldline: | |
99 oldline = oldline + ' ' + line | |
100 else: | |
101 oldline = line | |
102 else: | |
103 if oldline: | |
104 lines.append(oldline) | |
105 log = '\n\n'.join(['* %s' % line for line in lines]) | |
106 | |
107 f = file(output, 'w') # write the output to a patch file | |
108 print >> f, diff | |
109 f.close() | |
79 return log | 110 return log |
80 | 111 |
81 def branch(self): | 112 def branch(self): |
82 """print what branch you're on""" | 113 """print what branch you're on""" |
83 output = call(['git', 'branch'], output=False, pipe=True) | 114 output = call(['git', 'branch'], output=False, pipe=True) |