Merge lp:~jelmer/bzr-commitfromnews/extractbugnumbers into lp:bzr-commitfromnews

Proposed by Jelmer Vernooij
Status: Merged
Merged at revision: 3
Proposed branch: lp:~jelmer/bzr-commitfromnews/extractbugnumbers
Merge into: lp:bzr-commitfromnews
Diff against target: 158 lines (+72/-27)
2 files modified
committemplate.py (+14/-1)
tests/test_committemplate.py (+58/-26)
To merge this branch: bzr merge lp:~jelmer/bzr-commitfromnews/extractbugnumbers
Reviewer Review Type Date Requested Status
Robert Collins Pending
Review via email: mp+84953@code.launchpad.net

This proposal supersedes a proposal from 2010-03-30.

Description of the change

Initial work on setting revision properties based on information in NEWS.

Now updated to use "lp:BUGNO" rather than "#BUGNO"

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote : Posted in a previous version of this proposal

 review: needsfixing

This is looking pretty good. Uhm, I don't like #1234 being picked up -
lets look for lp:1234 - that way we don't have any confusion about what
bug tracker. And yes, I think that that will matter a great deal.

You can introspect bzr's bugs module to get a list of prefixes that can
be looked for sensibly, pretty easily.

Cheers,
Rob

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

