Merge lp:~thumper/launchpad/imports-urls into lp:launchpad/db-devel
- imports-urls
- Merge into db-devel
Status: | Merged |
---|---|
Approved by: | Jonathan Lange |
Approved revision: | not available |
Merged at revision: | not available |
Proposed branch: | lp:~thumper/launchpad/imports-urls |
Merge into: | lp:launchpad/db-devel |
Diff against target: |
1395 lines (+268/-353) 23 files modified
.bzrignore (+3/-0) database/sampledata/current-dev.sql (+2/-2) database/sampledata/current.sql (+2/-2) database/schema/comments.sql (+1/-1) database/schema/patch-2207-26-0.sql (+28/-0) lib/lp/code/browser/branch.py (+2/-2) lib/lp/code/browser/codeimport.py (+84/-81) lib/lp/code/configure.zcml (+1/-2) lib/lp/code/doc/codeimport-event.txt (+15/-75) lib/lp/code/doc/codeimport.txt (+18/-20) lib/lp/code/enums.py (+19/-0) lib/lp/code/interfaces/codeimport.py (+7/-24) lib/lp/code/mail/codeimport.py (+6/-11) lib/lp/code/model/codeimport.py (+17/-30) lib/lp/code/model/codeimportevent.py (+3/-4) lib/lp/code/model/tests/test_codeimport.py (+3/-3) lib/lp/code/stories/codeimport/xx-admin-codeimport.txt (+5/-5) lib/lp/code/stories/codeimport/xx-create-codeimport.txt (+1/-1) lib/lp/code/templates/branch-import-details.pt (+4/-4) lib/lp/codehosting/codeimport/tests/test_worker.py (+7/-10) lib/lp/codehosting/codeimport/tests/test_workermonitor.py (+5/-7) lib/lp/codehosting/codeimport/worker.py (+24/-56) lib/lp/testing/factory.py (+11/-13) |
To merge this branch: | bzr merge lp:~thumper/launchpad/imports-urls |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jonathan Lange (community) | db | Approve | |
Stuart Bishop (community) | db | Approve | |
Michael Hudson-Doyle | Approve | ||
Review via email: mp+17172@code.launchpad.net |
Commit message
Unify the svn_branch_url and git_repo_url into a single url field in the code import table.
Description of the change
Tim Penhey (thumper) wrote : | # |
Michael Hudson-Doyle (mwhudson) wrote : | # |
Hi Tim,
Thanks for plugging your way through this!
A few tiny comments below.
I look forward to when we can collapse the CVS stuff into a URL
somehow or other as well, but this is a good start :-)
Cheers,
mwh
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -15,7 +15,6 @@
> 'CodeImportView',
> ]
>
> -from cgi import escape
>
> from BeautifulSoup import BeautifulSoup
> from zope.app.form import CustomWidgetFactory
> @@ -24,16 +23,16 @@
> from zope.component import getUtility
> from zope.formlib import form
> from zope.interface import Interface
> -from zope.schema import Choice, TextLine
> +from zope.schema import Choice
>
> from canonical.
> from canonical.launchpad import _
> +from canonical.
> from canonical.
> from lp.code.enums import (
> BranchSubscript
> CodeImportRevie
> RevisionControl
> -from lp.code.
> from lp.code.
> get_branch_
> from lp.code.
> @@ -128,8 +127,7 @@
>
> custom_
> custom_
> - custom_
> - custom_
> + custom_
>
> @cachedproperty
> def _super_user(self):
> @@ -173,56 +171,73 @@
> canonical_
> code_import.
>
> - def _validateSVN(self, svn_branch_url, existing_
> - """If the user has specified a subversion url, we need
> - to make sure that there isn't already an import with
> - that url."""
> - if svn_branch_url is None:
> + def _validateURL(self, url, existing_
> + """If the user has specified a url, we need to make sure that there
> + isn't already an import with that url."""
> + if url is None:
> self.setSeconda
> - 'svn_branch_url', 'Enter the URL of a Subversion branch.')
> + field_name, 'Enter the URL of a foreign VCS branch.')
> else:
> - code_import = getUtility(
> - svn_branch_url)
> + code_import = getUtility(
> if (code_import is not None and
> code_import != existing_import):
> self.setFieldError(
> - 'svn_branch_url',
> + field_name,
> structured("""
> - This Subversion branch URL is already specified for
> + ...
Tim Penhey (thumper) wrote : | # |
On Tue, 12 Jan 2010 15:59:43 Michael Hudson wrote:
> Review: Approve
> Hi Tim,
>
> Thanks for plugging your way through this!
>
> A few tiny comments below.
>
> I look forward to when we can collapse the CVS stuff into a URL
> somehow or other as well, but this is a good start :-)
>
> Cheers,
> mwh
Addressed. Thanks for the review of this tedious branch.
Tim
Stuart Bishop (stub) wrote : | # |
Fine. Discussed the rationale for not addressing the git/hg URL bug on IRC and that is fine.
Patch number patch-2207-26-0.sql
Jonathan Lange (jml) wrote : | # |
This looks like an incremental improvement. It would be nice to move the cvs stuff in as well, but the patch is big enough as is. Please file a bug and mention it on this review.
Tim Penhey (thumper) wrote : | # |
On Wed, 13 Jan 2010 10:09:04 Jonathan Lange wrote:
> Review: Approve db
> This looks like an incremental improvement. It would be nice to move the
> cvs stuff in as well, but the patch is big enough as is. Please file a bug
> and mention it on this review.
>
Bug 506631 filed (cvs imports should use the url field instead of root and
module).
Preview Diff
1 | === modified file '.bzrignore' |
2 | --- .bzrignore 2010-01-10 22:23:32 +0000 |
3 | +++ .bzrignore 2010-01-12 21:08:17 +0000 |
4 | @@ -53,4 +53,7 @@ |
5 | bzr.dev |
6 | _trial_temp |
7 | lazr-js |
8 | +.bazaar |
9 | +.cache |
10 | +.subversion |
11 | lib/canonical/buildd/launchpad-files |
12 | |
13 | === modified file 'database/sampledata/current-dev.sql' |
14 | --- database/sampledata/current-dev.sql 2010-01-12 02:24:06 +0000 |
15 | +++ database/sampledata/current-dev.sql 2010-01-12 21:08:17 +0000 |
16 | @@ -1724,8 +1724,8 @@ |
17 | |
18 | ALTER TABLE codeimport DISABLE TRIGGER ALL; |
19 | |
20 | -INSERT INTO codeimport (id, branch, date_created, registrant, rcs_type, svn_branch_url, cvs_root, cvs_module, review_status, date_last_successful, owner, assignee, update_interval, git_repo_url) VALUES (1, 75, '2007-06-25 20:04:04.226605', 52, 2, 'http://svn.example.org/svnroot/gnome-terminal/trunk', NULL, NULL, 20, NULL, 52, NULL, NULL, NULL); |
21 | -INSERT INTO codeimport (id, branch, date_created, registrant, rcs_type, svn_branch_url, cvs_root, cvs_module, review_status, date_last_successful, owner, assignee, update_interval, git_repo_url) VALUES (2, 76, '2007-06-25 20:04:04.379285', 52, 1, NULL, ':pserver:anonymous@anoncvs.example.org:/cvs/gnome', 'evolution', 1, NULL, 52, NULL, NULL, NULL); |
22 | +INSERT INTO codeimport (id, branch, date_created, registrant, rcs_type, cvs_root, cvs_module, review_status, date_last_successful, owner, assignee, update_interval, url) VALUES (1, 75, '2007-06-25 20:04:04.226605', 52, 2, NULL, NULL, 20, NULL, 52, NULL, NULL, 'http://svn.example.org/svnroot/gnome-terminal/trunk'); |
23 | +INSERT INTO codeimport (id, branch, date_created, registrant, rcs_type, cvs_root, cvs_module, review_status, date_last_successful, owner, assignee, update_interval, url) VALUES (2, 76, '2007-06-25 20:04:04.379285', 52, 1, ':pserver:anonymous@anoncvs.example.org:/cvs/gnome', 'evolution', 1, NULL, 52, NULL, NULL, NULL); |
24 | |
25 | |
26 | ALTER TABLE codeimport ENABLE TRIGGER ALL; |
27 | |
28 | === modified file 'database/sampledata/current.sql' |
29 | --- database/sampledata/current.sql 2010-01-12 02:24:06 +0000 |
30 | +++ database/sampledata/current.sql 2010-01-12 21:08:17 +0000 |
31 | @@ -1706,8 +1706,8 @@ |
32 | |
33 | ALTER TABLE codeimport DISABLE TRIGGER ALL; |
34 | |
35 | -INSERT INTO codeimport (id, branch, date_created, registrant, rcs_type, svn_branch_url, cvs_root, cvs_module, review_status, date_last_successful, owner, assignee, update_interval, git_repo_url) VALUES (1, 75, '2007-06-25 20:04:04.226605', 52, 2, 'http://svn.example.org/svnroot/gnome-terminal/trunk', NULL, NULL, 20, NULL, 52, NULL, NULL, NULL); |
36 | -INSERT INTO codeimport (id, branch, date_created, registrant, rcs_type, svn_branch_url, cvs_root, cvs_module, review_status, date_last_successful, owner, assignee, update_interval, git_repo_url) VALUES (2, 76, '2007-06-25 20:04:04.379285', 52, 1, NULL, ':pserver:anonymous@anoncvs.example.org:/cvs/gnome', 'evolution', 1, NULL, 52, NULL, NULL, NULL); |
37 | +INSERT INTO codeimport (id, branch, date_created, registrant, rcs_type, cvs_root, cvs_module, review_status, date_last_successful, owner, assignee, update_interval, url) VALUES (1, 75, '2007-06-25 20:04:04.226605', 52, 2, NULL, NULL, 20, NULL, 52, NULL, NULL, 'http://svn.example.org/svnroot/gnome-terminal/trunk'); |
38 | +INSERT INTO codeimport (id, branch, date_created, registrant, rcs_type, cvs_root, cvs_module, review_status, date_last_successful, owner, assignee, update_interval, url) VALUES (2, 76, '2007-06-25 20:04:04.379285', 52, 1, ':pserver:anonymous@anoncvs.example.org:/cvs/gnome', 'evolution', 1, NULL, 52, NULL, NULL, NULL); |
39 | |
40 | |
41 | ALTER TABLE codeimport ENABLE TRIGGER ALL; |
42 | |
43 | === modified file 'database/schema/comments.sql' |
44 | --- database/schema/comments.sql 2010-01-11 04:46:04 +0000 |
45 | +++ database/schema/comments.sql 2010-01-12 21:08:17 +0000 |
46 | @@ -321,7 +321,7 @@ |
47 | COMMENT ON COLUMN CodeImport.owner IS 'The person who is currently responsible for keeping the import details up to date, initially set to the registrant. This person can edit some of the details of the code import branch.'; |
48 | COMMENT ON COLUMN CodeImport.review_status IS 'Whether this code import request has been reviewed, and whether it was accepted.'; |
49 | COMMENT ON COLUMN CodeImport.rcs_type IS 'The revision control system used by the import source. The value is defined in dbschema.RevisionControlSystems.'; |
50 | -COMMENT ON COLUMN CodeImport.svn_branch_url IS 'The URL of the Subversion branch for this import.'; |
51 | +COMMENT ON COLUMN CodeImport.url IS 'The URL of the foreign VCS branch for this import.'; |
52 | COMMENT ON COLUMN CodeImport.cvs_root IS 'The $CVSROOT details, probably of the form :pserver:user@host:/path.'; |
53 | COMMENT ON COLUMN CodeImport.cvs_module IS 'The module in cvs_root to import, often the name of the project.'; |
54 | COMMENT ON COLUMN CodeImport.date_last_successful IS 'When this code import last succeeded. NULL if this import has never succeeded.'; |
55 | |
56 | === added file 'database/schema/patch-2207-26-0.sql' |
57 | --- database/schema/patch-2207-26-0.sql 1970-01-01 00:00:00 +0000 |
58 | +++ database/schema/patch-2207-26-0.sql 2010-01-12 21:08:17 +0000 |
59 | @@ -0,0 +1,28 @@ |
60 | +SET client_min_messages=ERROR; |
61 | + |
62 | +ALTER TABLE CodeImport ADD COLUMN url text; |
63 | +UPDATE CodeImport SET url = git_repo_url WHERE rcs_type = 4; |
64 | +UPDATE CodeImport SET url = svn_branch_url WHERE rcs_type IN (2, 3); |
65 | +DROP INDEX codeimport__svn_branch_url__idx; |
66 | +DROP INDEX codeimport__git_repo_url__idx; |
67 | +ALTER TABLE CodeImport DROP CONSTRAINT valid_vcs_details; |
68 | +ALTER TABLE CodeImport ADD CONSTRAINT "valid_vcs_details" CHECK ( |
69 | +CASE |
70 | + WHEN rcs_type = 1 |
71 | + THEN cvs_root IS NOT NULL AND cvs_root <> ''::text AND cvs_module IS NOT NULL AND cvs_module <> ''::text |
72 | + AND url IS NULL |
73 | + WHEN rcs_type IN (2, 3) |
74 | + THEN cvs_root IS NULL AND cvs_module IS NULL |
75 | + AND url IS NOT NULL AND valid_absolute_url(url) |
76 | + WHEN rcs_type IN (4, 5) |
77 | + -- Git and mercurial imports are not checked for valid urls right now, |
78 | + -- this is a bug - 506146 |
79 | + THEN cvs_root IS NULL AND cvs_module IS NULL AND url IS NOT NULL |
80 | + ELSE false |
81 | +END); |
82 | +ALTER TABLE CodeImport DROP COLUMN git_repo_url; |
83 | +ALTER TABLE CodeImport DROP COLUMN svn_branch_url; |
84 | + |
85 | +CREATE UNIQUE INDEX codeimport__url__idx ON CodeImport USING btree (url) WHERE (url is NOT NULL); |
86 | + |
87 | +INSERT INTO LaunchpadDatabaseRevision VALUES (2207, 26, 0); |
88 | |
89 | === modified file 'lib/lp/code/browser/branch.py' |
90 | --- lib/lp/code/browser/branch.py 2010-01-07 05:03:46 +0000 |
91 | +++ lib/lp/code/browser/branch.py 2010-01-12 21:08:17 +0000 |
92 | @@ -511,8 +511,8 @@ |
93 | """True if an imported branch's SVN URL is HTTP or HTTPS.""" |
94 | # You should only be calling this if it's an SVN code import |
95 | assert self.context.code_import |
96 | - assert self.context.code_import.svn_branch_url |
97 | - url = self.context.code_import.svn_branch_url |
98 | + url = self.context.code_import.url |
99 | + assert url |
100 | # https starts with http too! |
101 | return url.startswith("http") |
102 | |
103 | |
104 | === modified file 'lib/lp/code/browser/codeimport.py' |
105 | --- lib/lp/code/browser/codeimport.py 2009-12-08 02:32:03 +0000 |
106 | +++ lib/lp/code/browser/codeimport.py 2010-01-12 21:08:17 +0000 |
107 | @@ -15,7 +15,6 @@ |
108 | 'CodeImportView', |
109 | ] |
110 | |
111 | -from cgi import escape |
112 | |
113 | from BeautifulSoup import BeautifulSoup |
114 | from zope.app.form import CustomWidgetFactory |
115 | @@ -24,16 +23,16 @@ |
116 | from zope.component import getUtility |
117 | from zope.formlib import form |
118 | from zope.interface import Interface |
119 | -from zope.schema import Choice, TextLine |
120 | +from zope.schema import Choice |
121 | |
122 | from canonical.cachedproperty import cachedproperty |
123 | from canonical.launchpad import _ |
124 | +from canonical.launchpad.fields import URIField |
125 | from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities |
126 | from lp.code.enums import ( |
127 | BranchSubscriptionDiffSize, BranchSubscriptionNotificationLevel, |
128 | CodeImportReviewStatus, CodeReviewNotificationLevel, |
129 | RevisionControlSystems) |
130 | -from lp.code.interfaces.branch import branch_name_validator |
131 | from lp.code.interfaces.branchnamespace import ( |
132 | get_branch_namespace, IBranchNamespacePolicy) |
133 | from lp.code.interfaces.codeimport import ( |
134 | @@ -128,8 +127,7 @@ |
135 | |
136 | custom_widget('cvs_root', StrippedTextWidget, displayWidth=50) |
137 | custom_widget('cvs_module', StrippedTextWidget, displayWidth=20) |
138 | - custom_widget('svn_branch_url', URIWidget, displayWidth=50) |
139 | - custom_widget('git_repo_url', URIWidget, displayWidth=50) |
140 | + custom_widget('url', URIWidget, displayWidth=50) |
141 | |
142 | @cachedproperty |
143 | def _super_user(self): |
144 | @@ -173,56 +171,73 @@ |
145 | canonical_url(code_import.branch), |
146 | code_import.branch.unique_name)) |
147 | |
148 | - def _validateSVN(self, svn_branch_url, existing_import=None): |
149 | - """If the user has specified a subversion url, we need |
150 | - to make sure that there isn't already an import with |
151 | - that url.""" |
152 | - if svn_branch_url is None: |
153 | + def _validateURL(self, url, existing_import=None, field_name='url'): |
154 | + """If the user has specified a url, we need to make sure that there |
155 | + isn't already an import with that url.""" |
156 | + if url is None: |
157 | self.setSecondaryFieldError( |
158 | - 'svn_branch_url', 'Enter the URL of a Subversion branch.') |
159 | + field_name, 'Enter the URL of a foreign VCS branch.') |
160 | else: |
161 | - code_import = getUtility(ICodeImportSet).getBySVNDetails( |
162 | - svn_branch_url) |
163 | + code_import = getUtility(ICodeImportSet).getByURL(url) |
164 | if (code_import is not None and |
165 | code_import != existing_import): |
166 | self.setFieldError( |
167 | - 'svn_branch_url', |
168 | + field_name, |
169 | structured(""" |
170 | - This Subversion branch URL is already specified for |
171 | + This foreign branch URL is already specified for |
172 | the imported branch <a href="%s">%s</a>.""", |
173 | canonical_url(code_import.branch), |
174 | code_import.branch.unique_name)) |
175 | |
176 | - def _validateGit(self, git_repo_url, existing_import=None): |
177 | - """If the user has specified a git repo url, we need |
178 | - to make sure that there isn't already an import with |
179 | - that url.""" |
180 | - if git_repo_url is None: |
181 | - self.setSecondaryFieldError( |
182 | - 'git_repo_url', 'Enter the URL of a Git repo.') |
183 | - else: |
184 | - code_import = getUtility(ICodeImportSet).getByGitDetails( |
185 | - git_repo_url) |
186 | - if (code_import is not None and |
187 | - code_import != existing_import): |
188 | - self.setFieldError( |
189 | - 'git_repo_url', |
190 | - structured(""" |
191 | - This Git repository URL is already specified for |
192 | - the imported branch <a href="%s">%s</a>.""", |
193 | - escape(canonical_url(code_import.branch)), |
194 | - escape(code_import.branch.unique_name))) |
195 | + |
196 | + |
197 | +class NewCodeImportForm(Interface): |
198 | + """The fields presented on the form for editing a code import.""" |
199 | + |
200 | + use_template( |
201 | + ICodeImport, |
202 | + ['product', 'rcs_type', 'cvs_root', 'cvs_module']) |
203 | + |
204 | + svn_branch_url = URIField( |
205 | + title=_("Branch URL"), required=False, |
206 | + description=_( |
207 | + "The URL of a Subversion branch, starting with svn:// or" |
208 | + " http(s)://. Only trunk branches are imported."), |
209 | + allowed_schemes=["http", "https", "svn"], |
210 | + allow_userinfo=False, |
211 | + allow_port=True, |
212 | + allow_query=False, |
213 | + allow_fragment=False, |
214 | + trailing_slash=False) |
215 | + |
216 | + git_repo_url = URIField( |
217 | + title=_("Repo URL"), required=False, |
218 | + description=_( |
219 | + "The URL of the git repository. The MASTER branch will be " |
220 | + "imported."), |
221 | + allowed_schemes=["git"], |
222 | + allow_userinfo=False, # Only anonymous access is supported. |
223 | + allow_port=True, |
224 | + allow_query=False, |
225 | + allow_fragment=False, |
226 | + trailing_slash=False) |
227 | + |
228 | + branch_name = copy_field( |
229 | + IBranch['name'], |
230 | + __name__='branch_name', |
231 | + title=_('Branch Name'), |
232 | + description=_( |
233 | + "This will be used in the branch URL to identify the " |
234 | + "imported branch. Examples: main, trunk."), |
235 | + ) |
236 | |
237 | |
238 | class CodeImportNewView(CodeImportBaseView): |
239 | """The view to request a new code import.""" |
240 | |
241 | + schema = NewCodeImportForm |
242 | for_input = True |
243 | label = 'Request a code import' |
244 | - field_names = [ |
245 | - 'product', 'rcs_type', 'svn_branch_url', 'cvs_root', 'cvs_module', |
246 | - 'git_repo_url', |
247 | - ] |
248 | |
249 | custom_widget('rcs_type', LaunchpadRadioWidget) |
250 | |
251 | @@ -236,19 +251,6 @@ |
252 | """Cancel should take the user back to the root site.""" |
253 | return '/' |
254 | |
255 | - def setUpFields(self): |
256 | - CodeImportBaseView.setUpFields(self) |
257 | - # Add in the field for the branch name. |
258 | - name_field = form.Fields( |
259 | - TextLine( |
260 | - __name__='branch_name', |
261 | - title=_('Branch Name'), required=True, description=_( |
262 | - "This will be used in the branch URL to identify the " |
263 | - "imported branch. Examples: main, trunk."), |
264 | - constraint=branch_name_validator), |
265 | - render_context=self.render_context) |
266 | - self.form_fields = self.form_fields + name_field |
267 | - |
268 | def setUpWidgets(self): |
269 | CodeImportBaseView.setUpWidgets(self) |
270 | |
271 | @@ -268,18 +270,31 @@ |
272 | self.rcs_type_git = str(git_button) |
273 | self.rcs_type_emptymarker = str(empty_marker) |
274 | |
275 | + def _getImportLocation(self, data): |
276 | + """Return the import location based on type.""" |
277 | + rcs_type = data['rcs_type'] |
278 | + if rcs_type == RevisionControlSystems.CVS: |
279 | + return data.get('cvs_root'), data.get('cvs_module'), None |
280 | + elif rcs_type == RevisionControlSystems.BZR_SVN: |
281 | + return None, None, data.get('svn_branch_url') |
282 | + elif rcs_type == RevisionControlSystems.GIT: |
283 | + return None, None, data.get('git_repo_url') |
284 | + else: |
285 | + raise AssertionError( |
286 | + 'Unexpected revision control type %r.' % rcs_type) |
287 | + |
288 | def _create_import(self, data, status): |
289 | """Create the code import.""" |
290 | + cvs_root, cvs_module, url = self._getImportLocation(data) |
291 | return getUtility(ICodeImportSet).new( |
292 | registrant=self.user, |
293 | product=data['product'], |
294 | branch_name=data['branch_name'], |
295 | rcs_type=data['rcs_type'], |
296 | - svn_branch_url=data['svn_branch_url'], |
297 | - cvs_root=data['cvs_root'], |
298 | - cvs_module=data['cvs_module'], |
299 | - review_status=status, |
300 | - git_repo_url=data['git_repo_url']) |
301 | + url=url, |
302 | + cvs_root=cvs_root, |
303 | + cvs_module=cvs_module, |
304 | + review_status=status) |
305 | |
306 | def _setBranchExists(self, existing_branch): |
307 | """Set a field error indicating that the branch already exists.""" |
308 | @@ -357,19 +372,13 @@ |
309 | # Make sure fields for unselected revision control systems |
310 | # are blanked out: |
311 | if rcs_type == RevisionControlSystems.CVS: |
312 | - data['svn_branch_url'] = None |
313 | - data['git_repo_url'] = None |
314 | self._validateCVS(data.get('cvs_root'), data.get('cvs_module')) |
315 | elif rcs_type == RevisionControlSystems.BZR_SVN: |
316 | - data['cvs_root'] = None |
317 | - data['cvs_module'] = None |
318 | - data['git_repo_url'] = None |
319 | - self._validateSVN(data.get('svn_branch_url')) |
320 | + self._validateURL( |
321 | + data.get('svn_branch_url'), field_name='svn_branch_url') |
322 | elif rcs_type == RevisionControlSystems.GIT: |
323 | - data['cvs_root'] = None |
324 | - data['cvs_module'] = None |
325 | - data['svn_branch_url'] = None |
326 | - self._validateGit(data.get('git_repo_url')) |
327 | + self._validateURL( |
328 | + data.get('git_repo_url'), field_name='git_repo_url') |
329 | else: |
330 | raise AssertionError( |
331 | 'Unexpected revision control type %r.' % rcs_type) |
332 | @@ -380,7 +389,7 @@ |
333 | |
334 | use_template( |
335 | ICodeImport, |
336 | - ['svn_branch_url', 'cvs_root', 'cvs_module', 'git_repo_url']) |
337 | + ['url', 'cvs_root', 'cvs_module']) |
338 | whiteboard = copy_field(IBranch['whiteboard']) |
339 | |
340 | |
341 | @@ -457,15 +466,12 @@ |
342 | # If the import is a Subversion import, then omit the CVS |
343 | # fields, and vice versa. |
344 | if self.code_import.rcs_type == RevisionControlSystems.CVS: |
345 | - self.form_fields = self.form_fields.omit( |
346 | - 'svn_branch_url', 'git_repo_url') |
347 | + self.form_fields = self.form_fields.omit('url') |
348 | elif self.code_import.rcs_type in (RevisionControlSystems.SVN, |
349 | - RevisionControlSystems.BZR_SVN): |
350 | - self.form_fields = self.form_fields.omit( |
351 | - 'cvs_root', 'cvs_module', 'git_repo_url') |
352 | - elif self.code_import.rcs_type == RevisionControlSystems.GIT: |
353 | - self.form_fields = self.form_fields.omit( |
354 | - 'cvs_root', 'cvs_module', 'svn_branch_url') |
355 | + RevisionControlSystems.BZR_SVN, |
356 | + RevisionControlSystems.GIT): |
357 | + self.form_fields = self.form_fields.omit( |
358 | + 'cvs_root', 'cvs_module') |
359 | else: |
360 | raise AssertionError('Unknown rcs_type for code import.') |
361 | |
362 | @@ -496,12 +502,9 @@ |
363 | data.get('cvs_root'), data.get('cvs_module'), |
364 | self.code_import) |
365 | elif self.code_import.rcs_type in (RevisionControlSystems.SVN, |
366 | - RevisionControlSystems.BZR_SVN): |
367 | - self._validateSVN( |
368 | - data.get('svn_branch_url'), self.code_import) |
369 | - elif self.code_import.rcs_type == RevisionControlSystems.GIT: |
370 | - self._validateGit( |
371 | - data.get('git_repo_url'), self.code_import) |
372 | + RevisionControlSystems.BZR_SVN, |
373 | + RevisionControlSystems.GIT): |
374 | + self._validateURL(data.get('url'), self.code_import) |
375 | else: |
376 | raise AssertionError('Unknown rcs_type for code import.') |
377 | |
378 | |
379 | === modified file 'lib/lp/code/configure.zcml' |
380 | --- lib/lp/code/configure.zcml 2010-01-06 14:14:35 +0000 |
381 | +++ lib/lp/code/configure.zcml 2010-01-12 21:08:17 +0000 |
382 | @@ -749,8 +749,7 @@ |
383 | rcs_type |
384 | cvs_root |
385 | cvs_module |
386 | - svn_branch_url |
387 | - git_repo_url |
388 | + url |
389 | date_last_successful |
390 | source_product_series |
391 | update_interval |
392 | |
393 | === modified file 'lib/lp/code/doc/codeimport-event.txt' |
394 | --- lib/lp/code/doc/codeimport-event.txt 2009-07-01 13:16:44 +0000 |
395 | +++ lib/lp/code/doc/codeimport-event.txt 2010-01-12 21:08:17 +0000 |
396 | @@ -95,22 +95,11 @@ |
397 | |
398 | >>> nopriv = getUtility(IPersonSet).getByName('no-priv') |
399 | |
400 | - >>> def new_code_import(name, **kw_details): |
401 | - ... vcs_imports = getUtility(ILaunchpadCelebrities).vcs_imports |
402 | - ... product = getUtility(IProductSet).getByName('firefox') |
403 | - ... namespace = get_branch_namespace(vcs_imports, product=product) |
404 | - ... import_branch = namespace.createBranch( |
405 | - ... BranchType.IMPORTED, name, vcs_imports, title='Import branch') |
406 | - ... return CodeImport( |
407 | - ... registrant=nopriv, owner=nopriv, branch=import_branch, |
408 | - ... **kw_details) |
409 | - |
410 | First we create a Subversion import. |
411 | |
412 | >>> from lp.code.enums import RevisionControlSystems |
413 | - >>> svn_url = 'svn://svn.example.com/trunk' |
414 | - >>> svn_import = new_code_import('svn-trunk', |
415 | - ... rcs_type=RevisionControlSystems.SVN, svn_branch_url=svn_url) |
416 | + >>> svn_import = factory.makeCodeImport( |
417 | + ... svn_branch_url='svn://svn.example.com/trunk') |
418 | |
419 | CodeImportSet.newCreate creates an event from the new CodeImport object |
420 | and the person that created it. Here, the creator is the nopriv user. |
421 | @@ -131,11 +120,11 @@ |
422 | |
423 | >>> print_items(svn_create_event) |
424 | CODE_IMPORT <muted> |
425 | - OWNER u'52' |
426 | + OWNER ... |
427 | REVIEW_STATUS u'NEW' |
428 | ASSIGNEE None |
429 | UPDATE_INTERVAL None |
430 | - SVN_BRANCH_URL u'svn://svn.example.com/trunk' |
431 | + URL u'svn://svn.example.com/trunk' |
432 | |
433 | The database IDs of the CodeImport is also recorded. It is useful to |
434 | collate events associated with deleted CodeImport objects. |
435 | @@ -149,14 +138,13 @@ |
436 | import source. For a CVS import, CVS details are recorded instead of the |
437 | Subversion URL. |
438 | |
439 | - >>> cvs_import = new_code_import('cvs-main', |
440 | - ... rcs_type=RevisionControlSystems.CVS, |
441 | + >>> cvs_import = factory.makeCodeImport( |
442 | ... cvs_root=':pserver:anonymous@cvs.example.com:/cvsroot', |
443 | ... cvs_module='hello') |
444 | >>> cvs_create_event = event_set.newCreate(cvs_import, nopriv) |
445 | >>> print_items(cvs_create_event) |
446 | CODE_IMPORT <muted> |
447 | - OWNER u'52' |
448 | + OWNER ... |
449 | REVIEW_STATUS u'NEW' |
450 | ASSIGNEE None |
451 | UPDATE_INTERVAL None |
452 | @@ -165,17 +153,17 @@ |
453 | |
454 | And for a Git import, the git details are recorded. |
455 | |
456 | - >>> git_import = new_code_import('git-main', |
457 | - ... rcs_type=RevisionControlSystems.GIT, |
458 | + >>> git_import = factory.makeCodeImport( |
459 | ... git_repo_url='git://git.example.org/main.git') |
460 | >>> git_create_event = event_set.newCreate(git_import, nopriv) |
461 | >>> print_items(git_create_event) |
462 | CODE_IMPORT <muted> |
463 | - OWNER u'52' |
464 | - REVIEW_STATUS u'NEW' |
465 | + OWNER ... |
466 | + REVIEW_STATUS u'REVIEWED' |
467 | ASSIGNEE None |
468 | UPDATE_INTERVAL None |
469 | - GIT_REPO_URL u'git://git.example.org/main.git' |
470 | + URL u'git://git.example.org/main.git' |
471 | + |
472 | |
473 | == MODIFY == |
474 | |
475 | @@ -204,7 +192,8 @@ |
476 | Then changes can be applied. |
477 | |
478 | >>> from lp.code.enums import CodeImportReviewStatus |
479 | - >>> svn_import.review_status = CodeImportReviewStatus.REVIEWED |
480 | + >>> removeSecurityProxy(svn_import).review_status = ( |
481 | + ... CodeImportReviewStatus.REVIEWED) |
482 | |
483 | After applying changes, the newModify method can create an event that |
484 | details the changes that have been applied. |
485 | @@ -229,12 +218,12 @@ |
486 | |
487 | >>> print_items(modify_event) |
488 | CODE_IMPORT <muted> |
489 | - OWNER u'52' |
490 | + OWNER ... |
491 | REVIEW_STATUS u'REVIEWED' |
492 | OLD_REVIEW_STATUS u'NEW' |
493 | ASSIGNEE None |
494 | UPDATE_INTERVAL None |
495 | - SVN_BRANCH_URL u'svn://svn.example.com/trunk' |
496 | + URL u'svn://svn.example.com/trunk' |
497 | |
498 | If no change of interest is found, no event is created. |
499 | |
500 | @@ -245,55 +234,6 @@ |
501 | >>> len(list(event_set.getAll())) == old_event_set_len |
502 | True |
503 | |
504 | -In most events, only the source details for the selected version control |
505 | -system are recorded. If the rcs_type changes, we record old and new |
506 | -values for all changed attributes to explicitly represent transitions to |
507 | -None and from None. |
508 | - |
509 | - >>> token = event_set.beginModify(cvs_import) |
510 | - >>> cvs_import.rcs_type = RevisionControlSystems.SVN |
511 | - >>> cvs_import.svn_branch_url = u'svn://svn.example.com/from-cvs' |
512 | - >>> cvs_import.cvs_root = None |
513 | - >>> cvs_import.cvs_module = None |
514 | - >>> modify_event = event_set.newModify(cvs_import, nopriv, token) |
515 | - >>> print_items(modify_event) |
516 | - CODE_IMPORT <muted> |
517 | - OWNER u'52' |
518 | - REVIEW_STATUS u'NEW' |
519 | - ASSIGNEE None |
520 | - UPDATE_INTERVAL None |
521 | - CVS_ROOT None |
522 | - CVS_MODULE None |
523 | - OLD_CVS_ROOT u':pserver:anonymous@cvs.example.com:/cvsroot' |
524 | - OLD_CVS_MODULE u'hello' |
525 | - SVN_BRANCH_URL u'svn://svn.example.com/from-cvs' |
526 | - OLD_SVN_BRANCH_URL None |
527 | - |
528 | -Aside from source details changes, MODIFY events can record changes to |
529 | -the owner, the review_status, the assignee, and the update_interval of a |
530 | -code import. |
531 | - |
532 | - >>> from datetime import timedelta |
533 | - >>> sample_owner = getUtility(IPersonSet).getByName('name12') |
534 | - >>> sample_assignee = getUtility(IPersonSet).getByName('ddaa') |
535 | - >>> token = event_set.beginModify(svn_import) |
536 | - >>> svn_import.owner = sample_owner |
537 | - >>> svn_import.review_status = CodeImportReviewStatus.SUSPENDED |
538 | - >>> svn_import.assignee = sample_assignee |
539 | - >>> svn_import.update_interval = timedelta(hours=1) |
540 | - >>> modify_event = event_set.newModify(svn_import, nopriv, token) |
541 | - >>> print_items(modify_event) |
542 | - CODE_IMPORT <muted> |
543 | - OWNER u'12' |
544 | - OLD_OWNER u'52' |
545 | - REVIEW_STATUS u'SUSPENDED' |
546 | - OLD_REVIEW_STATUS u'REVIEWED' |
547 | - ASSIGNEE u'23' |
548 | - OLD_ASSIGNEE None |
549 | - UPDATE_INTERVAL u'1:00:00' |
550 | - OLD_UPDATE_INTERVAL None |
551 | - SVN_BRANCH_URL u'svn://svn.example.com/trunk' |
552 | - |
553 | |
554 | === REQUEST === |
555 | |
556 | |
557 | === modified file 'lib/lp/code/doc/codeimport.txt' |
558 | --- lib/lp/code/doc/codeimport.txt 2009-12-08 19:21:29 +0000 |
559 | +++ lib/lp/code/doc/codeimport.txt 2010-01-12 21:08:17 +0000 |
560 | @@ -59,6 +59,7 @@ |
561 | Subversion via CSCVS |
562 | Subversion via bzr-svn |
563 | Git |
564 | + Mercurial |
565 | |
566 | |
567 | Import from CVS |
568 | @@ -128,7 +129,7 @@ |
569 | >>> svn_url = 'svn://svn.example.com/trunk' |
570 | >>> svn_import = code_import_set.new( |
571 | ... registrant=nopriv, product=product, branch_name='trunk-svn', |
572 | - ... rcs_type=svn, svn_branch_url=svn_url) |
573 | + ... rcs_type=svn, url=svn_url) |
574 | >>> verifyObject(ICodeImport, removeSecurityProxy(svn_import)) |
575 | True |
576 | |
577 | @@ -141,8 +142,7 @@ |
578 | The CodeImportSet is also able to retrieve the code imports with the |
579 | specified subversion branch url. |
580 | |
581 | - >>> existing_import = code_import_set.getBySVNDetails( |
582 | - ... svn_branch_url=svn_url) |
583 | + >>> existing_import = code_import_set.getByURL(svn_url) |
584 | >>> svn_import == existing_import |
585 | True |
586 | |
587 | @@ -158,15 +158,14 @@ |
588 | >>> bzr_svn_url = 'svn://svn.example.com/for-bzr-svn/trunk' |
589 | >>> bzr_svn_import = code_import_set.new( |
590 | ... registrant=nopriv, product=product, branch_name='trunk-bzr-svn', |
591 | - ... rcs_type=bzr_svn, svn_branch_url=bzr_svn_url) |
592 | + ... rcs_type=bzr_svn, url=bzr_svn_url) |
593 | >>> verifyObject(ICodeImport, removeSecurityProxy(svn_import)) |
594 | True |
595 | |
596 | The CodeImportSet.getBySVNDetails is also able to find bzr-svn |
597 | imports. |
598 | |
599 | - >>> existing_bzr_svn_import = code_import_set.getBySVNDetails( |
600 | - ... svn_branch_url=bzr_svn_url) |
601 | + >>> existing_bzr_svn_import = code_import_set.getByURL(bzr_svn_url) |
602 | >>> bzr_svn_import == existing_bzr_svn_import |
603 | True |
604 | |
605 | @@ -181,7 +180,7 @@ |
606 | >>> git_url = 'git://git.example.com/hello.git' |
607 | >>> git_import = code_import_set.new( |
608 | ... registrant=nopriv, product=product, branch_name='trunk-git', |
609 | - ... rcs_type=git, git_repo_url=git_url) |
610 | + ... rcs_type=git, url=git_url) |
611 | >>> verifyObject(ICodeImport, removeSecurityProxy(git_import)) |
612 | True |
613 | |
614 | @@ -194,8 +193,7 @@ |
615 | The CodeImportSet is also able to retrieve the code imports with the |
616 | specified git repo url. |
617 | |
618 | - >>> existing_import = code_import_set.getByGitDetails( |
619 | - ... git_repo_url=git_url) |
620 | + >>> existing_import = code_import_set.getByURL(git_url) |
621 | >>> git_import == existing_import |
622 | True |
623 | |
624 | @@ -237,7 +235,7 @@ |
625 | >>> ignore_old_emails = pop_notifications() |
626 | >>> modify_event = code_import.updateFromData( |
627 | ... {'review_status': CodeImportReviewStatus.REVIEWED, |
628 | - ... 'svn_branch_url': 'http://svn.example.com/project/trunk'}, |
629 | + ... 'url': 'http://svn.example.com/project/trunk'}, |
630 | ... nopriv) |
631 | >>> print_emails(group_similar=True) |
632 | From: No Privileges Person <no-priv@canonical.com> |
633 | @@ -288,7 +286,7 @@ |
634 | from a 'noreply' address. |
635 | |
636 | >>> modify_event = code_import.updateFromData( |
637 | - ... {'svn_branch_url': 'http://svn.example.org/project/trunk'}, |
638 | + ... {'url': 'http://svn.example.org/project/trunk'}, |
639 | ... None) |
640 | >>> print_emails(group_similar=True) |
641 | From: noreply@launchpad.net |
642 | @@ -375,7 +373,7 @@ |
643 | object view for an import and also by branch, which will be used to |
644 | present the import's details on the page of the branch. |
645 | |
646 | - >>> code_import_set.get(svn_import.id).svn_branch_url |
647 | + >>> code_import_set.get(svn_import.id).url |
648 | u'svn://svn.example.com/trunk' |
649 | >>> code_import_set.getByBranch(cvs_import.branch).cvs_root |
650 | u':pserver:anonymous@cvs.example.com:/cvsroot' |
651 | @@ -432,25 +430,25 @@ |
652 | on those objects. |
653 | |
654 | >>> login('david.allouche@canonical.com') |
655 | - >>> svn_import.svn_branch_url |
656 | + >>> svn_import.url |
657 | u'svn://svn.example.com/trunk' |
658 | - >>> svn_import.svn_branch_url = 'svn://svn.example.com/branch/1.0' |
659 | + >>> svn_import.url = 'svn://svn.example.com/branch/1.0' |
660 | Traceback (most recent call last): |
661 | ... |
662 | - ForbiddenAttribute: ('svn_branch_url', <CodeImport ...>) |
663 | + ForbiddenAttribute: ('url', <CodeImport ...>) |
664 | |
665 | Modifications can be done using the CodeImport.updateFromData |
666 | method. If any change were made, this method creates and returns a |
667 | CodeImportEvent describing them. The CodeImportEvent records the user |
668 | that made the change, so we need to pass the user as an argument. |
669 | |
670 | - >>> svn_import.svn_branch_url |
671 | + >>> svn_import.url |
672 | u'svn://svn.example.com/trunk' |
673 | - >>> data = {'svn_branch_url': 'svn://svn.example.com/branch/1.0'} |
674 | + >>> data = {'url': 'svn://svn.example.com/branch/1.0'} |
675 | >>> modify_event = svn_import.updateFromData(data, nopriv) |
676 | >>> modify_event.event_type.name |
677 | 'MODIFY' |
678 | - >>> svn_import.svn_branch_url |
679 | + >>> svn_import.url |
680 | u'svn://svn.example.com/branch/1.0' |
681 | >>> svn_events = event_set.getEventsForCodeImport(svn_import) |
682 | >>> [event.event_type.name for event in svn_events] |
683 | @@ -481,7 +479,7 @@ |
684 | |
685 | And for Git. |
686 | |
687 | - >>> data = {'git_repo_url': 'git://git.example.com/goodbye.git'} |
688 | + >>> data = {'url': 'git://git.example.com/goodbye.git'} |
689 | >>> modify_event = git_import.updateFromData(data, nopriv) |
690 | >>> print make_email_body_for_code_import_update( |
691 | ... git_import, modify_event, None) |
692 | @@ -492,7 +490,7 @@ |
693 | |
694 | Imports via bzr-svn are also similar. |
695 | |
696 | - >>> data = {'svn_branch_url': 'http://svn.example.com/for-bzr-svn/trunk'} |
697 | + >>> data = {'url': 'http://svn.example.com/for-bzr-svn/trunk'} |
698 | >>> modify_event = bzr_svn_import.updateFromData(data, nopriv) |
699 | >>> print make_email_body_for_code_import_update( |
700 | ... bzr_svn_import, modify_event, None) |
701 | |
702 | === modified file 'lib/lp/code/enums.py' |
703 | --- lib/lp/code/enums.py 2009-12-08 02:32:03 +0000 |
704 | +++ lib/lp/code/enums.py 2010-01-12 21:08:17 +0000 |
705 | @@ -405,6 +405,12 @@ |
706 | Imports from Git using bzr-git. |
707 | """) |
708 | |
709 | + HG = DBItem(5, """ |
710 | + Mercurial |
711 | + |
712 | + Imports from Mercurial using bzr-hg. |
713 | + """) |
714 | + |
715 | |
716 | class CodeImportReviewStatus(DBEnumeratedType): |
717 | """CodeImport review status. |
718 | @@ -666,6 +672,19 @@ |
719 | Previous Git repo URL, when recording on import source change. |
720 | """) |
721 | |
722 | + URL = DBItem(240, """ |
723 | + Foreign VCS branch URL |
724 | + |
725 | + Location of the foreign VCS branch to import. |
726 | + """) |
727 | + |
728 | + OLD_URL = DBItem(241, """ |
729 | + Previous foreign VCS branch URL |
730 | + |
731 | + Previous foreign VCS branch location, when recording an import source |
732 | + change. |
733 | + """) |
734 | + |
735 | # Data related to machine events |
736 | |
737 | OFFLINE_REASON = DBItem(410, """Offline Reason |
738 | |
739 | === modified file 'lib/lp/code/interfaces/codeimport.py' |
740 | --- lib/lp/code/interfaces/codeimport.py 2009-10-19 17:28:59 +0000 |
741 | +++ lib/lp/code/interfaces/codeimport.py 2010-01-12 21:08:17 +0000 |
742 | @@ -106,22 +106,9 @@ |
743 | "The version control system to import from. " |
744 | "Can be CVS or Subversion.")) |
745 | |
746 | - svn_branch_url = URIField(title=_("Branch URL"), required=False, |
747 | - description=_( |
748 | - "The URL of a Subversion branch, starting with svn:// or" |
749 | - " http(s)://. Only trunk branches are imported."), |
750 | - allowed_schemes=["http", "https", "svn"], |
751 | - allow_userinfo=False, # Only anonymous access is supported. |
752 | - allow_port=True, |
753 | - allow_query=False, # Query makes no sense in Subversion. |
754 | - allow_fragment=False, # Fragment makes no sense in Subversion. |
755 | - trailing_slash=False) # See http://launchpad.net/bugs/56357. |
756 | - |
757 | - git_repo_url = URIField(title=_("Repo URL"), required=False, |
758 | - description=_( |
759 | - "The URL of the git repository. The MASTER branch will be " |
760 | - "imported."), |
761 | - allowed_schemes=["git"], |
762 | + url = URIField(title=_("URL"), required=False, |
763 | + description=_("The URL of the VCS branch."), |
764 | + allowed_schemes=["http", "https", "svn", "git"], |
765 | allow_userinfo=False, # Only anonymous access is supported. |
766 | allow_port=True, |
767 | allow_query=False, # Query makes no sense in Subversion. |
768 | @@ -200,9 +187,8 @@ |
769 | class ICodeImportSet(Interface): |
770 | """Interface representing the set of code imports.""" |
771 | |
772 | - def new(registrant, product, branch_name, rcs_type, svn_branch_url=None, |
773 | - cvs_root=None, cvs_module=None, git_repo_url=None, |
774 | - review_status=None): |
775 | + def new(registrant, product, branch_name, rcs_type, url=None, |
776 | + cvs_root=None, cvs_module=None, review_status=None): |
777 | """Create a new CodeImport.""" |
778 | |
779 | def getAll(): |
780 | @@ -230,11 +216,8 @@ |
781 | def getByCVSDetails(cvs_root, cvs_module): |
782 | """Get the CodeImport with the specified CVS details.""" |
783 | |
784 | - def getByGitDetails(git_repo_url): |
785 | - """Get the CodeImport with the specified Git details.""" |
786 | - |
787 | - def getBySVNDetails(svn_branch_url): |
788 | - """Get the CodeImport with the specified SVN details.""" |
789 | + def getByURL(url): |
790 | + """Get the CodeImport with the url.""" |
791 | |
792 | def delete(id): |
793 | """Delete a CodeImport given its id.""" |
794 | |
795 | === modified file 'lib/lp/code/mail/codeimport.py' |
796 | --- lib/lp/code/mail/codeimport.py 2009-11-26 03:35:35 +0000 |
797 | +++ lib/lp/code/mail/codeimport.py 2010-01-12 21:08:17 +0000 |
798 | @@ -96,17 +96,12 @@ |
799 | details_change_prefix + '\n' + new_details + |
800 | "\ninstead of:\n" + old_details) |
801 | elif code_import.rcs_type in (RevisionControlSystems.SVN, |
802 | - RevisionControlSystems.BZR_SVN): |
803 | - if CodeImportEventDataType.OLD_SVN_BRANCH_URL in event_data: |
804 | - old_url = event_data[CodeImportEventDataType.OLD_SVN_BRANCH_URL] |
805 | - body.append( |
806 | - details_change_prefix + '\n ' +code_import.svn_branch_url + |
807 | - "\ninstead of:\n " + old_url) |
808 | - elif code_import.rcs_type == RevisionControlSystems.GIT: |
809 | - if CodeImportEventDataType.OLD_GIT_REPO_URL in event_data: |
810 | - old_url = event_data[CodeImportEventDataType.OLD_GIT_REPO_URL] |
811 | - body.append( |
812 | - details_change_prefix + '\n ' +code_import.git_repo_url + |
813 | + RevisionControlSystems.BZR_SVN, |
814 | + RevisionControlSystems.GIT): |
815 | + if CodeImportEventDataType.OLD_URL in event_data: |
816 | + old_url = event_data[CodeImportEventDataType.OLD_URL] |
817 | + body.append( |
818 | + details_change_prefix + '\n ' +code_import.url + |
819 | "\ninstead of:\n " + old_url) |
820 | else: |
821 | raise AssertionError( |
822 | |
823 | === modified file 'lib/lp/code/model/codeimport.py' |
824 | --- lib/lp/code/model/codeimport.py 2010-01-07 05:03:46 +0000 |
825 | +++ lib/lp/code/model/codeimport.py 2010-01-12 21:08:17 +0000 |
826 | @@ -87,9 +87,7 @@ |
827 | |
828 | cvs_module = StringCol(default=None) |
829 | |
830 | - svn_branch_url = StringCol(default=None) |
831 | - |
832 | - git_repo_url = StringCol(default=None) |
833 | + url = StringCol(default=None) |
834 | |
835 | date_last_successful = UtcDateTimeCol(default=None) |
836 | update_interval = IntervalCol(default=None) |
837 | @@ -121,12 +119,11 @@ |
838 | "Only makes sense for series with import details set.") |
839 | if self.rcs_type == RevisionControlSystems.CVS: |
840 | return '%s %s' % (self.cvs_root, self.cvs_module) |
841 | - elif self.rcs_type == RevisionControlSystems.SVN: |
842 | - return self.svn_branch_url |
843 | - elif self.rcs_type == RevisionControlSystems.GIT: |
844 | - return self.git_repo_url |
845 | - elif self.rcs_type == RevisionControlSystems.BZR_SVN: |
846 | - return self.svn_branch_url |
847 | + elif self.rcs_type in ( |
848 | + RevisionControlSystems.SVN, |
849 | + RevisionControlSystems.GIT, |
850 | + RevisionControlSystems.BZR_SVN): |
851 | + return self.url |
852 | else: |
853 | raise AssertionError( |
854 | 'Unknown rcs type: %s'% self.rcs_type.title) |
855 | @@ -214,22 +211,16 @@ |
856 | implements(ICodeImportSet) |
857 | |
858 | def new(self, registrant, product, branch_name, rcs_type, |
859 | - svn_branch_url=None, cvs_root=None, cvs_module=None, |
860 | - review_status=None, git_repo_url=None): |
861 | + url=None, cvs_root=None, cvs_module=None, review_status=None): |
862 | """See `ICodeImportSet`.""" |
863 | if rcs_type == RevisionControlSystems.CVS: |
864 | assert cvs_root is not None and cvs_module is not None |
865 | - assert svn_branch_url is None |
866 | - assert git_repo_url is None |
867 | + assert url is None |
868 | elif rcs_type in (RevisionControlSystems.SVN, |
869 | - RevisionControlSystems.BZR_SVN): |
870 | - assert cvs_root is None and cvs_module is None |
871 | - assert svn_branch_url is not None |
872 | - assert git_repo_url is None |
873 | - elif rcs_type == RevisionControlSystems.GIT: |
874 | - assert cvs_root is None and cvs_module is None |
875 | - assert svn_branch_url is None |
876 | - assert git_repo_url is not None |
877 | + RevisionControlSystems.BZR_SVN, |
878 | + RevisionControlSystems.GIT): |
879 | + assert cvs_root is None and cvs_module is None |
880 | + assert url is not None |
881 | else: |
882 | raise AssertionError( |
883 | "Don't know how to sanity check source details for unknown " |
884 | @@ -248,9 +239,9 @@ |
885 | |
886 | code_import = CodeImport( |
887 | registrant=registrant, owner=registrant, branch=import_branch, |
888 | - rcs_type=rcs_type, svn_branch_url=svn_branch_url, |
889 | + rcs_type=rcs_type, url=url, |
890 | cvs_root=cvs_root, cvs_module=cvs_module, |
891 | - review_status=review_status, git_repo_url=git_repo_url) |
892 | + review_status=review_status) |
893 | |
894 | getUtility(ICodeImportEventSet).newCreate(code_import, registrant) |
895 | notify(ObjectCreatedEvent(code_import)) |
896 | @@ -329,13 +320,9 @@ |
897 | return CodeImport.selectOneBy( |
898 | cvs_root=cvs_root, cvs_module=cvs_module) |
899 | |
900 | - def getByGitDetails(self, git_repo_url): |
901 | - """See `ICodeImportSet`.""" |
902 | - return CodeImport.selectOneBy(git_repo_url=git_repo_url) |
903 | - |
904 | - def getBySVNDetails(self, svn_branch_url): |
905 | - """See `ICodeImportSet`.""" |
906 | - return CodeImport.selectOneBy(svn_branch_url=svn_branch_url) |
907 | + def getByURL(self, url): |
908 | + """See `ICodeImportSet`.""" |
909 | + return CodeImport.selectOneBy(url=url) |
910 | |
911 | def getByBranch(self, branch): |
912 | """See `ICodeImportSet`.""" |
913 | |
914 | === modified file 'lib/lp/code/model/codeimportevent.py' |
915 | --- lib/lp/code/model/codeimportevent.py 2009-11-26 03:35:35 +0000 |
916 | +++ lib/lp/code/model/codeimportevent.py 2010-01-12 21:08:17 +0000 |
917 | @@ -257,13 +257,12 @@ |
918 | def _iterSourceDetails(self, code_import): |
919 | """Yield key-value tuples describing the source of the import.""" |
920 | if code_import.rcs_type in (RevisionControlSystems.SVN, |
921 | - RevisionControlSystems.BZR_SVN): |
922 | - yield 'SVN_BRANCH_URL', code_import.svn_branch_url |
923 | + RevisionControlSystems.BZR_SVN, |
924 | + RevisionControlSystems.GIT): |
925 | + yield 'URL', code_import.url |
926 | elif code_import.rcs_type == RevisionControlSystems.CVS: |
927 | yield 'CVS_ROOT', code_import.cvs_root |
928 | yield 'CVS_MODULE', code_import.cvs_module |
929 | - elif code_import.rcs_type == RevisionControlSystems.GIT: |
930 | - yield 'GIT_REPO_URL', code_import.git_repo_url |
931 | else: |
932 | raise AssertionError( |
933 | "Unknown RCS type: %s" % (code_import.rcs_type,)) |
934 | |
935 | === modified file 'lib/lp/code/model/tests/test_codeimport.py' |
936 | --- lib/lp/code/model/tests/test_codeimport.py 2010-01-05 21:28:22 +0000 |
937 | +++ lib/lp/code/model/tests/test_codeimport.py 2010-01-12 21:08:17 +0000 |
938 | @@ -51,7 +51,7 @@ |
939 | product=self.factory.makeProduct(), |
940 | branch_name='imported', |
941 | rcs_type=RevisionControlSystems.SVN, |
942 | - svn_branch_url=self.factory.getUniqueURL()) |
943 | + url=self.factory.getUniqueURL()) |
944 | self.assertEqual( |
945 | CodeImportReviewStatus.NEW, |
946 | code_import.review_status) |
947 | @@ -65,7 +65,7 @@ |
948 | product=self.factory.makeProduct(), |
949 | branch_name='imported', |
950 | rcs_type=RevisionControlSystems.SVN, |
951 | - svn_branch_url=self.factory.getUniqueURL(), |
952 | + url=self.factory.getUniqueURL(), |
953 | review_status=CodeImportReviewStatus.REVIEWED) |
954 | self.assertEqual( |
955 | CodeImportReviewStatus.REVIEWED, |
956 | @@ -111,7 +111,7 @@ |
957 | product=self.factory.makeProduct(), |
958 | branch_name='imported', |
959 | rcs_type=RevisionControlSystems.GIT, |
960 | - git_repo_url=self.factory.getUniqueURL(), |
961 | + url=self.factory.getUniqueURL(), |
962 | review_status=None) |
963 | self.assertEqual( |
964 | CodeImportReviewStatus.REVIEWED, |
965 | |
966 | === modified file 'lib/lp/code/stories/codeimport/xx-admin-codeimport.txt' |
967 | --- lib/lp/code/stories/codeimport/xx-admin-codeimport.txt 2009-12-08 04:31:34 +0000 |
968 | +++ lib/lp/code/stories/codeimport/xx-admin-codeimport.txt 2010-01-12 21:08:17 +0000 |
969 | @@ -84,7 +84,7 @@ |
970 | ... print '%s: %s' % (tag['name'], tag['value']) |
971 | |
972 | >>> print_form_fields(import_browser) |
973 | - field.svn_branch_url: svn://svn.example.com/fooix/trunk |
974 | + field.url: svn://svn.example.com/fooix/trunk |
975 | |
976 | >>> import_browser.open(cvs_import_location) |
977 | >>> import_browser.getLink('Edit import source or review import').click() |
978 | @@ -95,7 +95,7 @@ |
979 | >>> import_browser.open(git_import_location) |
980 | >>> import_browser.getLink('Edit import source or review import').click() |
981 | >>> print_form_fields(import_browser) |
982 | - field.git_repo_url: git://git.example.org/fooix |
983 | + field.url: git://git.example.org/fooix |
984 | |
985 | Editing the import location |
986 | +++++++++++++++++++++++++++ |
987 | @@ -106,7 +106,7 @@ |
988 | This is true for Subversion imports, |
989 | |
990 | >>> import_browser.open(svn_import_location + '/+edit-import') |
991 | - >>> import_browser.getControl('Branch URL').value = \ |
992 | + >>> import_browser.getControl('URL').value = \ |
993 | ... 'svn://svn-new.example.com/fooix/trunk' |
994 | >>> import_browser.getControl('Update').click() |
995 | >>> for message in get_feedback_messages(import_browser.contents): |
996 | @@ -116,7 +116,7 @@ |
997 | bzr-svn imports, |
998 | |
999 | >>> import_browser.open(bzr_svn_import_location + '/+edit-import') |
1000 | - >>> import_browser.getControl('Branch URL').value = \ |
1001 | + >>> import_browser.getControl('URL').value = \ |
1002 | ... 'svn://svn-new.example.com/bzr-svn/trunk' |
1003 | >>> import_browser.getControl('Update').click() |
1004 | >>> for message in get_feedback_messages(import_browser.contents): |
1005 | @@ -138,7 +138,7 @@ |
1006 | and Git imports. |
1007 | |
1008 | >>> import_browser.open(git_import_location + '/+edit-import') |
1009 | - >>> import_browser.getControl('Repo URL').value = \ |
1010 | + >>> import_browser.getControl('URL').value = \ |
1011 | ... 'git://git-new.example.org/fooix' |
1012 | >>> import_browser.getControl('Update').click() |
1013 | >>> for message in get_feedback_messages(import_browser.contents): |
1014 | |
1015 | === modified file 'lib/lp/code/stories/codeimport/xx-create-codeimport.txt' |
1016 | --- lib/lp/code/stories/codeimport/xx-create-codeimport.txt 2009-12-08 02:32:03 +0000 |
1017 | +++ lib/lp/code/stories/codeimport/xx-create-codeimport.txt 2010-01-12 21:08:17 +0000 |
1018 | @@ -167,7 +167,7 @@ |
1019 | >>> for message in get_feedback_messages(browser.contents): |
1020 | ... print extract_text(message) |
1021 | There is 1 error. |
1022 | - This Subversion branch URL is already specified for |
1023 | + This foreign branch URL is already specified for |
1024 | the imported branch ~no-priv/firefox/imported. |
1025 | |
1026 | |
1027 | |
1028 | === modified file 'lib/lp/code/templates/branch-import-details.pt' |
1029 | --- lib/lp/code/templates/branch-import-details.pt 2009-12-08 22:40:31 +0000 |
1030 | +++ lib/lp/code/templates/branch-import-details.pt 2010-01-12 21:08:17 +0000 |
1031 | @@ -41,7 +41,7 @@ |
1032 | |
1033 | <tal:git-import condition="code_import/rcs_type/enumvalue:GIT"> |
1034 | <p>This branch is an import of the MASTER branch from the Git repo at |
1035 | - <span tal:replace="code_import/git_repo_url" />. |
1036 | + <span tal:replace="code_import/url" />. |
1037 | </p> |
1038 | </tal:git-import> |
1039 | |
1040 | @@ -51,11 +51,11 @@ |
1041 | <span tal:attributes="title code_import/rcs_type/title">Subversion</span> |
1042 | branch from |
1043 | <tal:is-web-url condition="view/svn_url_is_web"> |
1044 | - <a tal:attributes="href code_import/svn_branch_url" |
1045 | - tal:content="code_import/svn_branch_url" />. |
1046 | + <a tal:attributes="href code_import/url" |
1047 | + tal:content="code_import/url" />. |
1048 | </tal:is-web-url> |
1049 | <tal:not-web-url condition="not: view/svn_url_is_web"> |
1050 | - <span tal:replace="code_import/svn_branch_url" />. |
1051 | + <span tal:replace="code_import/url" />. |
1052 | </tal:not-web-url> |
1053 | </p> |
1054 | </tal:svn-import> |
1055 | |
1056 | === modified file 'lib/lp/codehosting/codeimport/tests/test_worker.py' |
1057 | --- lib/lp/codehosting/codeimport/tests/test_worker.py 2009-12-22 23:35:26 +0000 |
1058 | +++ lib/lp/codehosting/codeimport/tests/test_worker.py 2010-01-12 21:08:17 +0000 |
1059 | @@ -403,7 +403,7 @@ |
1060 | working_tree = store._getForeignTree('path') |
1061 | self.assertIsSameRealPath(working_tree.local_path, 'path') |
1062 | self.assertEqual( |
1063 | - working_tree.remote_url, source_details.svn_branch_url) |
1064 | + working_tree.remote_url, source_details.url) |
1065 | |
1066 | def test_getForeignTreeCVS(self): |
1067 | # _getForeignTree() returns a CVS working tree for CVS code imports. |
1068 | @@ -770,7 +770,7 @@ |
1069 | def makeForeignCommit(self, source_details): |
1070 | """Change the foreign tree.""" |
1071 | client = pysvn.Client() |
1072 | - client.checkout(source_details.svn_branch_url, 'working_tree') |
1073 | + client.checkout(source_details.url, 'working_tree') |
1074 | file = open('working_tree/newfile', 'w') |
1075 | file.write('No real content\n') |
1076 | file.close() |
1077 | @@ -790,7 +790,7 @@ |
1078 | svn_branch_url = svn_branch_url.replace('://localhost/', ':///') |
1079 | self.foreign_commit_count = 2 |
1080 | return self.factory.makeCodeImportSourceDetails( |
1081 | - rcstype=self.rcstype, svn_branch_url=svn_branch_url) |
1082 | + rcstype=self.rcstype, url=svn_branch_url) |
1083 | |
1084 | |
1085 | class TestSubversionImport(WorkerTest, SubversionImportHelpers, |
1086 | @@ -822,14 +822,11 @@ |
1087 | # import should be rejected. |
1088 | args = {'rcstype': self.rcstype} |
1089 | reference_url = self.createBranchReference() |
1090 | - if self.rcstype == 'git': |
1091 | - args['git_repo_url'] = reference_url |
1092 | - elif self.rcstype == 'bzr-svn': |
1093 | - args['svn_branch_url'] = reference_url |
1094 | + if self.rcstype in ('git', 'bzr-svn'): |
1095 | + args['url'] = reference_url |
1096 | else: |
1097 | raise AssertionError("unexpected rcs_type %r" % self.rcs_type) |
1098 | source_details = self.factory.makeCodeImportSourceDetails(**args) |
1099 | - |
1100 | worker = self.makeImportWorker(source_details) |
1101 | self.assertRaises(NotBranchError, worker.run) |
1102 | |
1103 | @@ -866,7 +863,7 @@ |
1104 | """Change the foreign tree, generating exactly one commit.""" |
1105 | from bzrlib.plugins.git.tests import run_git |
1106 | wd = os.getcwd() |
1107 | - os.chdir(source_details.git_repo_url) |
1108 | + os.chdir(source_details.url) |
1109 | try: |
1110 | run_git('config', 'user.name', 'Joe Random Hacker') |
1111 | run_git('commit', '-m', 'dsadas') |
1112 | @@ -886,7 +883,7 @@ |
1113 | self.foreign_commit_count = 1 |
1114 | |
1115 | return self.factory.makeCodeImportSourceDetails( |
1116 | - rcstype='git', git_repo_url=repository_path) |
1117 | + rcstype='git', url=repository_path) |
1118 | |
1119 | |
1120 | class TestBzrSvnImport(WorkerTest, SubversionImportHelpers, |
1121 | |
1122 | === modified file 'lib/lp/codehosting/codeimport/tests/test_workermonitor.py' |
1123 | --- lib/lp/codehosting/codeimport/tests/test_workermonitor.py 2009-12-04 03:31:06 +0000 |
1124 | +++ lib/lp/codehosting/codeimport/tests/test_workermonitor.py 2010-01-12 21:08:17 +0000 |
1125 | @@ -203,7 +203,7 @@ |
1126 | def check_source_details(details): |
1127 | job = self.worker_monitor.getJob() |
1128 | self.assertEqual( |
1129 | - details.svn_branch_url, job.code_import.svn_branch_url) |
1130 | + details.url, job.code_import.url) |
1131 | self.assertEqual( |
1132 | details.cvs_root, job.code_import.cvs_root) |
1133 | self.assertEqual( |
1134 | @@ -470,12 +470,11 @@ |
1135 | self.subversion_server = SubversionServer(self.repo_path) |
1136 | self.subversion_server.setUp() |
1137 | self.addCleanup(self.subversion_server.tearDown) |
1138 | - svn_branch_url = self.subversion_server.makeBranch( |
1139 | + url = self.subversion_server.makeBranch( |
1140 | 'trunk', [('README', 'contents')]) |
1141 | self.foreign_commit_count = 2 |
1142 | |
1143 | - return self.factory.makeCodeImport( |
1144 | - svn_branch_url=svn_branch_url) |
1145 | + return self.factory.makeCodeImport(svn_branch_url=url) |
1146 | |
1147 | def makeBzrSvnCodeImport(self): |
1148 | """Make a `CodeImport` that points to a real Subversion repository.""" |
1149 | @@ -483,13 +482,12 @@ |
1150 | self.repo_path, use_svn_serve=True) |
1151 | self.subversion_server.setUp() |
1152 | self.addCleanup(self.subversion_server.tearDown) |
1153 | - svn_branch_url = self.subversion_server.makeBranch( |
1154 | + url = self.subversion_server.makeBranch( |
1155 | 'trunk', [('README', 'contents')]) |
1156 | self.foreign_commit_count = 2 |
1157 | |
1158 | return self.factory.makeCodeImport( |
1159 | - svn_branch_url=svn_branch_url, |
1160 | - rcs_type=RevisionControlSystems.BZR_SVN) |
1161 | + svn_branch_url=url, rcs_type=RevisionControlSystems.BZR_SVN) |
1162 | |
1163 | def makeGitCodeImport(self): |
1164 | """Make a `CodeImport` that points to a real Git repository.""" |
1165 | |
1166 | === modified file 'lib/lp/codehosting/codeimport/worker.py' |
1167 | --- lib/lp/codehosting/codeimport/worker.py 2009-12-22 23:50:27 +0000 |
1168 | +++ lib/lp/codehosting/codeimport/worker.py 2010-01-12 21:08:17 +0000 |
1169 | @@ -107,80 +107,62 @@ |
1170 | :ivar branch_id: The id of the branch associated to this code import, used |
1171 | for locating the existing import and the foreign tree. |
1172 | :ivar rcstype: 'svn' or 'cvs' as appropriate. |
1173 | - :ivar svn_branch_url: The branch URL if rcstype in ['svn', 'bzr-svn'], |
1174 | - None otherwise. |
1175 | + :ivar url: The branch URL if rcstype in ['svn', 'bzr-svn', |
1176 | + 'git'], None otherwise. |
1177 | :ivar cvs_root: The $CVSROOT if rcstype == 'cvs', None otherwise. |
1178 | :ivar cvs_module: The CVS module if rcstype == 'cvs', None otherwise. |
1179 | - :ivar git_repo_url: The URL of the git repo, if rcstype == 'git', None, |
1180 | - otherwise. |
1181 | """ |
1182 | |
1183 | - def __init__(self, branch_id, rcstype, svn_branch_url=None, cvs_root=None, |
1184 | - cvs_module=None, git_repo_url=None): |
1185 | + def __init__(self, branch_id, rcstype, url=None, cvs_root=None, |
1186 | + cvs_module=None): |
1187 | self.branch_id = branch_id |
1188 | self.rcstype = rcstype |
1189 | - self.svn_branch_url = svn_branch_url |
1190 | + self.url = url |
1191 | self.cvs_root = cvs_root |
1192 | self.cvs_module = cvs_module |
1193 | - self.git_repo_url = git_repo_url |
1194 | |
1195 | @classmethod |
1196 | def fromArguments(cls, arguments): |
1197 | """Convert command line-style arguments to an instance.""" |
1198 | branch_id = int(arguments.pop(0)) |
1199 | rcstype = arguments.pop(0) |
1200 | - if rcstype in ['svn', 'bzr-svn']: |
1201 | - [svn_branch_url] = arguments |
1202 | - cvs_root = cvs_module = git_repo_url = None |
1203 | + if rcstype in ['svn', 'bzr-svn', 'git']: |
1204 | + [url] = arguments |
1205 | + cvs_root = cvs_module = None |
1206 | elif rcstype == 'cvs': |
1207 | - svn_branch_url = git_repo_url = None |
1208 | + url = None |
1209 | [cvs_root, cvs_module] = arguments |
1210 | - elif rcstype == 'git': |
1211 | - cvs_root = cvs_module = svn_branch_url = None |
1212 | - [git_repo_url] = arguments |
1213 | else: |
1214 | raise AssertionError("Unknown rcstype %r." % rcstype) |
1215 | - return cls( |
1216 | - branch_id, rcstype, svn_branch_url, cvs_root, cvs_module, |
1217 | - git_repo_url) |
1218 | + return cls(branch_id, rcstype, url, cvs_root, cvs_module) |
1219 | |
1220 | @classmethod |
1221 | def fromCodeImport(cls, code_import): |
1222 | """Convert a `CodeImport` to an instance.""" |
1223 | + branch_id = code_import.branch.id |
1224 | if code_import.rcs_type == RevisionControlSystems.SVN: |
1225 | - rcstype = 'svn' |
1226 | - svn_branch_url = str(code_import.svn_branch_url) |
1227 | - cvs_root = cvs_module = git_repo_url = None |
1228 | + return cls(branch_id, 'svn', str(code_import.url)) |
1229 | elif code_import.rcs_type == RevisionControlSystems.BZR_SVN: |
1230 | - rcstype = 'bzr-svn' |
1231 | - svn_branch_url = str(code_import.svn_branch_url) |
1232 | - cvs_root = cvs_module = git_repo_url = None |
1233 | + return cls(branch_id, 'bzr-svn', str(code_import.url)) |
1234 | elif code_import.rcs_type == RevisionControlSystems.CVS: |
1235 | - rcstype = 'cvs' |
1236 | - svn_branch_url = git_repo_url = None |
1237 | - cvs_root = str(code_import.cvs_root) |
1238 | - cvs_module = str(code_import.cvs_module) |
1239 | + return cls( |
1240 | + branch_id, 'cvs', |
1241 | + cvs_root=str(code_import.cvs_root), |
1242 | + cvs_module=str(code_import.cvs_module)) |
1243 | elif code_import.rcs_type == RevisionControlSystems.GIT: |
1244 | - rcstype = 'git' |
1245 | - svn_branch_url = cvs_root = cvs_module = None |
1246 | - git_repo_url = str(code_import.git_repo_url) |
1247 | + return cls(branch_id, 'git', str(code_import.url)) |
1248 | else: |
1249 | raise AssertionError("Unknown rcstype %r." % code_import.rcs_type) |
1250 | - return cls( |
1251 | - code_import.branch.id, rcstype, svn_branch_url, |
1252 | - cvs_root, cvs_module, git_repo_url) |
1253 | |
1254 | def asArguments(self): |
1255 | """Return a list of arguments suitable for passing to a child process. |
1256 | """ |
1257 | result = [str(self.branch_id), self.rcstype] |
1258 | - if self.rcstype in ['svn', 'bzr-svn']: |
1259 | - result.append(self.svn_branch_url) |
1260 | + if self.rcstype in ['svn', 'bzr-svn', 'git']: |
1261 | + result.append(self.url) |
1262 | elif self.rcstype == 'cvs': |
1263 | result.append(self.cvs_root) |
1264 | result.append(self.cvs_module) |
1265 | - elif self.rcstype == 'git': |
1266 | - result.append(self.git_repo_url) |
1267 | else: |
1268 | raise AssertionError("Unknown rcstype %r." % self.rcstype) |
1269 | return result |
1270 | @@ -294,7 +276,7 @@ |
1271 | source_details = self.import_data_store.source_details |
1272 | if source_details.rcstype == 'svn': |
1273 | return SubversionWorkingTree( |
1274 | - source_details.svn_branch_url, str(target_path)) |
1275 | + source_details.url, str(target_path)) |
1276 | elif source_details.rcstype == 'cvs': |
1277 | return CVSWorkingTree( |
1278 | source_details.cvs_root, source_details.cvs_module, |
1279 | @@ -492,12 +474,8 @@ |
1280 | class PullingImportWorker(ImportWorker): |
1281 | """An import worker for imports that can be done by a bzr plugin. |
1282 | |
1283 | - Subclasses need to implement `pull_url` and `format_classes`. |
1284 | + Subclasses need to implement `format_classes`. |
1285 | """ |
1286 | - @property |
1287 | - def pull_url(self): |
1288 | - """Return the URL that should be pulled from.""" |
1289 | - raise NotImplementedError |
1290 | |
1291 | @property |
1292 | def format_classes(self): |
1293 | @@ -512,7 +490,7 @@ |
1294 | bzrlib.ui.ui_factory = LoggingUIFactory( |
1295 | writer=lambda m: self._logger.info('%s', m)) |
1296 | try: |
1297 | - transport = get_transport(self.pull_url) |
1298 | + transport = get_transport(self.source_details.url) |
1299 | for format_class in self.format_classes: |
1300 | try: |
1301 | format = format_class.probe_transport(transport) |
1302 | @@ -520,7 +498,7 @@ |
1303 | except NotBranchError: |
1304 | pass |
1305 | else: |
1306 | - raise NotBranchError(self.pull_url) |
1307 | + raise NotBranchError(self.source_details.url) |
1308 | foreign_branch = format.open(transport).open_branch() |
1309 | bazaar_tree.branch.pull(foreign_branch, overwrite=True) |
1310 | finally: |
1311 | @@ -535,11 +513,6 @@ |
1312 | """ |
1313 | |
1314 | @property |
1315 | - def pull_url(self): |
1316 | - """See `PullingImportWorker.pull_url`.""" |
1317 | - return self.source_details.git_repo_url |
1318 | - |
1319 | - @property |
1320 | def format_classes(self): |
1321 | """See `PullingImportWorker.opening_format`.""" |
1322 | # We only return LocalGitBzrDirFormat for tests. |
1323 | @@ -575,11 +548,6 @@ |
1324 | """An import worker for importing Subversion via bzr-svn.""" |
1325 | |
1326 | @property |
1327 | - def pull_url(self): |
1328 | - """See `PullingImportWorker.pull_url`.""" |
1329 | - return self.source_details.svn_branch_url |
1330 | - |
1331 | - @property |
1332 | def format_classes(self): |
1333 | """See `PullingImportWorker.opening_format`.""" |
1334 | from bzrlib.plugins.svn.format import SvnRemoteFormat |
1335 | |
1336 | === modified file 'lib/lp/testing/factory.py' |
1337 | --- lib/lp/testing/factory.py 2010-01-05 00:53:47 +0000 |
1338 | +++ lib/lp/testing/factory.py 2010-01-12 21:08:17 +0000 |
1339 | @@ -1242,13 +1242,13 @@ |
1340 | RevisionControlSystems.BZR_SVN) |
1341 | return code_import_set.new( |
1342 | registrant, product, branch_name, rcs_type=rcs_type, |
1343 | - svn_branch_url=svn_branch_url) |
1344 | + url=svn_branch_url) |
1345 | elif git_repo_url is not None: |
1346 | assert rcs_type in (None, RevisionControlSystems.GIT) |
1347 | return code_import_set.new( |
1348 | registrant, product, branch_name, |
1349 | rcs_type=RevisionControlSystems.GIT, |
1350 | - git_repo_url=git_repo_url) |
1351 | + url=git_repo_url) |
1352 | else: |
1353 | assert rcs_type in (None, RevisionControlSystems.CVS) |
1354 | return code_import_set.new( |
1355 | @@ -1317,31 +1317,29 @@ |
1356 | result_status, date_started, date_finished) |
1357 | |
1358 | def makeCodeImportSourceDetails(self, branch_id=None, rcstype=None, |
1359 | - svn_branch_url=None, cvs_root=None, |
1360 | - cvs_module=None, git_repo_url=None): |
1361 | + url=None, cvs_root=None, cvs_module=None): |
1362 | if branch_id is None: |
1363 | branch_id = self.getUniqueInteger() |
1364 | if rcstype is None: |
1365 | rcstype = 'svn' |
1366 | if rcstype in ['svn', 'bzr-svn']: |
1367 | - assert cvs_root is cvs_module is git_repo_url is None |
1368 | - if svn_branch_url is None: |
1369 | - svn_branch_url = self.getUniqueURL() |
1370 | + assert cvs_root is cvs_module is None |
1371 | + if url is None: |
1372 | + url = self.getUniqueURL() |
1373 | elif rcstype == 'cvs': |
1374 | - assert svn_branch_url is git_repo_url is None |
1375 | + assert url is None |
1376 | if cvs_root is None: |
1377 | cvs_root = self.getUniqueString() |
1378 | if cvs_module is None: |
1379 | cvs_module = self.getUniqueString() |
1380 | elif rcstype == 'git': |
1381 | - assert cvs_root is cvs_module is svn_branch_url is None |
1382 | - if git_repo_url is None: |
1383 | - git_repo_url = self.getUniqueURL(scheme='git') |
1384 | + assert cvs_root is cvs_module is None |
1385 | + if url is None: |
1386 | + url = self.getUniqueURL(scheme='git') |
1387 | else: |
1388 | raise AssertionError("Unknown rcstype %r." % rcstype) |
1389 | return CodeImportSourceDetails( |
1390 | - branch_id, rcstype, svn_branch_url, cvs_root, cvs_module, |
1391 | - git_repo_url) |
1392 | + branch_id, rcstype, url, cvs_root, cvs_module) |
1393 | |
1394 | def makeCodeReviewComment(self, sender=None, subject=None, body=None, |
1395 | vote=None, vote_tag=None, parent=None, |
Still working on this, but is building on jelmer's branch to unify the git and subversion url fields for code imports.