/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
4763.2.4 by John Arbash Meinel
merge bzr.2.1 in preparation for NEWS entry.
1
# Copyright (C) 2007-2010 Canonical Ltd
2376.4.4 by jml at canonical
Beginnings of generic bug-tracker plugin system.
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2376.4.4 by jml at canonical
Beginnings of generic bug-tracker plugin system.
16
6379.6.1 by Jelmer Vernooij
Import absolute_import in a few places.
17
from __future__ import absolute_import
18
6729.4.1 by Jelmer Vernooij
Move bugtracker errors to breezy.bugtracker.
19
from . import (
20
    errors,
21
    registry,
22
    )
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
23
from .lazy_import import lazy_import
2376.4.6 by jml at canonical
Basic docstrings for bugtracker.py
24
lazy_import(globals(), """
6729.4.1 by Jelmer Vernooij
Move bugtracker errors to breezy.bugtracker.
25
from breezy import urlutils
2376.4.6 by jml at canonical
Basic docstrings for bugtracker.py
26
""")
2376.4.4 by jml at canonical
Beginnings of generic bug-tracker plugin system.
27
28
2376.4.7 by jml at canonical
- Add docstrings to tests.
29
"""Provides a shorthand for referring to bugs on a variety of bug trackers.
30
31
'commit --fixes' stores references to bugs as a <bug_url> -> <bug_status>
32
mapping in the properties for that revision.
33
34
However, it's inconvenient to type out full URLs for bugs on the command line,
35
particularly given that many users will be using only a single bug tracker per
36
branch.
37
38
Thus, this module provides a registry of types of bug tracker (e.g. Launchpad,
2376.4.23 by Jonathan Lange
Change 'tag' to 'abbreviated_tracker_name'
39
Trac). Given an abbreviated name (e.g. 'lp', 'twisted') and a branch with
2376.4.7 by jml at canonical
- Add docstrings to tests.
40
configuration information, these tracker types can return an instance capable
41
of converting bug IDs into URLs.
42
"""
43
44
3053.8.1 by Ian Clatworthy
Improve bug tracker integration documentation (Ian Clatworthy)
45
_bugs_help = \
46
"""When making a commit, metadata about bugs fixed by that change can be
4927.2.6 by Ian Clatworthy
Nicer formatting of bug tracking topic
47
recorded by using the ``--fixes`` option. For each bug marked as fixed, an
3053.8.1 by Ian Clatworthy
Improve bug tracker integration documentation (Ian Clatworthy)
48
entry is included in the 'bugs' revision property stating '<url> <status>'.
3154.1.1 by Ian Clatworthy
Minor tweaks to bug tracker integration documentation
49
(The only ``status`` value currently supported is ``fixed.``)
3535.10.2 by James Westby
Flesh out the bugs help topic and explain the simple things first.
50
4927.2.6 by Ian Clatworthy
Nicer formatting of bug tracking topic
51
The ``--fixes`` option allows you to specify a bug tracker and a bug identifier
52
rather than a full URL. This looks like::
3535.10.2 by James Westby
Flesh out the bugs help topic and explain the simple things first.
53
3535.10.3 by James Westby
Talk about "trackers" rather than "tags" as it may be less confusing.
54
    bzr commit --fixes <tracker>:<id>
3535.10.2 by James Westby
Flesh out the bugs help topic and explain the simple things first.
55
6120.1.2 by Jelmer Vernooij
Doc doc doc.
56
or::
57
58
    bzr commit --fixes <id>
59
3535.10.3 by James Westby
Talk about "trackers" rather than "tags" as it may be less confusing.
60
where "<tracker>" is an identifier for the bug tracker, and "<id>" is the
3535.10.2 by James Westby
Flesh out the bugs help topic and explain the simple things first.
61
identifier for that bug within the bugtracker, usually the bug number.
6120.1.2 by Jelmer Vernooij
Doc doc doc.
62
If "<tracker>" is not specified the ``bugtracker`` set in the branch
63
or global configuration is used.
3535.10.2 by James Westby
Flesh out the bugs help topic and explain the simple things first.
64
3535.10.5 by James Westby
Don't say "well-known" as suggested by Robert.
65
Bazaar knows about a few bug trackers that have many users. If
3535.10.2 by James Westby
Flesh out the bugs help topic and explain the simple things first.
66
you use one of these bug trackers then there is no setup required to
3535.10.3 by James Westby
Talk about "trackers" rather than "tags" as it may be less confusing.
67
use this feature, you just need to know the tracker identifier to use.
68
These are the bugtrackers that are built in:
69
4927.2.6 by Ian Clatworthy
Nicer formatting of bug tracking topic
70
  ============================ ============ ============
71
  URL                          Abbreviation Example
72
  ============================ ============ ============
73
  https://bugs.launchpad.net/  lp           lp:12345
74
  http://bugs.debian.org/      deb          deb:12345
75
  http://bugzilla.gnome.org/   gnome        gnome:12345
76
  ============================ ============ ============
3535.10.2 by James Westby
Flesh out the bugs help topic and explain the simple things first.
77
3535.10.5 by James Westby
Don't say "well-known" as suggested by Robert.
78
For the bug trackers not listed above configuration is required.
79
Support for generating the URLs for any project using Bugzilla or Trac
80
is built in, along with a template mechanism for other bugtrackers with
3535.10.6 by James Westby
Mention that the a plugin can support their tracker as the last resort.
81
simple URL schemes. If your bug tracker can't be described by one
82
of the schemes described below then you can write a plugin to support
83
it.
3535.10.2 by James Westby
Flesh out the bugs help topic and explain the simple things first.
84
3053.8.1 by Ian Clatworthy
Improve bug tracker integration documentation (Ian Clatworthy)
85
If you use Bugzilla or Trac, then you only need to set a configuration
86
variable which contains the base URL of the bug tracker. These options
6740.1.1 by Jelmer Vernooij
Rename bazaar.conf to breezy.conf.
87
can go into ``breezy.conf``, ``branch.conf`` or into a branch-specific
3053.8.1 by Ian Clatworthy
Improve bug tracker integration documentation (Ian Clatworthy)
88
configuration section in ``locations.conf``.  You can set up these values
89
for each of the projects you work on.
90
91
Note: As you provide a short name for each tracker, you can specify one or
92
more bugs in one or more trackers at commit time if you wish.
93
3860.2.1 by Martin Pool
Mention in 'help bugs' the syntax for Launchpad
94
Launchpad
95
---------
96
97
Use ``bzr commit --fixes lp:2`` to record that this commit fixes bug 2.
98
4927.2.6 by Ian Clatworthy
Nicer formatting of bug tracking topic
99
bugzilla_<tracker>_url
100
----------------------
3053.8.1 by Ian Clatworthy
Improve bug tracker integration documentation (Ian Clatworthy)
101
102
If present, the location of the Bugzilla bug tracker referred to by
4927.2.6 by Ian Clatworthy
Nicer formatting of bug tracking topic
103
<tracker>. This option can then be used together with ``bzr commit
3053.8.1 by Ian Clatworthy
Improve bug tracker integration documentation (Ian Clatworthy)
104
--fixes`` to mark bugs in that tracker as being fixed by that commit. For
105
example::
106
5444.1.1 by Martin Pool
Updated URL for Squid bugzilla
107
    bugzilla_squid_url = http://bugs.squid-cache.org
3053.8.1 by Ian Clatworthy
Improve bug tracker integration documentation (Ian Clatworthy)
108
109
would allow ``bzr commit --fixes squid:1234`` to mark Squid's bug 1234 as
110
fixed.
111
4927.2.6 by Ian Clatworthy
Nicer formatting of bug tracking topic
112
trac_<tracker>_url
113
------------------
3053.8.1 by Ian Clatworthy
Improve bug tracker integration documentation (Ian Clatworthy)
114
115
If present, the location of the Trac instance referred to by
4927.2.6 by Ian Clatworthy
Nicer formatting of bug tracking topic
116
<tracker>. This option can then be used together with ``bzr commit
3053.8.1 by Ian Clatworthy
Improve bug tracker integration documentation (Ian Clatworthy)
117
--fixes`` to mark bugs in that tracker as being fixed by that commit. For
118
example::
119
120
    trac_twisted_url = http://www.twistedmatrix.com/trac
121
122
would allow ``bzr commit --fixes twisted:1234`` to mark Twisted's bug 1234 as
123
fixed.
124
4927.2.6 by Ian Clatworthy
Nicer formatting of bug tracking topic
125
bugtracker_<tracker>_url
126
------------------------
3089.3.14 by Ian Clatworthy
follow-up tweaks to bzr.dev integration
127
3053.8.1 by Ian Clatworthy
Improve bug tracker integration documentation (Ian Clatworthy)
128
If present, the location of a generic bug tracker instance referred to by
4927.2.6 by Ian Clatworthy
Nicer formatting of bug tracking topic
129
<tracker>. The location must contain an ``{id}`` placeholder,
3053.8.1 by Ian Clatworthy
Improve bug tracker integration documentation (Ian Clatworthy)
130
which will be replaced by a specific bug ID. This option can then be used
131
together with ``bzr commit --fixes`` to mark bugs in that tracker as being
132
fixed by that commit. For example::
133
134
    bugtracker_python_url = http://bugs.python.org/issue{id}
135
136
would allow ``bzr commit --fixes python:1234`` to mark bug 1234 in Python's
137
Roundup bug tracker as fixed, or::
138
139
    bugtracker_cpan_url = http://rt.cpan.org/Public/Bug/Display.html?id={id}
140
5409.3.1 by Alexandre Garnier
Allow using string bug ID with generic bug trackers.
141
would allow ``bzr commit --fixes cpan:1234`` to mark bug 1234 in CPAN's
142
RT bug tracker as fixed, or::
143
144
    bugtracker_hudson_url = http://issues.hudson-ci.org/browse/{id}
145
146
would allow ``bzr commit --fixes hudson:HUDSON-1234`` to mark bug HUDSON-1234
147
in Hudson's JIRA bug tracker as fixed.
3053.8.1 by Ian Clatworthy
Improve bug tracker integration documentation (Ian Clatworthy)
148
"""
149
150
6729.4.1 by Jelmer Vernooij
Move bugtracker errors to breezy.bugtracker.
151
class MalformedBugIdentifier(errors.BzrError):
152
153
    _fmt = ('Did not understand bug identifier %(bug_id)s: %(reason)s. '
154
            'See "brz help bugs" for more information on this feature.')
