/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 breezy/bugtracker.py

  • Committer: Jelmer Vernooij
  • Date: 2017-07-23 22:06:41 UTC
  • mfrom: (6738 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170723220641-69eczax9bmv8d6kk
Merge trunk, address review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
from __future__ import absolute_import
18
18
 
19
 
from . import registry
 
19
from . import (
 
20
    errors,
 
21
    registry,
 
22
    )
20
23
from .lazy_import import lazy_import
21
24
lazy_import(globals(), """
22
 
from breezy import errors, urlutils
 
25
from breezy import urlutils
23
26
""")
24
27
 
25
28
 
145
148
"""
146
149
 
147
150
 
 
151
class MalformedBugIdentifier(errors.BzrError):
 
152
 
 
153
    _fmt = ('Did not understand bug identifier %(bug_id)s: %(reason)s. '
 
154
            'See "brz help bugs" for more information on this feature.')
 
155
 
 
156
    def __init__(self, bug_id, reason):
 
157
        self.bug_id = bug_id
 
158
        self.reason = reason
 
159
 
 
160
 
 
161
class InvalidBugTrackerURL(errors.BzrError):
 
162
 
 
163
    _fmt = ("The URL for bug tracker \"%(abbreviation)s\" doesn't "
 
164
            "contain {id}: %(url)s")
 
165
 
 
166
    def __init__(self, abbreviation, url):
 
167
        self.abbreviation = abbreviation
 
168
        self.url = url
 
169
 
 
170
 
 
171
class UnknownBugTrackerAbbreviation(errors.BzrError):
 
172
 
 
173
    _fmt = ("Cannot find registered bug tracker called %(abbreviation)s "
 
174
            "on %(branch)s")
 
175
 
 
176
    def __init__(self, abbreviation, branch):
 
177
        self.abbreviation = abbreviation
 
178
        self.branch = branch
 
179
 
 
180
 
 
181
class InvalidLineInBugsProperty(errors.BzrError):
 
182
 
 
183
    _fmt = ("Invalid line in bugs property: '%(line)s'")
 
184
 
 
185
    def __init__(self, line):
 
186
        self.line = line
 
187
 
 
188
 
 
189
class InvalidBugStatus(errors.BzrError):
 
190
 
 
191
    _fmt = ("Invalid bug status: '%(status)s'")
 
192
 
 
193
    def __init__(self, status):
 
194
        self.status = status
 
195
 
 
196
 
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
150
199
    'bug_id'.
167
216
            tracker = tracker_type.get(abbreviated_bugtracker_name, branch)
168
217
            if tracker is not None:
169
218
                return tracker
170
 
        raise errors.UnknownBugTrackerAbbreviation(abbreviated_bugtracker_name,
171
 
                                                   branch)
 
219
        raise UnknownBugTrackerAbbreviation(abbreviated_bugtracker_name,
 
220
                branch)
172
221
 
173
222
    def help_topic(self, topic):
174
223
        return _bugs_help
203
252
        try:
204
253
            int(bug_id)
205
254
        except ValueError:
206
 
            raise errors.MalformedBugIdentifier(bug_id, "Must be an integer")
 
255
            raise MalformedBugIdentifier(bug_id, "Must be an integer")
207
256
 
208
257
 
209
258
class UniqueIntegerBugTracker(IntegerBugTracker):
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,
308
 
                                              self._base_url)
 
356
            raise InvalidBugTrackerURL(self._abbreviation, self._base_url)
309
357
        return self._base_url.replace('{id}', str(bug_id))
310
358
 
311
359