| 1 | import re |
|---|
| 2 | |
|---|
| 3 | from bzrlib.log import LogFormatter, register_formatter |
|---|
| 4 | from bzrlib.osutils import format_date |
|---|
| 5 | |
|---|
| 6 | class MyLogFormatter(LogFormatter): |
|---|
| 7 | |
|---|
| 8 | def __init__(self, *args, **kwargs): |
|---|
| 9 | LogFormatter.__init__(self, *args, **kwargs) |
|---|
| 10 | self._last_date = None |
|---|
| 11 | |
|---|
| 12 | def show(self, revno, rev, delta): |
|---|
| 13 | |
|---|
| 14 | # skip commits that just pulled history in. |
|---|
| 15 | if not (delta.renamed or delta.removed or delta.modified): |
|---|
| 16 | return |
|---|
| 17 | |
|---|
| 18 | to_file = self.to_file |
|---|
| 19 | rev_date = format_date(rev.timestamp, rev.timezone or 0, |
|---|
| 20 | self.show_timezone, date_fmt="%Y-%m-%d", |
|---|
| 21 | show_offset=False) |
|---|
| 22 | if rev_date != self._last_date: |
|---|
| 23 | if self._last_date is not None: |
|---|
| 24 | print >>to_file, '' |
|---|
| 25 | print >>to_file, '------------\n %s\n------------\n' % rev_date |
|---|
| 26 | self._last_date = rev_date |
|---|
| 27 | print >>to_file, "%s: %s" % (revno, self.short_committer(rev)) |
|---|
| 28 | if self.show_ids: |
|---|
| 29 | print >>to_file, 'revision-id:', rev.revision_id |
|---|
| 30 | |
|---|
| 31 | # TODO: Why not show the modified files in a shorter form as |
|---|
| 32 | # well? rewrap them single lines of appropriate length |
|---|
| 33 | if delta is not None: |
|---|
| 34 | delta.show(to_file, self.show_ids, short_status=True) |
|---|
| 35 | if not rev.message: |
|---|
| 36 | print >>to_file, '(no message)' |
|---|
| 37 | else: |
|---|
| 38 | message = rev.message.rstrip('\r\n') |
|---|
| 39 | for l in message.split('\n'): |
|---|
| 40 | print >>to_file, l |
|---|
| 41 | print >>to_file, '' |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | register_formatter('pkgcore-changelog', MyLogFormatter) |
|---|