155
156
    def __init__(self, bug_id, reason):
157
        self.bug_id = bug_id
158
        self.reason = reason
159
160
161
class InvalidBugTrackerURL(errors.BzrError):
162
163
    _fmt = ("The URL for bug tracker \"%(abbreviation)s\" doesn't "
164
            "contain {id}: %(url)s")
165
166
    def __init__(self, abbreviation, url):
167
        self.abbreviation = abbreviation
168
        self.url = url
169
170
171
class UnknownBugTrackerAbbreviation(errors.BzrError):
172
173
    _fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
174
            "on %(branch)s")
175
176
    def __init__(self, abbreviation, branch):
177
        self.abbreviation = abbreviation
178
        self.branch = branch
179
180
181
class InvalidLineInBugsProperty(errors.BzrError):
182
183
    _fmt = ("Invalid line in bugs property: '%(line)s'")
184
185
    def __init__(self, line):
186
        self.line = line
187
188
189
class InvalidBugStatus(errors.BzrError):
190
191
    _fmt = ("Invalid bug status: '%(status)s'")
192
193
    def __init__(self, status):
194
        self.status = status
195
196
2376.4.23 by Jonathan Lange
Change 'tag' to 'abbreviated_tracker_name'
197
def get_bug_url(abbreviated_bugtracker_name, branch, bug_id):
198
    """Return a URL pointing to the canonical web page of the bug identified by
199
    'bug_id'.
200
    """
