1
# Copyright (C) 2007 Canonical Ltd
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.
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.
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
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
from bzrlib import registry
20
def get_url(tag, branch, bug_id):
21
return tracker_registry.get_by_tag(tag, branch).get_bug_url(bug_id)
24
class TrackerRegistry(registry.Registry):
25
"""Registry of bug tracker types."""
27
def get_by_tag(self, tag, branch):
28
for tracker_name, tracker_type in self.iteritems():
29
tracker = tracker_type.get(tag, branch)
30
if tracker is not None:
33
tracker_registry = TrackerRegistry()
36
class LaunchpadTracker(object):
39
def get(klass, tag, branch):
44
def get_bug_url(self, bug_id):
45
return 'https://launchpad.net/bugs/%s' % (bug_id,)
48
class TracTracker(object):
51
def get(klass, tag, branch):
52
url = branch.get_config().get_user_option('trac_%s_url' % (tag,))
57
def __init__(self, url):
60
def get_bug_url(self, bug_id):
61
return '%s/ticket/%s' % (self._url, bug_id)
63
tracker_registry.register('launchpad', LaunchpadTracker)
64
tracker_registry.register('trac', TracTracker)