Merge lp:~soren/nova/changelog-format into lp:~hudson-openstack/nova/trunk

Proposed by Soren Hansen
Status: Merged
Approved by: Eric Day
Approved revision: 255
Merged at revision: 266
Proposed branch: lp:~soren/nova/changelog-format
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 82 lines (+63/-2)
2 files modified
bzrplugins/novalog/__init__.py (+59/-0)
setup.py (+4/-2)
To merge this branch: bzr merge lp:~soren/nova/changelog-format
Reviewer Review Type Date Requested Status
Eric Day (community) Approve
Devin Carlen (community) Approve
Review via email: mp+34236@code.launchpad.net

Description of the change

This improves the changelog generated as part of "setup.py sdist". If you look at it now, it says that Tarmac has done everything and every little commit is listed. With this patch, it only logs the "top-most" commit and credits the author rather than the committer.

Example from the current output format (from current trunk):
##########################################
2010-08-31 Tarmac

        Adjust setup.py to match nova-rsapi -> nova-api-new rename.

2010-08-31 Soren Hansen <email address hidden>

        Fix up setup.py to match nova-rsapi -> nova-api-new rename.

2010-08-30 Tarmac

        Reconnect to libvirt on broken connection.

2010-08-30 Soren Hansen <email address hidden>

        Detect if libvirt connection has been broken and reestablish it.

2010-08-30 Tarmac

        pylint fixes for /nova/virt/connection.py

2010-08-30 <email address hidden>

        Merge trunk and resolve conflicts

##########################################

With this patch, this is reduced to:

##########################################
2010-08-31 Soren Hansen <email address hidden>

        Adjust setup.py to match nova-rsapi -> nova-api-new rename.

2010-08-30 Soren Hansen <email address hidden>

        Reconnect to libvirt on broken connection.

2010-08-30 <email address hidden>

        pylint fixes for /nova/virt/connection.py

##########################################

To post a comment you must log in.
Revision history for this message
Devin Carlen (devcamcar) wrote :

lgtm

review: Approve
Revision history for this message
Eric Day (eday) wrote :

lgtm.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'bzrplugins'
2=== added directory 'bzrplugins/novalog'
3=== added file 'bzrplugins/novalog/__init__.py'
4--- bzrplugins/novalog/__init__.py 1970-01-01 00:00:00 +0000
5+++ bzrplugins/novalog/__init__.py 2010-08-31 19:24:44 +0000
6@@ -0,0 +1,59 @@
7+# Copyright 2010 OpenStack LLC
8+#
9+# Licensed under the Apache License, Version 2.0 (the "License"); you may
10+# not use this file except in compliance with the License. You may obtain
11+# a copy of the License at
12+#
13+# http://www.apache.org/licenses/LICENSE-2.0
14+#
15+# Unless required by applicable law or agreed to in writing, software
16+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+# License for the specific language governing permissions and limitations
19+# under the License.
20+
21+"""Log format for Nova's changelog."""
22+
23+import bzrlib.log
24+from bzrlib.osutils import format_date
25+
26+#
27+# This is mostly stolen from bzrlib.log.GnuChangelogLogFormatter
28+# The difference is that it logs the author rather than the committer
29+# which for Nova always is Tarmac.
30+#
31+class NovaLogFormat(bzrlib.log.GnuChangelogLogFormatter):
32+ preferred_levels = 1
33+ def log_revision(self, revision):
34+ """Log a revision, either merged or not."""
35+ to_file = self.to_file
36+
37+ date_str = format_date(revision.rev.timestamp,
38+ revision.rev.timezone or 0,
39+ self.show_timezone,
40+ date_fmt='%Y-%m-%d',
41+ show_offset=False)
42+
43+ authors = revision.rev.get_apparent_authors()
44+ to_file.write('%s %s\n\n' % (date_str, ", ".join(authors)))
45+
46+ if revision.delta is not None and revision.delta.has_changed():
47+ for c in revision.delta.added + revision.delta.removed + revision.delta.modified:
48+ path, = c[:1]
49+ to_file.write('\t* %s:\n' % (path,))
50+ for c in revision.delta.renamed:
51+ oldpath,newpath = c[:2]
52+ # For renamed files, show both the old and the new path
53+ to_file.write('\t* %s:\n\t* %s:\n' % (oldpath,newpath))
54+ to_file.write('\n')
55+
56+ if not revision.rev.message:
57+ to_file.write('\tNo commit message\n')
58+ else:
59+ message = revision.rev.message.rstrip('\r\n')
60+ for l in message.split('\n'):
61+ to_file.write('\t%s\n' % (l.lstrip(),))
62+ to_file.write('\n')
63+
64+bzrlib.log.register_formatter('novalog', NovaLogFormat)
65+
66
67=== modified file 'setup.py'
68--- setup.py 2010-08-31 07:54:31 +0000
69+++ setup.py 2010-08-31 19:24:44 +0000
70@@ -29,8 +29,10 @@
71 def run(self):
72 if os.path.isdir('.bzr'):
73 # We're in a bzr branch
74- log_cmd = subprocess.Popen(["bzr", "log", "--gnu"],
75- stdout=subprocess.PIPE)
76+ env = os.environ.copy()
77+ env['BZR_PLUGIN_PATH'] = os.path.abspath('./bzrplugins')
78+ log_cmd = subprocess.Popen(["bzr", "log", "--novalog"],
79+ stdout=subprocess.PIPE, env=env)
80 changelog = log_cmd.communicate()[0]
81 with open("ChangeLog", "w") as changelog_file:
82 changelog_file.write(changelog)