201
    tracker = tracker_registry.get_tracker(abbreviated_bugtracker_name, branch)
202
    return tracker.get_bug_url(bug_id)
2376.4.4 by jml at canonical
Beginnings of generic bug-tracker plugin system.
203
204
205
class TrackerRegistry(registry.Registry):
206
    """Registry of bug tracker types."""
207
2376.4.23 by Jonathan Lange
Change 'tag' to 'abbreviated_tracker_name'
208
    def get_tracker(self, abbreviated_bugtracker_name, branch):
209
        """Return the first registered tracker that understands
210
        'abbreviated_bugtracker_name'.
2376.4.7 by jml at canonical
- Add docstrings to tests.
211
212
        If no such tracker is found, raise KeyError.
213
        """
2376.4.23 by Jonathan Lange
Change 'tag' to 'abbreviated_tracker_name'
214
        for tracker_name in self.keys():
215
            tracker_type = self.get(tracker_name)
216
            tracker = tracker_type.get(abbreviated_bugtracker_name, branch)
2376.4.4 by jml at canonical
Beginnings of generic bug-tracker plugin system.
217
            if tracker is not None:
218
                return tracker
6729.4.1 by Jelmer Vernooij
Move bugtracker errors to breezy.bugtracker.
219
        raise UnknownBugTrackerAbbreviation(abbreviated_bugtracker_name,
220
                branch)
