/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/bugtracker.py

  • Committer: Robert Collins
  • Date: 2008-02-13 03:30:01 UTC
  • mfrom: (3221 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3224.
  • Revision ID: robertc@robertcollins.net-20080213033001-rw70ul0zb02ph856
Merge to fix conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
"""
40
40
 
41
41
 
 
42
_bugs_help = \
 
43
"""When making a commit, metadata about bugs fixed by that change can be
 
44
recorded by using the --fixes option. For each bug marked as fixed, an
 
45
entry is included in the 'bugs' revision property stating '<url> <status>'.
 
46
(The only ``status`` value currently supported is ``fixed.``)
 
47
Support for Launchpad's central bug tracker is built in. For other bug
 
48
trackers, configuration is required in advance so that the correct URL
 
49
can be recorded.
 
50
 
 
51
In addition to Launchpad, Bazaar directly supports the generation of
 
52
URLs appropriate for Bugzilla and Trac. If your project uses a different
 
53
bug tracker, it is easy to add support for it.
 
54
If you use Bugzilla or Trac, then you only need to set a configuration
 
55
variable which contains the base URL of the bug tracker. These options
 
56
can go into ``bazaar.conf``, ``branch.conf`` or into a branch-specific
 
57
configuration section in ``locations.conf``.  You can set up these values
 
58
for each of the projects you work on.
 
59
 
 
60
Note: As you provide a short name for each tracker, you can specify one or
 
61
more bugs in one or more trackers at commit time if you wish.
 
62
 
 
63
bugzilla_<tracker_abbreviation>_url
 
64
-----------------------------------
 
65
 
 
66
If present, the location of the Bugzilla bug tracker referred to by
 
67
<tracker_abbreviation>. This option can then be used together with ``bzr commit
 
68
--fixes`` to mark bugs in that tracker as being fixed by that commit. For
 
69
example::
 
70
 
 
71
    bugzilla_squid_url = http://www.squid-cache.org/bugs
 
72
 
 
73
would allow ``bzr commit --fixes squid:1234`` to mark Squid's bug 1234 as
 
74
fixed.
 
75
 
 
76
trac_<tracker_abbrevation>_url
 
77
------------------------------
 
78
 
 
79
If present, the location of the Trac instance referred to by
 
80
<tracker_abbreviation>. This option can then be used together with ``bzr commit
 
81
--fixes`` to mark bugs in that tracker as being fixed by that commit. For
 
82
example::
 
83
 
 
84
    trac_twisted_url = http://www.twistedmatrix.com/trac
 
85
 
 
86
would allow ``bzr commit --fixes twisted:1234`` to mark Twisted's bug 1234 as
 
87
fixed.
 
88
 
 
89
bugtracker_<tracker_abbrevation>_url
 
90
------------------------------------
 
91
 
 
92
If present, the location of a generic bug tracker instance referred to by
 
93
<tracker_abbreviation>. The location must contain an ``{id}`` placeholder,
 
94
which will be replaced by a specific bug ID. This option can then be used
 
95
together with ``bzr commit --fixes`` to mark bugs in that tracker as being
 
96
fixed by that commit. For example::
 
97
 
 
98
    bugtracker_python_url = http://bugs.python.org/issue{id}
 
99
 
 
100
would allow ``bzr commit --fixes python:1234`` to mark bug 1234 in Python's
 
101
Roundup bug tracker as fixed, or::
 
102
 
 
103
    bugtracker_cpan_url = http://rt.cpan.org/Public/Bug/Display.html?id={id}
 
104
 
 
105
for CPAN's RT bug tracker.
 
106
"""
 
107
 
 
108
 
42
109
def get_bug_url(abbreviated_bugtracker_name, branch, bug_id):
43
110
    """Return a URL pointing to the canonical web page of the bug identified by
44
111
    'bug_id'.
65
132
                                                   branch)
66
133
 
67
134
    def help_topic(self, topic):
68
 
        return textwrap.dedent("""\
69
 
        Bazaar provides the ability to store information about bugs being fixed
70
 
        as metadata on a revision.
71
 
 
72
 
        For each bug marked as fixed, an entry is included in the 'bugs'
73
 
        revision property stating '<url> <status>'.
74
 
        """)
 
135
        return _bugs_help
75
136
 
76
137
 
77
138
tracker_registry = TrackerRegistry()
171
232
tracker_registry.register(
172
233
    'bugzilla',
173
234
    URLParametrizedIntegerBugTracker('bugzilla', 'show_bug.cgi?id='))
 
235
 
 
236
 
 
237
class GenericBugTracker(URLParametrizedIntegerBugTracker):
 
238
    """Generic bug tracker specified by an URL template."""
 
239
 
 
240
    def __init__(self):
 
241
        super(GenericBugTracker, self).__init__('bugtracker', None)
 
242
 
 
243
    def get(self, abbreviation, branch):
 
244
        self._abbreviation = abbreviation
 
245
        return super(GenericBugTracker, self).get(abbreviation, branch)
 
246
 
 
247
    def _get_bug_url(self, bug_id):
 
248
        """Given a validated bug_id, return the bug's web page's URL."""
 
249
        if '{id}' not in self._base_url:
 
250
            raise errors.InvalidBugTrackerURL(self._abbreviation,
 
251
                                              self._base_url)
 
252
        return self._base_url.replace('{id}', str(bug_id))
 
253
 
 
254
 
 
255
tracker_registry.register('generic', GenericBugTracker())