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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
# 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
"""A collection of branches.
See `IBranchCollection` for more details.
"""
__metaclass__ = type
__all__ = [
'IAllBranches',
'IBranchCollection',
'InvalidFilter',
]
from zope.interface import Interface
class InvalidFilter(Exception):
"""Raised when an `IBranchCollection` cannot apply the given filter."""
class IBranchCollection(Interface):
"""A collection of branches.
An `IBranchCollection` is an immutable collection of branches. It has two
kinds of methods: filter methods and query methods.
Query methods get information about the contents of collection. See
`IBranchCollection.count` and `IBranchCollection.getBranches`.
Filter methods return new IBranchCollection instances that have some sort
of restriction. Examples include `ownedBy`, `visibleByUser` and
`inProduct`.
Implementations of this interface are not 'content classes'. That is, they
do not correspond to a particular row in the database.
This interface is intended for use within Launchpad, not to be exported as
a public API.
"""
# Note to developers: This interface should be extended with more query
# methods. It would be great to have methods like getRecentRevisions on
# arbitrary branch collections. Other statistical methods would be good
# too, e.g. number of different branch owners in this collection.
def count():
"""The number of branches in this collection."""
def is_empty():
"""Is this collection empty?"""
def ownerCounts():
"""Return the number of different branch owners.
:return: a tuple (individual_count, team_count) containing the number
of individuals and teams that own branches in this collection.
"""
def getBranches(eager_load=False):
"""Return a result set of all branches in this collection.
The returned result set will also join across the specified tables as
defined by the arguments to this function. These extra tables are
joined specificly to allow the caller to sort on values not in the
Branch table itself.
:param eager_load: If True trigger eager loading of all the related
objects in the collection.
"""
def getMergeProposals(statuses=None, for_branches=None,
target_branch=None, eager_load=False):
"""Return a result set of merge proposals for the branches in this
collection.
:param statuses: If specified, only return merge proposals with these
statuses. If not, return all merge proposals.
:param for_branches: An iterable of branches what will restrict the
resulting set of merge proposals to be only those where the source
branch is one of the branches specified.
:param target_branch: If specified, only return merge proposals
that target the specified branch.
:param eager_load: If True, preloads all the related information for
merge proposals like PreviewDiffs and Branches.
"""
def getMergeProposalsForPerson(person, status=None):
"""Proposals for `person`.
Return the proposals for branches owned by `person` or where `person`
is reviewing or been asked to review.
"""
def getMergeProposalsForReviewer(reviewer, status=None):
"""Return a result set of merge proposals for the given reviewer.
That is, all merge proposals that 'reviewer' has voted on or has been
invited to vote on.
:param reviewer: An `IPerson` who is a reviewer.
:param status: An iterable of queue_status of the proposals to return.
If None is specified, all the proposals of all possible states
are returned.
"""
def getExtendedRevisionDetails(user, revisions):
"""Return information about the specified revisions on a branch.
For each revision, see if the revision resulted from merging in a
merge proposal, and if so package up the merge proposal and any linked
bug tasks on the merge proposal's source branch.
:param user: The user who is making the request. Only bug tasks
visible to this user are returned.
:param revisions: The revisions we want details for.
"""
def getTeamsWithBranches(person):
"""Return the teams that person is a member of that have branches."""
def inProduct(product):
"""Restrict the collection to branches in 'product'."""
def inProject(project):
"""Restrict the collection to branches in 'project'."""
def inSourcePackage(package):
"""Restrict the collection to branches in 'package'.
A source package is effectively a sourcepackagename in a distro
series.
"""
def inDistribution(distribution):
"""Restrict the collection to branches in 'distribution'."""
def inDistroSeries(distro_series):
"""Restrict the collection to branches in 'distro_series'."""
def inDistributionSourcePackage(distro_source_package):
"""Restrict to branches in a 'package' for a 'distribution'."""
def linkedToBugs(bugs):
"""Restrict to branches linked to `bugs`."""
def officialBranches(pocket=None):
"""Restrict to branches that are official for some source package."""
def isJunk():
"""Restrict the collection to junk branches.
A junk branch is a branch that's not associated with a product nor
with a sourcepackage.
"""
def ownedBy(person):
"""Restrict the collection to branches owned by 'person'."""
def ownedByTeamMember(person):
"""Restrict the collection to branches owned by 'person' or a team
of which person is a member.
"""
def registeredBy(person):
"""Restrict the collection to branches registered by 'person'."""
def relatedTo(person):
"""Restrict the collection to branches related to 'person'.
That is, branches that 'person' owns, registered or is subscribed to.
"""
def search(search_term):
"""Search the collection for branches matching 'search_term'.
:param search_term: A string.
:return: An `ICountableIterator`.
"""
def scanned():
"""Restrict the collection to branches that have been scanned."""
def subscribedBy(person):
"""Restrict the collection to branches subscribed to by 'person'."""
def visibleByUser(person):
"""Restrict the collection to branches that person is allowed to see.
"""
def withBranchType(*branch_types):
"""Restrict the collection to branches with the given branch types."""
def withLifecycleStatus(*statuses):
"""Restrict the collection to branches with the given statuses."""
def modifiedSince(epoch):
"""Restrict the collection to branches modified since `epoch`."""
def scannedSince(epoch):
"""Restrict the collection to branches scanned since `epoch`."""
def targetedBy(person):
"""Restrict the collection to branches targeted by person.
A branch is targeted by a person if that person has registered a merge
proposal with the branch as the target.
:param since: If supplied, ignore merge proposals before this date.
"""
class IAllBranches(IBranchCollection):
"""A `IBranchCollection` representing all branches in Launchpad."""
|