~jelmer/bzr-commitfromnews/extractbugnumbers

« back to all changes in this revision

Viewing changes to committemplate.py

  • Committer: Jelmer Vernooij
  • Date: 2010-03-05 02:04:52 UTC
  • Revision ID: jelmer@samba.org-20100305020452-9ei3rloudv1xyy51
Initial work on extract bug numbers from NEWS.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from bzrlib.lazy_import import lazy_import
20
20
lazy_import(globals(), """
21
 
from bzrlib import osutils, patiencediff
 
21
from bzrlib import bugtracker, errors, osutils, patiencediff
22
22
""")
 
23
import re
 
24
 
 
25
_BUG_MATCH = re.compile(r'#(\d+)')
23
26
 
24
27
class CommitTemplate(object):
25
28
 
85
88
                if tag == 'delete':
86
89
                    continue
87
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
101
            return self.merge_message(''.join(new_lines))
89
102
 
90
103
    def merge_message(self, new_message):