Merge lp:~cjwatson/launchpad/codeimport-list-git into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18237
Proposed branch: lp:~cjwatson/launchpad/codeimport-list-git
Merge into: lp:launchpad
Prerequisite: lp:~cjwatson/launchpad/codeimport-git-read-only-views
Diff against target: 299 lines (+111/-38)
5 files modified
lib/lp/code/browser/codeimport.py (+15/-4)
lib/lp/code/interfaces/codeimport.py (+4/-1)
lib/lp/code/model/codeimport.py (+5/-1)
lib/lp/code/stories/codeimport/xx-codeimport-view.txt (+70/-27)
lib/lp/code/templates/codeimport-list.pt (+17/-5)
To merge this branch: bzr merge lp:~cjwatson/launchpad/codeimport-list-git
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+308387@code.launchpad.net

Commit message

Extend CodeImportSet:+index to support different target types.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/browser/codeimport.py'
2--- lib/lp/code/browser/codeimport.py 2016-10-13 14:25:08 +0000
3+++ lib/lp/code/browser/codeimport.py 2016-10-13 14:25:09 +0000
4@@ -123,12 +123,19 @@
5 review_status_field = copy_field(
6 ICodeImport['review_status'], required=False, default=None)
7 self.review_status_widget = CustomWidgetFactory(DropdownWidgetWithAny)
8- setUpWidget(self, 'review_status', review_status_field, IInputWidget)
9+ setUpWidget(self, 'review_status', review_status_field, IInputWidget)
10
11 rcs_type_field = copy_field(
12 ICodeImport['rcs_type'], required=False, default=None)
13 self.rcs_type_widget = CustomWidgetFactory(DropdownWidgetWithAny)
14- setUpWidget(self, 'rcs_type', rcs_type_field, IInputWidget)
15+ setUpWidget(self, 'rcs_type', rcs_type_field, IInputWidget)
16+
17+ target_rcs_type_field = copy_field(
18+ ICodeImport['target_rcs_type'], required=False, default=None)
19+ self.target_rcs_type_widget = CustomWidgetFactory(
20+ DropdownWidgetWithAny)
21+ setUpWidget(
22+ self, 'target_rcs_type', target_rcs_type_field, IInputWidget)
23
24 # status should be None if either (a) there were no query arguments
25 # supplied, i.e. the user browsed directly to this page (this is when
26@@ -138,13 +145,17 @@
27 review_status = None
28 if self.review_status_widget.hasValidInput():
29 review_status = self.review_status_widget.getInputValue()
30- # Similar for 'type'
31+ # Similar for 'rcs_type' and 'target_rcs_type'.
32 rcs_type = None
33 if self.rcs_type_widget.hasValidInput():
34 rcs_type = self.rcs_type_widget.getInputValue()
35+ target_rcs_type = None
36+ if self.target_rcs_type_widget.hasValidInput():
37+ target_rcs_type = self.target_rcs_type_widget.getInputValue()
38
39 imports = self.context.search(
40- review_status=review_status, rcs_type=rcs_type)
41+ review_status=review_status, rcs_type=rcs_type,
42+ target_rcs_type=target_rcs_type)
43
44 self.batchnav = BatchNavigator(imports, self.request)
45
46
47=== modified file 'lib/lp/code/interfaces/codeimport.py'
48--- lib/lp/code/interfaces/codeimport.py 2016-10-13 14:25:08 +0000
49+++ lib/lp/code/interfaces/codeimport.py 2016-10-13 14:25:09 +0000
50@@ -267,11 +267,14 @@
51 def delete(id):
52 """Delete a CodeImport given its id."""
53
54- def search(review_status=None, rcs_type=None):
55+ def search(review_status=None, rcs_type=None, target_rcs_type=None):
56 """Find the CodeImports of the given status and type.
57
58 :param review_status: An entry from the `CodeImportReviewStatus`
59 schema, or None, which signifies 'any status'.
60 :param rcs_type: An entry from the `RevisionControlSystems`
61 schema, or None, which signifies 'any type'.
62+ :param target_rcs_type: An entry from the
63+ `TargetRevisionControlSystems` schema, or None, which signifies
64+ 'any type'.
65 """
66
67=== modified file 'lib/lp/code/model/codeimport.py'
68--- lib/lp/code/model/codeimport.py 2016-10-13 14:25:08 +0000
69+++ lib/lp/code/model/codeimport.py 2016-10-13 14:25:09 +0000
70@@ -364,11 +364,15 @@
71 def getByGitRepository(self, repository):
72 return CodeImport.selectOneBy(git_repository=repository)
73
74- def search(self, review_status=None, rcs_type=None):
75+ def search(self, review_status=None, rcs_type=None, target_rcs_type=None):
76 """See `ICodeImportSet`."""
77 clauses = []
78 if review_status is not None:
79 clauses.append(CodeImport.review_status == review_status)
80 if rcs_type is not None:
81 clauses.append(CodeImport.rcs_type == rcs_type)
82+ if target_rcs_type == TargetRevisionControlSystems.BZR:
83+ clauses.append(CodeImport.branch != None)
84+ elif target_rcs_type == TargetRevisionControlSystems.GIT:
85+ clauses.append(CodeImport.git_repository != None)
86 return IStore(CodeImport).find(CodeImport, *clauses)
87
88=== modified file 'lib/lp/code/stories/codeimport/xx-codeimport-view.txt'
89--- lib/lp/code/stories/codeimport/xx-codeimport-view.txt 2011-12-24 15:18:32 +0000
90+++ lib/lp/code/stories/codeimport/xx-codeimport-view.txt 2016-10-13 14:25:09 +0000
91@@ -1,10 +1,37 @@
92 Code imports
93 ============
94
95-The code imports overview page is linked of the main code page.
96+The sample data only contains imports that target Bazaar, but we'll create
97+another couple that target Git as well before we start.
98+
99+ >>> from zope.component import getUtility
100+ >>> from lp.code.enums import TargetRevisionControlSystems
101+ >>> from lp.code.tests.helpers import GitHostingFixture
102+ >>> from lp.registry.interfaces.person import IPersonSet
103+ >>> from lp.registry.interfaces.product import IProductSet
104+ >>> from lp.testing import login, logout
105+
106+ >>> login('test@canonical.com')
107+ >>> name12 = getUtility(IPersonSet).getByName('name12')
108+ >>> with GitHostingFixture():
109+ ... _ = factory.makeCodeImport(
110+ ... registrant=name12,
111+ ... context=getUtility(IProductSet).getByName('gnome-terminal'),
112+ ... branch_name=u'gnome-terminal',
113+ ... git_repo_url=u'git://git.gnome.org/gnome-terminal',
114+ ... target_rcs_type=TargetRevisionControlSystems.GIT)
115+ ... _ = factory.makeCodeImport(
116+ ... registrant=name12,
117+ ... context=getUtility(IProductSet).getByName('evolution'),
118+ ... branch_name=u'evolution',
119+ ... git_repo_url=u'https://git.gnome.org/browse/evolution',
120+ ... target_rcs_type=TargetRevisionControlSystems.GIT)
121+ >>> logout()
122+
123+The code imports overview page is linked off the main code page.
124
125 >>> browser.open('http://code.launchpad.dev')
126- >>> browser.getLink('1 imported branches').click()
127+ >>> browser.getLink('3 imported branches').click()
128 >>> print browser.title
129 Code Imports
130
131@@ -15,19 +42,21 @@
132 Code Imports
133
134 There are two CodeImports in the sample data and they both show up in
135-the page:
136+the page, as well as the two we created above:
137
138 >>> table = find_tag_by_id(browser.contents, 'code-import-listing')
139 >>> names = [extract_text(tr.td) for tr in table.tbody('tr')]
140 >>> for name in names:
141 ... print name
142- gnome-terminal/import
143- evolution/import
144+ ~vcs-imports/gnome-terminal/import
145+ ~vcs-imports/evolution/import
146+ ~name12/gnome-terminal/+git/gnome-terminal
147+ ~name12/evolution/+git/evolution
148
149 If we click on the code import's name, we go to the associated branch
150 for that import:
151
152- >>> browser.getLink('gnome-terminal/import').click()
153+ >>> browser.getLink('~vcs-imports/gnome-terminal/import').click()
154 >>> browser.url
155 'http://code.launchpad.dev/~vcs-imports/gnome-terminal/import'
156
157@@ -35,12 +64,11 @@
158 Filtering the code import list
159 ==============================
160
161-The code import listing is filterable, on review status and type.
162-There are no invalid imports in the sample data, so if we filter just
163-on them we'll see the "no imports found" message. It is worth
164-ensuring that the control for filtering on review status reads "Any"
165-by default, as the code that ensures this is poking at Zope 3
166-internals a bit.
167+The code import listing is filterable, on review status, source type, and
168+target type. There are no invalid imports in the sample data, so if we
169+filter just on them we'll see the "no imports found" message. It is worth
170+ensuring that the control for filtering on review status reads "Any" by
171+default, as the code that ensures this is poking at Zope 3 internals a bit.
172
173 >>> browser.open('http://code.launchpad.dev/+code-imports')
174 >>> control = browser.getControl(name="field.review_status")
175@@ -61,32 +89,47 @@
176 >>> rows = [extract_text(tr) for tr in table('tr')]
177 >>> for row in rows:
178 ... print row
179- Import Created Type Location Status
180- gnome-terminal/import 2007-... Subversion via ... http://sv... Reviewed
181- evolution/import 2007-... Concurrent Vers... :pserver:... Pending Review
182+ Import Created Source type Target type Location Status
183+ ~vcs-imports/gnome-terminal/import 2007-... Subversion via ... Bazaar http://sv... Reviewed
184+ ~vcs-imports/evolution/import 2007-... Concurrent Vers... Bazaar :pserver:... Pending Review
185+ ~name12/gnome-terminal/+git/gnome-terminal ... Git Git git://git... Reviewed
186+ ~name12/evolution/+git/evolution ... Git Git https://g... Reviewed
187
188-We can also filter by type.
189+We can also filter by source type.
190
191 >>> control = browser.getControl(name="field.rcs_type")
192 >>> control.displayValue
193 ['Any']
194- >>> browser.getControl(name="field.rcs_type").displayValue = [
195- ... "Concurrent Versions System"]
196- >>> browser.getControl(name="submit").click()
197- >>> table = find_tag_by_id(browser.contents, 'code-import-listing')
198- >>> rows = [extract_text(tr) for tr in table('tr')]
199- >>> for row in rows:
200- ... print row
201- Import Created Type Location Status
202- evolution/import 2007-... Concurrent Vers... :pserver:... Pending Review
203+ >>> control.displayValue = ["Concurrent Versions System"]
204+ >>> browser.getControl(name="submit").click()
205+ >>> table = find_tag_by_id(browser.contents, 'code-import-listing')
206+ >>> rows = [extract_text(tr) for tr in table('tr')]
207+ >>> for row in rows:
208+ ... print row
209+ Import Created Source type Target type Location Status
210+ ~vcs-imports/evolution/import 2007-... Concurrent Vers... Bazaar :pserver:... Pending Review
211+
212+... or by target type.
213+
214+ >>> browser.getControl(name="field.rcs_type").displayValue = ["Any"]
215+ >>> control = browser.getControl(name="field.target_rcs_type")
216+ >>> control.displayValue
217+ ['Any']
218+ >>> control.displayValue = ["Git"]
219+ >>> browser.getControl(name="submit").click()
220+ >>> table = find_tag_by_id(browser.contents, 'code-import-listing')
221+ >>> rows = [extract_text(tr) for tr in table('tr')]
222+ >>> for row in rows:
223+ ... print row
224+ Import Created Source type Target type Location Status
225+ ~name12/gnome-terminal/+git/gnome-terminal ... Git Git git://git... Reviewed
226+ ~name12/evolution/+git/evolution ... Git Git https://g... Reviewed
227
228 If we create a lot of imports, the listing view will be batched.
229
230- >>> from lp.testing import login, logout
231 >>> login('test@canonical.com')
232 >>> for i in range(10):
233 ... new_import = factory.makeCodeImport()
234-
235 >>> logout()
236
237 >>> browser.open('http://code.launchpad.dev/+code-imports')
238
239=== modified file 'lib/lp/code/templates/codeimport-list.pt'
240--- lib/lp/code/templates/codeimport-list.pt 2011-09-28 10:28:47 +0000
241+++ lib/lp/code/templates/codeimport-list.pt 2016-10-13 14:25:09 +0000
242@@ -19,6 +19,7 @@
243 <option label="NEW">New</option>
244 <option label="REVIEWED">Reviewed</option>
245 </select>
246+ from
247 <select name="rcs_type" tal:replace="structure view/rcs_type_widget">
248 <option label="">Any</option>
249 <option label="BZR">Bazaar</option>
250@@ -26,6 +27,12 @@
251 <option label="BZR_SVN">Subversion</option>
252 <option label="SVN">Subversion (legacy)</option>
253 </select>
254+ to
255+ <select name="target_rcs_type" tal:replace="structure view/target_rcs_type_widget">
256+ <option label="">Any</option>
257+ <option label="BZR">Bazaar</option>
258+ <option label="GIT">Git</option>
259+ </select>
260 <input type="submit" name="submit"/>
261 </form>
262
263@@ -45,7 +52,10 @@
264 Created
265 </th>
266 <th>
267- Type
268+ Source type
269+ </th>
270+ <th>
271+ Target type
272 </th>
273 <th>
274 Location
275@@ -60,11 +70,9 @@
276
277 <td>
278 <a href="code-import"
279- tal:attributes="href codeimport/branch/fmt:url">
280- <span tal:replace="codeimport/branch/target/name">
281+ tal:attributes="href codeimport/target/fmt:url">
282+ <span tal:replace="codeimport/target/unique_name">
283 target-name
284- </span>/<span tal:replace="codeimport/branch/name">
285- branch-name
286 </span>
287 </a>
288 </td>
289@@ -77,6 +85,10 @@
290 some type
291 </td>
292
293+ <td tal:content="codeimport/target_rcs_type/title">
294+ some type
295+ </td>
296+
297 <td tal:content="codeimport/getImportDetailsForDisplay">
298 some details
299 </td>