Merge lp:~jr/bzr-builddeb/changelog-closes-bugs into lp:bzr-builddeb

Proposed by Jonathan Riddell
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 563
Merged at revision: 565
Proposed branch: lp:~jr/bzr-builddeb/changelog-closes-bugs
Merge into: lp:bzr-builddeb
Diff against target: 124 lines (+49/-3)
4 files modified
__init__.py (+22/-0)
debian/changelog (+6/-1)
tests/test_commit_message.py (+20/-1)
util.py (+1/-1)
To merge this branch: bzr merge lp:~jr/bzr-builddeb/changelog-closes-bugs
Reviewer Review Type Date Requested Status
Jelmer Vernooij Needs Fixing
Review via email: mp+63248@code.launchpad.net

Description of the change

Uses the new hook added by https://code.launchpad.net/~jr/bzr/707274-commit-message-hook/+merge/62334 to set the changelog and mark bugs in debian/changelog as fixed in the branch

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

We generally try to avoid doing more imports than necessary in the __init__.py of plugins, as everything there gets imported every time bzr is started. "bzrlib.bugtracker" is usually not loaded on startup, so it would make sense to import it only in debian_changelog_commit when it is actually used.

commit.builder._revprops should be public if plugins have to touch it; this should probably be part of adding the set_commit_message hook.

Oh, and the really nitpicky bit.. PEP8 requires two empty lines around top-level things, so you need an extra newline above and an extra newline below debian_changelog_commit.

A basic test would be nice, even if just exercises debian_changelog_commit directly.

562. By Jonathan Riddell

fix parsing of LP: lines with multple entries

563. By Jonathan Riddell

actually this is fine

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

W00t. Two more minor style nitpics:

* The line with self.assertEqual looks over 80 characters.
* We usually stick to one single summary line in docstrings (debian_changelog_commit's docstring is longer)

review: Approve (code)
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Changing vote to needs fixing (but marking the MP as approved) - please fix these, but there's no need for another round of review.

review: Needs Fixing
564. By Jonathan Riddell

Add changelog entry

565. By Jonathan Riddell

over 80 characters in a line shocker

566. By Jonathan Riddell

tidy up doc string

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '__init__.py'
2--- __init__.py 2011-05-08 06:44:00 +0000
3+++ __init__.py 2011-06-03 14:44:26 +0000
4@@ -24,6 +24,7 @@
5 """bzr-builddeb - manage packages in a Bazaar branch."""
6
7 import os
8+import re
9
10 import bzrlib
11 from bzrlib.commands import plugin_cmds
12@@ -110,6 +111,21 @@
13 return "".join(changes)
14
15
16+def debian_changelog_commit(commit, start_message):
17+ """hooked into bzrlib.msgeditor set_commit_message.
18+ Set the commit message from debian/changelog and set any LP: #1234 to bug
19+ fixed tags."""
20+
21+ changes = debian_changelog_commit_message(commit, start_message)
22+ if changes is None:
23+ return None
24+
25+ bugs_fixed = util.find_bugs_fixed([changes], commit.work_tree.branch)
26+ commit.builder._revprops["bugs"] = "\n".join(bugs_fixed)
27+
28+ return debian_changelog_commit_message(commit, start_message)
29+
30+
31 def changelog_merge_hook_factory(merger):
32 from bzrlib.plugins.builddeb import merge_changelog
33 return merge_changelog.ChangeLogFileMerge(merger)
34@@ -170,6 +186,12 @@
35 debian_changelog_commit_message,
36 "Use changes documented in debian/changelog to suggest "
37 "the commit message")
38+ if bzrlib.version_info[0] >= 2 and bzrlib.version_info[1] >= 4:
39+ install_lazy_named_hook(
40+ "bzrlib.msgeditor", "hooks", "set_commit_message",
41+ debian_changelog_commit,
42+ "Use changes documented in debian/changelog to set "
43+ "the commit message and bugs fixed")
44 install_lazy_named_hook(
45 "bzrlib.merge", "Merger.hooks",
46 'merge_file_content', changelog_merge_hook_factory,
47
48=== modified file 'debian/changelog'
49--- debian/changelog 2011-05-08 15:45:59 +0000
50+++ debian/changelog 2011-06-03 14:44:26 +0000
51@@ -1,9 +1,14 @@
52 bzr-builddeb (2.7.5) UNRELEASED; urgency=low
53
54+ [ Jelmer Vernooij ]
55 * New 'bzr dep3-patch' subcommand that can generate DEP-3 compliant
56 patches. LP: #460576
57
58- -- Jelmer Vernooij <jelmer@debian.org> Sun, 08 May 2011 17:45:14 +0200
59+ [ Jonathan Riddell ]
60+ * Use new set_commit_message() hook in bzr to set the commit
61+ message from debian/changelog and set fixed bugs in tags
62+
63+ -- Jonathan Riddell <jriddell@ubuntu.com> Fri, 03 Jun 2011 15:36:10 +0100
64
65 bzr-builddeb (2.7.4) unstable; urgency=low
66
67
68=== modified file 'tests/test_commit_message.py'
69--- tests/test_commit_message.py 2009-02-21 20:07:43 +0000
70+++ tests/test_commit_message.py 2011-06-03 14:44:26 +0000
71@@ -19,16 +19,19 @@
72
73 from bzrlib.tests import TestCaseWithTransport
74
75-from bzrlib.plugins.builddeb import debian_changelog_commit_message
76+from bzrlib.plugins.builddeb import debian_changelog_commit_message, debian_changelog_commit
77
78
79 class CommitMessageTests(TestCaseWithTransport):
80
81 class _Commit(object):
82+ class _Builder(object):
83+ _revprops = {}
84 def __init__(self, work_tree, exclude=[], specific_files=[]):
85 self.work_tree = work_tree
86 self.exclude = exclude
87 self.specific_files = specific_files
88+ self.builder = self._Builder()
89
90 def set_changelog_content(self, content):
91 f = open("debian/changelog", 'wb')
92@@ -97,3 +100,19 @@
93 commit = self._Commit(wt)
94 self.assertEqual(debian_changelog_commit_message(commit, None),
95 "* two\n* changes\n")
96+
97+ def test_set_message_with_bugs(self):
98+ wt = self.make_branch_and_tree(".")
99+ self.build_tree(['a', 'debian/', 'debian/changelog'])
100+ wt.add(['debian/', 'debian/changelog'])
101+ wt.commit("one")
102+ self.set_changelog_content(" * fix LP: #1234\n * close LP: #4321\n")
103+ wt.add(['a'])
104+ wt.lock_read()
105+ self.addCleanup(wt.unlock)
106+ commit = self._Commit(wt)
107+ self.assertEqual(debian_changelog_commit(commit, None),
108+ "* fix LP: #1234\n* close LP: #4321\n")
109+ self.assertEqual(commit.builder._revprops,
110+ {'bugs': 'https://launchpad.net/bugs/1234 fixed\n'
111+ 'https://launchpad.net/bugs/4321 fixed'})
112
113=== modified file 'util.py'
114--- util.py 2011-04-08 18:47:10 +0000
115+++ util.py 2011-06-03 14:44:26 +0000
116@@ -396,7 +396,7 @@
117 def find_bugs_fixed(changes, branch, _lplib=None):
118 """Find the bugs marked fixed in a changelog entry.
119
120- :param changes: The contents of the changelog entry.
121+ :param changes: A list of the contents of the changelog entry.
122 :param branch: Bazaar branch associated with the package
123 :return: String with bugs closed, as appropriate for a Bazaar "bugs" revision
124 property.

Subscribers

People subscribed via source and target branches