~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bugtracker.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-01 08:02:42 UTC
  • mfrom: (5390.3.3 faster-revert-593560)
  • Revision ID: pqm@pqm.ubuntu.com-20100901080242-esg62ody4frwmy66
(spiv) Avoid repeatedly calling self.target.all_file_ids() in
 InterTree.iter_changes. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

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