2376.4.7 by jml at canonical
- Add docstrings to tests.
221
2376.4.36 by Jonathan Lange
Provide really basic help topic for our bug tracker support.
222
    def help_topic(self, topic):
3053.8.1 by Ian Clatworthy
Improve bug tracker integration documentation (Ian Clatworthy)
223
        return _bugs_help
2376.4.36 by Jonathan Lange
Provide really basic help topic for our bug tracker support.
224
2376.4.4 by jml at canonical
Beginnings of generic bug-tracker plugin system.
225
226
tracker_registry = TrackerRegistry()
2376.4.6 by jml at canonical
Basic docstrings for bugtracker.py
227
"""Registry of bug trackers."""
2376.4.4 by jml at canonical
Beginnings of generic bug-tracker plugin system.
228
2376.4.15 by Jonathan Lange
Whitespace cleanup
229
2376.4.40 by Jonathan Lange
Redo the hierarchy of bug trackers to reduce duplication.
230
class BugTracker(object):
231
    """Base class for bug trackers."""
232
233
    def check_bug_id(self, bug_id):
234
        """Check that the bug_id is valid.
235
236
        The base implementation assumes that all bug_ids are valid.
237
        """
238
239
    def get_bug_url(self, bug_id):
240
        """Return the URL for bug_id. Raise an error if bug ID is malformed."""
241
        self.check_bug_id(bug_id)
242
        return self._get_bug_url(bug_id)
243
244
    def _get_bug_url(self, bug_id):
245
        """Given a validated bug_id, return the bug's web page's URL."""
246
247
248
class IntegerBugTracker(BugTracker):
249
    """A bug tracker that only allows integer bug IDs."""
250
251
    def check_bug_id(self, bug_id):
252
        try:
253
            int(bug_id)
254
        except ValueError:
6729.4.1 by Jelmer Vernooij
Move bugtracker errors to breezy.bugtracker.
255
            raise MalformedBugIdentifier(bug_id, "Must be an integer")
2376.4.40 by Jonathan Lange
Redo the hierarchy of bug trackers to reduce duplication.
256
257
258
class UniqueIntegerBugTracker(IntegerBugTracker):
2376.4.19 by Jonathan Lange
Rename SimpleBugTracker to UniqueBugTracker
259
    """A style of bug tracker that exists in one place only, such as Launchpad.
2376.4.15 by Jonathan Lange
Whitespace cleanup
260
2376.4.41 by Jonathan Lange
Update UniqueIntegerBugTracker docstring for new API
261
    If you have one of these trackers then register an instance passing in an
3270.5.3 by James Westby
No longer add an extra class to accomoadate gnome.
262
    abbreviated name for the bug tracker and a base URL. The bug ids are
263
    appended directly to the URL.
2376.5.1 by James Westby
Add a superclass for easy bug trackers. Also add bugs.debian.org as deb:
264
    """
265
2376.4.25 by Jonathan Lange
Make singleton bug tracker thing work via instances.
266
    def __init__(self, abbreviated_bugtracker_name, base_url):
267
        self.abbreviation = abbreviated_bugtracker_name
268
        self.base_url = base_url
269
270
    def get(self, abbreviated_bugtracker_name, branch):
