root/releases/pkgcore/0.2.10/bzr_plugins/changelog.py @ ferringb%2540gmail.com-20070227170428-w85073rqyr9d2csn

Revision ferringb%2540gmail.com-20070227170428-w85073rqyr9d2csn, 1.5 KB (checked in by Brian Harring <ferringb@…>, 23 months ago)

skip "pull in history" commits, ie stuff that doesn't change any files

Line 
1import re
2
3from bzrlib.log import LogFormatter, register_formatter
4from bzrlib.osutils import format_date
5
6class 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
44register_formatter('pkgcore-changelog', MyLogFormatter)
Note: See TracBrowser for help on using the browser.