1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
# pylint: disable-msg=E0211,E0213
"""Interfaces for linking BugTasks and Branches."""
__metaclass__ = type
__all__ = [
"IBugBranch",
"IBugBranchSet",
]
from lazr.restful.declarations import (
export_as_webservice_entry,
exported,
)
from lazr.restful.fields import ReferenceChoice
from zope.interface import Interface
from zope.schema import (
Int,
Object,
TextLine,
)
from canonical.launchpad import _
from canonical.launchpad.interfaces.launchpad import (
IHasBug,
IHasDateCreated,
)
from lp.bugs.interfaces.bugtask import IBugTask
from lp.code.interfaces.branch import IBranch
from lp.code.interfaces.branchtarget import IHasBranchTarget
from lp.registry.interfaces.person import IPerson
from lp.services.fields import (
BugField,
)
class IBugBranch(IHasDateCreated, IHasBug, IHasBranchTarget):
"""A branch linked to a bug."""
export_as_webservice_entry()
id = Int(title=_("Bug Branch #"))
bug = exported(
BugField(
title=_("Bug #"),
required=True, readonly=True))
branch_id = Int(title=_("Branch ID"), required=True, readonly=True)
branch = exported(
ReferenceChoice(
title=_("Branch"), schema=IBranch,
vocabulary="Branch", required=True))
revision_hint = TextLine(title=_("Revision Hint"))
bug_task = Object(
schema=IBugTask, title=_("The bug task that the branch fixes"),
description=_(
"the bug task reported against this branch's product or the "
"first bug task (in case where there is no task reported "
"against the branch's product)."),
readonly=True)
registrant = Object(
schema=IPerson, readonly=True, required=True,
title=_("The person who linked the bug to the branch"))
class IBugBranchSet(Interface):
def getBugBranch(bug, branch):
"""Return the BugBranch for the given bug and branch.
Return None if there is no such link.
"""
def getBranchesWithVisibleBugs(branches, user):
"""Find which of `branches` are for bugs that `user` can see.
:param branches: A sequence of `Branch`es to limit the search
to.
:return: A result set of `Branch` ids: a subset of the ids
found in `branches`, but limited to branches that are
visible to `user`.
"""
def getBugBranchesForBugTasks(tasks):
"""Return a sequence of IBugBranch instances associated with
the bugs for the given tasks."""
|