Updated. This now uses lp:1234 to talk about Launchpad bug numbers. It wasn't quite as easy to handle other bug trackers too, so I've kept it Launchpad-specific for now, but adding support for the other bug trackers should be possible without changing the behaviour for lp-specific bugs.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'committemplate.py'
--- committemplate.py 2010-02-27 12:38:57 +0000
+++ committemplate.py 2011-12-08 13:57:23 +0000
@@ -18,8 +18,11 @@
1818
19from bzrlib.lazy_import import lazy_import19from bzrlib.lazy_import import lazy_import
20lazy_import(globals(), """20lazy_import(globals(), """
21from bzrlib import osutils, patiencediff21from bzrlib import bugtracker, errors, osutils, patiencediff
22""")22""")
23import re
24
25_BUG_MATCH = re.compile(r'lp:(\d+)')
2326
24class CommitTemplate(object):27class CommitTemplate(object):
2528
@@ -85,6 +88,16 @@
85 if tag == 'delete':88 if tag == 'delete':
86 continue89 continue
87 new_lines.extend(new[j1:j2])90 new_lines.extend(new[j1:j2])
91 if not self.commit.revprops.get('bugs'):
92 # TODO: Allow the user to configure the bug tracker to use
93 # rather than hardcoding Launchpad.
94 bt = bugtracker.tracker_registry.get('launchpad')
95 bugids = []
96 for line in new_lines:
97 bugids.extend(_BUG_MATCH.findall(line))
98 self.commit.revprops['bugs'] = \
99 bugtracker.encode_fixes_bug_urls(
100 [bt.get_bug_url(bugid) for bugid in bugids])
88 return self.merge_message(''.join(new_lines))101 return self.merge_message(''.join(new_lines))
89102
90 def merge_message(self, new_message):103 def merge_message(self, new_message):
91104
=== modified file 'tests/test_committemplate.py'
--- tests/test_committemplate.py 2010-02-27 12:17:25 +0000
+++ tests/test_committemplate.py 2011-12-08 13:57:23 +0000
@@ -20,9 +20,25 @@
20from bzrlib import msgeditor20from bzrlib import msgeditor
21from bzrlib.tests import TestCaseWithTransport21from bzrlib.tests import TestCaseWithTransport
2222
23INITIAL_NEWS_CONTENT = """----------------------------
24commitfromnews release notes
25----------------------------
26
27NEXT (In development)
28---------------------
29
30IMPROVEMENTS
31~~~~~~~~~~~~
32
33* Created plugin, basic functionality of looking for NEWS and including the
34 NEWS diff.
35"""
36
37
23class TestCommitTemplate(TestCaseWithTransport):38class TestCommitTemplate(TestCaseWithTransport):
2439
25 def capture_template(self, commit, message):40 def capture_template(self, commit, message):
41 self.commits.append(commit)
26 self.messages.append(message)42 self.messages.append(message)
27 if message is None:43 if message is None:
28 message = 'let this commit succeed I command thee.'44 message = 'let this commit succeed I command thee.'
@@ -33,6 +49,7 @@
33 msgeditor.hooks.install_named_hook('commit_message_template',49 msgeditor.hooks.install_named_hook('commit_message_template',
34 self.capture_template, 'commitfromnews test template')50 self.capture_template, 'commitfromnews test template')
35 self.messages = []51 self.messages = []
52 self.commits = []
3653
37 def test_initial(self):54 def test_initial(self):
38 self.setup_capture()55 self.setup_capture()
@@ -50,19 +67,7 @@
50 self.setup_capture()67 self.setup_capture()
51 builder = self.make_branch_builder('test')68 builder = self.make_branch_builder('test')
52 builder.start_series()69 builder.start_series()
53 content = """----------------------------70 content = INITIAL_NEWS_CONTENT
54commitfromnews release notes
55----------------------------
56
57NEXT (In development)
58---------------------
59
60IMPROVEMENTS
61~~~~~~~~~~~~
62
63* Created plugin, basic functionality of looking for NEWS and including the
64 NEWS diff.
65"""
66 builder.build_snapshot('BASE-id', None,71 builder.build_snapshot('BASE-id', None,
67 [('add', ('', None, 'directory', None)),72 [('add', ('', None, 'directory', None)),
68 ('add', ('NEWS', 'foo-id', 'file', content)),73 ('add', ('NEWS', 'foo-id', 'file', content)),
@@ -75,19 +80,7 @@
75 self.setup_capture()80 self.setup_capture()
76 builder = self.make_branch_builder('test')81 builder = self.make_branch_builder('test')
77 builder.start_series()82 builder.start_series()
78 orig_content = """----------------------------83 orig_content = INITIAL_NEWS_CONTENT
79commitfromnews release notes
80----------------------------
81
82NEXT (In development)
83---------------------
84
85IMPROVEMENTS
86~~~~~~~~~~~~
87
88* Created plugin, basic functionality of looking for NEWS and including the
89 NEWS diff.
90"""
91 mod_content = """----------------------------84 mod_content = """----------------------------
92commitfromnews release notes85commitfromnews release notes
93----------------------------86----------------------------
@@ -117,5 +110,44 @@
117 builder.finish_series()110 builder.finish_series()
118 self.assertEqual([change_content], self.messages)111 self.assertEqual([change_content], self.messages)
119112
113 def test_fix_bug(self):
114 self.setup_capture()
115 builder = self.make_branch_builder('test')
116 builder.start_series()
117 orig_content = INITIAL_NEWS_CONTENT
118 mod_content = """----------------------------
119commitfromnews release notes
120----------------------------
121
122NEXT (In development)
123---------------------
124
125IMPROVEMENTS
126~~~~~~~~~~~~
127
128* Created plugin, basic functionality of looking for NEWS and including the
129 NEWS diff.
130
131* Fixed a horrible bug. (lp:523423)
132
133"""
134 change_content = """
135* Fixed a horrible bug. (lp:523423)
136
137"""
138 builder.build_snapshot('BASE-id', None,
139 [('add', ('', None, 'directory', None)),
140 ('add', ('NEWS', 'foo-id', 'file', orig_content)),
141 ])
142 builder.build_snapshot(None, None,
143 [('modify', ('foo-id', mod_content)),
144 ],
145 message_callback=msgeditor.generate_commit_message_template)
146 builder.finish_series()
147 self.assertEqual([change_content], self.messages)
148 self.assertEqual(1, len(self.commits))
149 self.assertEquals('https://launchpad.net/bugs/523423 fixed',
150 self.commits[0].revprops['bugs'])
151
120 def _todo_test_passes_messages_through(self):152 def _todo_test_passes_messages_through(self):
121 pass153 pass

Subscribers

People subscribed via source and target branches