/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: 2018-06-14 17:59:16 UTC
  • mto: This revision was merged to the branch mainline in revision 7065.
  • Revision ID: jelmer@jelmer.uk-20180614175916-a2e2xh5k533guq1x
Move breezy.plugins.git to breezy.git.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
from __future__ import absolute_import
 
18
 
17
19
from . import (
18
20
    errors,
19
21
    registry,
40
42
"""
41
43
 
42
44
 
43
 
_bugs_help = """\
44
 
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
45
47
recorded by using the ``--fixes`` option. For each bug marked as fixed, an
46
48
entry is included in the 'bugs' revision property stating '<url> <status>'.
47
49
(The only ``status`` value currently supported is ``fixed.``)
184
186
        self.line = line
185
187
 
186
188
 
187
 
class InvalidBugUrl(errors.BzrError):
188
 
 
189
 
    _fmt = "Invalid bug URL: %(url)s"
190
 
 
191
 
    def __init__(self, url):
192
 
        self.url = url
193
 
 
194
 
 
195
189
class InvalidBugStatus(errors.BzrError):
196
190
 
197
191
    _fmt = ("Invalid bug status: '%(status)s'")
222
216
            tracker = tracker_type.get(abbreviated_bugtracker_name, branch)
223
217
            if tracker is not None:
224
218
                return tracker
225
 
        raise UnknownBugTrackerAbbreviation(
226
 
            abbreviated_bugtracker_name, branch)
 
219
        raise UnknownBugTrackerAbbreviation(abbreviated_bugtracker_name,
 
220
                branch)
227
221
 
228
222
    def help_topic(self, topic):
229
223
        return _bugs_help
322
316
        if '{project}' not in self._base_url:
323
317
            raise InvalidBugTrackerURL(self._abbreviation, self._base_url)
324
318
        return self._base_url.replace(
325
 
            '{project}', project).replace('{id}', str(bug_id))
 
319
                '{project}', project).replace('{id}', str(bug_id))
326
320
 
327
321
 
328
322
tracker_registry.register(
333
327
    'debian', UniqueIntegerBugTracker('deb', 'http://bugs.debian.org/'))
334
328
 
335
329
 
336
 
tracker_registry.register(
337
 
    'gnome', UniqueIntegerBugTracker(
338
 
        '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='))
339
333
 
340
334
 
341
335
tracker_registry.register(
383
377
    'squid' or 'apache').
384
378
    """
385
379
 
386
 
 
387
380
tracker_registry.register(
388
381
    'trac', URLParametrizedIntegerBugTracker('trac', 'ticket/'))
389
382
 
413
406
 
414
407
 
415
408
FIXED = 'fixed'
416
 
RELATED = 'related'
417
409
 
418
 
ALLOWED_BUG_STATUSES = {FIXED, RELATED}
 
410
ALLOWED_BUG_STATUSES = {FIXED}
419
411
 
420
412
 
421
413
def encode_fixes_bug_urls(bug_urls):
422
414
    """Get the revision property value for a commit that fixes bugs.
423
415
 
424
 
    :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
425
417
        come from `get_bug_url`.
426
418
    :return: A string that will be set as the 'bugs' property of a revision
427
419
        as part of a commit.
428
420
    """
429
 
    lines = []
430
 
    for (url, tag) in bug_urls:
431
 
        if ' ' in url:
432
 
            raise InvalidBugUrl(url)
433
 
        lines.append('%s %s' % (url, tag))
434
 
    return '\n'.join(lines)
435
 
 
436
 
 
437
 
def decode_bug_urls(bug_text):
438
 
    """Decode a bug property text.
439
 
 
440
 
    :param bug_text: Contents of a bugs property
441
 
    :return: iterator over (url, status) tuples
442
 
    """
443
 
    for line in bug_text.splitlines():
444
 
        try:
445
 
            url, status = line.split(None, 2)
446
 
        except ValueError:
447
 
            raise InvalidLineInBugsProperty(line)
448
 
        if status not in ALLOWED_BUG_STATUSES:
449
 
            raise InvalidBugStatus(status)
450
 
        yield url, status
 
421
    return '\n'.join(('%s %s' % (url, FIXED)) for url in bug_urls)