~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bugtracker.py

  • Committer: Jelmer Vernooij
  • Date: 2011-12-05 14:12:23 UTC
  • mto: This revision was merged to the branch mainline in revision 6348.
  • Revision ID: jelmer@samba.org-20111205141223-8qxae4h37satlzgq
Move more functionality to vf_search.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007 Canonical Ltd
 
1
# Copyright (C) 2007-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
from bzrlib import registry, help_topics
 
17
from bzrlib import registry
18
18
from bzrlib.lazy_import import lazy_import
19
19
lazy_import(globals(), """
20
20
from bzrlib import errors, urlutils
48
48
 
49
49
    bzr commit --fixes <tracker>:<id>
50
50
 
 
51
or::
 
52
 
 
53
    bzr commit --fixes <id>
 
54
 
51
55
where "<tracker>" is an identifier for the bug tracker, and "<id>" is the
52
56
identifier for that bug within the bugtracker, usually the bug number.
 
57
If "<tracker>" is not specified the ``bugtracker`` set in the branch
 
58
or global configuration is used.
53
59
 
54
60
Bazaar knows about a few bug trackers that have many users. If
55
61
you use one of these bug trackers then there is no setup required to
93
99
--fixes`` to mark bugs in that tracker as being fixed by that commit. For
94
100
example::
95
101
 
96
 
    bugzilla_squid_url = http://www.squid-cache.org/bugs
 
102
    bugzilla_squid_url = http://bugs.squid-cache.org
97
103
 
98
104
would allow ``bzr commit --fixes squid:1234`` to mark Squid's bug 1234 as
99
105
fixed.
127
133
 
128
134
    bugtracker_cpan_url = http://rt.cpan.org/Public/Bug/Display.html?id={id}
129
135
 
130
 
for CPAN's RT bug tracker.
 
136
would allow ``bzr commit --fixes cpan:1234`` to mark bug 1234 in CPAN's
 
137
RT bug tracker as fixed, or::
 
138
 
 
139
    bugtracker_hudson_url = http://issues.hudson-ci.org/browse/{id}
 
140
 
 
141
would allow ``bzr commit --fixes hudson:HUDSON-1234`` to mark bug HUDSON-1234
 
142
in Hudson's JIRA bug tracker as fixed.
131
143
"""
132
144
 
133
145
 
225
237
 
226
238
 
227
239
tracker_registry.register('gnome',
228
 
    UniqueIntegerBugTracker('gnome', 'http://bugzilla.gnome.org/show_bug.cgi?id='))
229
 
 
230
 
 
231
 
class URLParametrizedIntegerBugTracker(IntegerBugTracker):
 
240
    UniqueIntegerBugTracker('gnome',
 
241
                            'http://bugzilla.gnome.org/show_bug.cgi?id='))
 
242
 
 
243
 
 
244
class URLParametrizedBugTracker(BugTracker):
232
245
    """A type of bug tracker that can be found on a variety of different sites,
233
246
    and thus needs to have the base URL configured.
234
247
 
235
248
    Looks for a config setting in the form '<type_name>_<abbreviation>_url'.
236
 
    `type_name` is the name of the type of tracker (e.g. 'bugzilla' or 'trac')
237
 
    and `abbreviation` is a short name for the particular instance (e.g.
238
 
    'squid' or 'apache').
 
249
    `type_name` is the name of the type of tracker and `abbreviation`
 
250
    is a short name for the particular instance.
239
251
    """
240
252
 
241
253
    def get(self, abbreviation, branch):
242
254
        config = branch.get_config()
243
255
        url = config.get_user_option(
244
 
            "%s_%s_url" % (self.type_name, abbreviation))
 
256
            "%s_%s_url" % (self.type_name, abbreviation), expand=False)
245
257
        if url is None:
246
258
            return None
247
259
        self._base_url = url
256
268
        return urlutils.join(self._base_url, self._bug_area) + str(bug_id)
257
269
 
258
270
 
 
271
class URLParametrizedIntegerBugTracker(IntegerBugTracker,
 
272
                                       URLParametrizedBugTracker):
 
273
    """A type of bug tracker that  only allows integer bug IDs.
 
274
 
 
275
    This can be found on a variety of different sites, and thus needs to have
 
276
    the base URL configured.
 
277
 
 
278
    Looks for a config setting in the form '<type_name>_<abbreviation>_url'.
 
279
    `type_name` is the name of the type of tracker (e.g. 'bugzilla' or 'trac')
 
280
    and `abbreviation` is a short name for the particular instance (e.g.
 
281
    'squid' or 'apache').
 
282
    """
 
283
 
259
284
tracker_registry.register(
260
285
    'trac', URLParametrizedIntegerBugTracker('trac', 'ticket/'))
261
286
 
264
289
    URLParametrizedIntegerBugTracker('bugzilla', 'show_bug.cgi?id='))
265
290
 
266
291
 
267
 
class GenericBugTracker(URLParametrizedIntegerBugTracker):
 
292
class GenericBugTracker(URLParametrizedBugTracker):
268
293
    """Generic bug tracker specified by an URL template."""
269
294
 
270
295
    def __init__(self):