17
17
from __future__ import absolute_import
19
from . import registry
20
23
from .lazy_import import lazy_import
21
24
lazy_import(globals(), """
22
from breezy import errors, urlutils
25
from breezy import urlutils
151
class MalformedBugIdentifier(errors.BzrError):
153
_fmt = ('Did not understand bug identifier %(bug_id)s: %(reason)s. '
154
'See "brz help bugs" for more information on this feature.')
156
def __init__(self, bug_id, reason):
161
class InvalidBugTrackerURL(errors.BzrError):
163
_fmt = ("The URL for bug tracker \"%(abbreviation)s\" doesn't "
164
"contain {id}: %(url)s")
166
def __init__(self, abbreviation, url):
167
self.abbreviation = abbreviation
171
class UnknownBugTrackerAbbreviation(errors.BzrError):
173
_fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
176
def __init__(self, abbreviation, branch):
177
self.abbreviation = abbreviation
181
class InvalidLineInBugsProperty(errors.BzrError):
183
_fmt = ("Invalid line in bugs property: '%(line)s'")
185
def __init__(self, line):
189
class InvalidBugStatus(errors.BzrError):
191
_fmt = ("Invalid bug status: '%(status)s'")
193
def __init__(self, status):
148
197
def get_bug_url(abbreviated_bugtracker_name, branch, bug_id):
149
198
"""Return a URL pointing to the canonical web page of the bug identified by
167
216
tracker = tracker_type.get(abbreviated_bugtracker_name, branch)
168
217
if tracker is not None:
170
raise errors.UnknownBugTrackerAbbreviation(abbreviated_bugtracker_name,
219
raise UnknownBugTrackerAbbreviation(abbreviated_bugtracker_name,
173
222
def help_topic(self, topic):
174
223
return _bugs_help
304
353
def _get_bug_url(self, bug_id):
305
354
"""Given a validated bug_id, return the bug's web page's URL."""
306
355
if '{id}' not in self._base_url:
307
raise errors.InvalidBugTrackerURL(self._abbreviation,
356
raise InvalidBugTrackerURL(self._abbreviation, self._base_url)
309
357
return self._base_url.replace('{id}', str(bug_id))