/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

Merge test-run support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
"""
43
43
 
44
44
 
45
 
_bugs_help = """\
46
 
When making a commit, metadata about bugs fixed by that change can be
 
45
_bugs_help = \
 
46
"""When making a commit, metadata about bugs fixed by that change can be
47
47
recorded by using the ``--fixes`` option. For each bug marked as fixed, an
48
48
entry is included in the 'bugs' revision property stating '<url> <status>'.
49
49
(The only ``status`` value currently supported is ``fixed.``)
186
186
        self.line = line
187
187
 
188
188
 
189
 
class InvalidBugUrl(errors.BzrError):
190
 
 
191
 
    _fmt = "Invalid bug URL: %(url)s"
192
 
 
193
 
    def __init__(self, url):
194
 
        self.url = url
195
 
 
196
 
 
197
189
class InvalidBugStatus(errors.BzrError):
198
190
 
199
191
    _fmt = ("Invalid bug status: '%(status)s'")
224
216
            tracker = tracker_type.get(abbreviated_bugtracker_name, branch)
225
217
            if tracker is not None:
226
218
                return tracker
227
 
        raise UnknownBugTrackerAbbreviation(
228
 
            abbreviated_bugtracker_name, branch)
 
219
        raise UnknownBugTrackerAbbreviation(abbreviated_bugtracker_name,
 
220
                branch)
229
221
 
230
222
    def help_topic(self, topic):
231
223
        return _bugs_help
324
316
        if '{project}' not in self._base_url:
325
317
            raise InvalidBugTrackerURL(self._abbreviation, self._base_url)
326
318
        return self._base_url.replace(
327
 
            '{project}', project).replace('{id}', str(bug_id))
 
319
                '{project}', project).replace('{id}', str(bug_id))
328
320
 
329
321
 
330
322
tracker_registry.register(
335
327
    'debian', UniqueIntegerBugTracker('deb', 'http://bugs.debian.org/'))
336
328
 
337
329
 
338
 
tracker_registry.register(
339
 
    'gnome', UniqueIntegerBugTracker(
340
 
        'gnome', 'http://bugzilla.gnome.org/show_bug.cgi?id='))
 
330
tracker_registry.register('gnome',
 
331
    UniqueIntegerBugTracker('gnome',
 
332
                            'http://bugzilla.gnome.org/show_bug.cgi?id='))
341
333
 
342
334
 
343
335
tracker_registry.register(
385
377
    'squid' or 'apache').
386
378
    """
387
379
 
388
 
 
389
380
tracker_registry.register(
390
381
    'trac', URLParametrizedIntegerBugTracker('trac', 'ticket/'))
391
382
 
415
406
 
416
407
 
417
408
FIXED = 'fixed'
418
 
RELATED = 'related'
419
409
 
420
 
ALLOWED_BUG_STATUSES = {FIXED, RELATED}
 
410
ALLOWED_BUG_STATUSES = {FIXED}
421
411
 
422
412
 
423
413
def encode_fixes_bug_urls(bug_urls):
424
414
    """Get the revision property value for a commit that fixes bugs.
425
415
 
426
 
    :param bug_urls: An iterable of (escaped URL, tag) tuples. These normally
 
416
    :param bug_urls: An iterable of escaped URLs to bugs. These normally
427
417
        come from `get_bug_url`.
428
418
    :return: A string that will be set as the 'bugs' property of a revision
429
419
        as part of a commit.
430
420
    """
431
 
    lines = []
432
 
    for (url, tag) in bug_urls:
433
 
        if ' ' in url:
434
 
            raise InvalidBugUrl(url)
435
 
        lines.append('%s %s' % (url, tag))
436
 
    return '\n'.join(lines)
437
 
 
438
 
 
439
 
def decode_bug_urls(bug_text):
440
 
    """Decode a bug property text.
441
 
 
442
 
    :param bug_text: Contents of a bugs property
443
 
    :return: iterator over (url, status) tuples
444
 
    """
445
 
    for line in bug_text.splitlines():
446
 
        try:
447
 
            url, status = line.split(None, 2)
448
 
        except ValueError:
449
 
            raise InvalidLineInBugsProperty(line)
450
 
        if status not in ALLOWED_BUG_STATUSES:
451
 
            raise InvalidBugStatus(status)
452
 
        yield url, status
 
421
    return '\n'.join(('%s %s' % (url, FIXED)) for url in bug_urls)