2376.4.23 by Jonathan Lange
Change 'tag' to 'abbreviated_tracker_name'
271
        """Returns the tracker if the abbreviation matches. Returns None
272
        otherwise."""
2376.4.25 by Jonathan Lange
Make singleton bug tracker thing work via instances.
273
        if abbreviated_bugtracker_name != self.abbreviation:
2376.5.1 by James Westby
Add a superclass for easy bug trackers. Also add bugs.debian.org as deb:
274
            return None
2376.4.25 by Jonathan Lange
Make singleton bug tracker thing work via instances.
275
        return self
2376.5.1 by James Westby
Add a superclass for easy bug trackers. Also add bugs.debian.org as deb:
276
2376.4.40 by Jonathan Lange
Redo the hierarchy of bug trackers to reduce duplication.
277
    def _get_bug_url(self, bug_id):
2376.5.1 by James Westby
Add a superclass for easy bug trackers. Also add bugs.debian.org as deb:
278
        """Return the URL for bug_id."""
3270.5.3 by James Westby
No longer add an extra class to accomoadate gnome.
279
        return self.base_url + bug_id
2376.5.1 by James Westby
Add a superclass for easy bug trackers. Also add bugs.debian.org as deb:
280
281
2376.4.25 by Jonathan Lange
Make singleton bug tracker thing work via instances.
282
tracker_registry.register(
283
    'launchpad', UniqueIntegerBugTracker('lp', 'https://launchpad.net/bugs/'))
284
285
286
tracker_registry.register(
2376.4.29 by Jonathan Lange
Tests for builtin trackers.
287
    'debian', UniqueIntegerBugTracker('deb', 'http://bugs.debian.org/'))
2376.4.4 by jml at canonical
Beginnings of generic bug-tracker plugin system.
288
2376.4.15 by Jonathan Lange
Whitespace cleanup
289
3270.5.3 by James Westby
No longer add an extra class to accomoadate gnome.
290
tracker_registry.register('gnome',
5676.1.4 by Jelmer Vernooij
merge bzr.dev.
291
    UniqueIntegerBugTracker('gnome',
292
                            'http://bugzilla.gnome.org/show_bug.cgi?id='))
3270.5.3 by James Westby
No longer add an extra class to accomoadate gnome.
293
294
5409.3.1 by Alexandre Garnier
Allow using string bug ID with generic bug trackers.
295
class URLParametrizedBugTracker(BugTracker):
2376.4.40 by Jonathan Lange
Redo the hierarchy of bug trackers to reduce duplication.
296
    """A type of bug tracker that can be found on a variety of different sites,
297
    and thus needs to have the base URL configured.
298
299
    Looks for a config setting in the form '<type_name>_<abbreviation>_url'.
5409.3.1 by Alexandre Garnier
Allow using string bug ID with generic bug trackers.
300
    `type_name` is the name of the type of tracker and `abbreviation`
301
    is a short name for the particular instance.
2376.4.40 by Jonathan Lange
Redo the hierarchy of bug trackers to reduce duplication.
302
    """
303
2376.4.42 by Jonathan Lange
Parametrize URLParametrizedIntegerBugTracker even further so we don't need to
304
    def get(self, abbreviation, branch):
2376.4.40 by Jonathan Lange
Redo the hierarchy of bug trackers to reduce duplication.
305
        config = branch.get_config()
306
        url = config.get_user_option(
5676.1.4 by Jelmer Vernooij
merge bzr.dev.
307
            "%s_%s_url" % (self.type_name, abbreviation), expand=False)
2376.4.40 by Jonathan Lange
Redo the hierarchy of bug trackers to reduce duplication.
308
        if url is None:
309
            return None
310
        self._base_url = url
2376.4.42 by Jonathan Lange
Parametrize URLParametrizedIntegerBugTracker even further so we don't need to
311
        return self
312
313
    def __init__(self, type_name, bug_area):
314
        self.type_name = type_name
315
        self._bug_area = bug_area
2376.4.40 by Jonathan Lange
Redo the hierarchy of bug trackers to reduce duplication.
316
317
    def _get_bug_url(self, bug_id):
2376.4.6 by jml at canonical
Basic docstrings for bugtracker.py
318
        """Return a URL for a bug on this Trac instance."""
2376.4.42 by Jonathan Lange
Parametrize URLParametrizedIntegerBugTracker even further so we don't need to
319
        return urlutils.join(self._base_url, self._bug_area) + str(bug_id)
320
321
5676.1.4 by Jelmer Vernooij
merge bzr.dev.
322
class URLParametrizedIntegerBugTracker(IntegerBugTracker,
323
                                       URLParametrizedBugTracker):
324
    """A type of bug tracker that  only allows integer bug IDs.
325
326
    This can be found on a variety of different sites, and thus needs to have
327
    the base URL configured.
5409.3.1 by Alexandre Garnier
Allow using string bug ID with generic bug trackers.
328
329
    Looks for a config setting in the form '<type_name>_<abbreviation>_url'.
330
    `type_name` is the name of the type of tracker (e.g. 'bugzilla' or 'trac')
331
    and `abbreviation` is a short name for the particular instance (e.g.
332
    'squid' or 'apache').
333
    """
334
2376.4.42 by Jonathan Lange
Parametrize URLParametrizedIntegerBugTracker even further so we don't need to
335
tracker_registry.register(
336
    'trac', URLParametrizedIntegerBugTracker('trac', 'ticket/'))
337
338
tracker_registry.register(
339
    'bugzilla',
340
    URLParametrizedIntegerBugTracker('bugzilla', 'show_bug.cgi?id='))
3035.3.1 by Lukáš Lalinský
Generic bug tracker configuration.
341
342
5409.3.1 by Alexandre Garnier
Allow using string bug ID with generic bug trackers.
343
class GenericBugTracker(URLParametrizedBugTracker):
3035.3.1 by Lukáš Lalinský
Generic bug tracker configuration.
344
    """Generic bug tracker specified by an URL template."""
345
346
    def __init__(self):
3035.3.2 by Lukáš Lalinský
Add tests for InvalidBugTrackerURL.
347
        super(GenericBugTracker, self).__init__('bugtracker', None)
348
349
    def get(self, abbreviation, branch):
350
        self._abbreviation = abbreviation
351
        return super(GenericBugTracker, self).get(abbreviation, branch)
3035.3.1 by Lukáš Lalinský
Generic bug tracker configuration.
352
353
    def _get_bug_url(self, bug_id):
354
        """Given a validated bug_id, return the bug's web page's URL."""
355
        if '{id}' not in self._base_url:
6729.4.1 by Jelmer Vernooij
Move bugtracker errors to breezy.bugtracker.
356
            raise InvalidBugTrackerURL(self._abbreviation, self._base_url)
3035.3.1 by Lukáš Lalinský
Generic bug tracker configuration.
357
        return self._base_url.replace('{id}', str(bug_id))
358
359
360
tracker_registry.register('generic', GenericBugTracker())
4119.4.1 by Jonathan Lange
Extract bug fix encoding logic from commit.
361
362
4119.4.2 by Jonathan Lange
Some refactoring, some unit tests.
363
FIXED = 'fixed'
364
6619.3.12 by Jelmer Vernooij
Use 2to3 set_literal fixer.
365
ALLOWED_BUG_STATUSES = {FIXED}
4119.4.3 by Jonathan Lange
Add Revision.iter_bugs.
366
4119.4.2 by Jonathan Lange
Some refactoring, some unit tests.
367
4119.4.1 by Jonathan Lange
Extract bug fix encoding logic from commit.
368
def encode_fixes_bug_urls(bug_urls):
4119.4.5 by Jonathan Lange
Fix the docstring.
369
    """Get the revision property value for a commit that fixes bugs.
370
371
    :param bug_urls: An iterable of escaped URLs to bugs. These normally
372
        come from `get_bug_url`.
373
    :return: A string that will be set as the 'bugs' property of a revision
374
        as part of a commit.
4119.4.1 by Jonathan Lange
Extract bug fix encoding logic from commit.
375
    """
4119.4.2 by Jonathan Lange
Some refactoring, some unit tests.
376
    return '\n'.join(('%s %s' % (url, FIXED)) for url in bug_urls)