Merge lp:~thumper/launchpad/imports-urls into lp:launchpad/db-devel

Proposed by Tim Penhey
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
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.

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Still working on this, but is building on jelmer's branch to unify the git and subversion url fields for code imports.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :
Download full text (23.8 KiB)

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/code/browser/codeimport.py'
> --- lib/lp/code/browser/codeimport.py 2009-12-08 02:32:03 +0000
> +++ lib/lp/code/browser/codeimport.py 2010-01-11 23:55:03 +0000
> @@ -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.cachedproperty import cachedproperty
> from canonical.launchpad import _
> +from canonical.launchpad.fields import URIField
> from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
> from lp.code.enums import (
> BranchSubscriptionDiffSize, BranchSubscriptionNotificationLevel,
> CodeImportReviewStatus, CodeReviewNotificationLevel,
> RevisionControlSystems)
> -from lp.code.interfaces.branch import branch_name_validator
> from lp.code.interfaces.branchnamespace import (
> get_branch_namespace, IBranchNamespacePolicy)
> from lp.code.interfaces.codeimport import (
> @@ -128,8 +127,7 @@
>
> custom_widget('cvs_root', StrippedTextWidget, displayWidth=50)
> custom_widget('cvs_module', StrippedTextWidget, displayWidth=20)
> - custom_widget('svn_branch_url', URIWidget, displayWidth=50)
> - custom_widget('git_repo_url', URIWidget, displayWidth=50)
> + custom_widget('url', URIWidget, displayWidth=50)
>
> @cachedproperty
> def _super_user(self):
> @@ -173,56 +171,73 @@
> canonical_url(code_import.branch),
> code_import.branch.unique_name))
>
> - def _validateSVN(self, svn_branch_url, existing_import=None):
> - """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_import=None, field_name='url'):
> + """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.setSecondaryFieldError(
> - 'svn_branch_url', 'Enter the URL of a Subversion branch.')
> + field_name, 'Enter the URL of a foreign VCS branch.')
> else:
> - code_import = getUtility(ICodeImportSet).getBySVNDetails(
> - svn_branch_url)
> + code_import = getUtility(ICodeImportSet).getByURL(url)
> 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
> + ...

review: Approve
Revision history for this message
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

Revision history for this message
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

review: Approve (db)
Revision history for this message
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.

review: Approve (db)
Revision history for this message
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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2010-01-10 22:23:32 +0000
+++ .bzrignore 2010-01-12 21:08:17 +0000
@@ -53,4 +53,7 @@
53bzr.dev53bzr.dev
54_trial_temp54_trial_temp
55lazr-js55lazr-js
56.bazaar
57.cache
58.subversion
56lib/canonical/buildd/launchpad-files59lib/canonical/buildd/launchpad-files
5760
=== modified file 'database/sampledata/current-dev.sql'
--- database/sampledata/current-dev.sql 2010-01-12 02:24:06 +0000
+++ database/sampledata/current-dev.sql 2010-01-12 21:08:17 +0000
@@ -1724,8 +1724,8 @@
17241724
1725ALTER TABLE codeimport DISABLE TRIGGER ALL;1725ALTER TABLE codeimport DISABLE TRIGGER ALL;
17261726
1727INSERT 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);1727INSERT 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');
1728INSERT 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);1728INSERT 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);
17291729
17301730
1731ALTER TABLE codeimport ENABLE TRIGGER ALL;1731ALTER TABLE codeimport ENABLE TRIGGER ALL;
17321732
=== modified file 'database/sampledata/current.sql'
--- database/sampledata/current.sql 2010-01-12 02:24:06 +0000
+++ database/sampledata/current.sql 2010-01-12 21:08:17 +0000
@@ -1706,8 +1706,8 @@
17061706
1707ALTER TABLE codeimport DISABLE TRIGGER ALL;1707ALTER TABLE codeimport DISABLE TRIGGER ALL;
17081708
1709INSERT 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);1709INSERT 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');
1710INSERT 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);1710INSERT 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);
17111711
17121712
1713ALTER TABLE codeimport ENABLE TRIGGER ALL;1713ALTER TABLE codeimport ENABLE TRIGGER ALL;
17141714
=== modified file 'database/schema/comments.sql'
--- database/schema/comments.sql 2010-01-11 04:46:04 +0000
+++ database/schema/comments.sql 2010-01-12 21:08:17 +0000
@@ -321,7 +321,7 @@
321COMMENT 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.';321COMMENT 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.';
322COMMENT ON COLUMN CodeImport.review_status IS 'Whether this code import request has been reviewed, and whether it was accepted.';322COMMENT ON COLUMN CodeImport.review_status IS 'Whether this code import request has been reviewed, and whether it was accepted.';
323COMMENT ON COLUMN CodeImport.rcs_type IS 'The revision control system used by the import source. The value is defined in dbschema.RevisionControlSystems.';323COMMENT ON COLUMN CodeImport.rcs_type IS 'The revision control system used by the import source. The value is defined in dbschema.RevisionControlSystems.';
324COMMENT ON COLUMN CodeImport.svn_branch_url IS 'The URL of the Subversion branch for this import.';324COMMENT ON COLUMN CodeImport.url IS 'The URL of the foreign VCS branch for this import.';
325COMMENT ON COLUMN CodeImport.cvs_root IS 'The $CVSROOT details, probably of the form :pserver:user@host:/path.';325COMMENT ON COLUMN CodeImport.cvs_root IS 'The $CVSROOT details, probably of the form :pserver:user@host:/path.';
326COMMENT ON COLUMN CodeImport.cvs_module IS 'The module in cvs_root to import, often the name of the project.';326COMMENT ON COLUMN CodeImport.cvs_module IS 'The module in cvs_root to import, often the name of the project.';
327COMMENT ON COLUMN CodeImport.date_last_successful IS 'When this code import last succeeded. NULL if this import has never succeeded.';327COMMENT ON COLUMN CodeImport.date_last_successful IS 'When this code import last succeeded. NULL if this import has never succeeded.';
328328
=== added file 'database/schema/patch-2207-26-0.sql'
--- database/schema/patch-2207-26-0.sql 1970-01-01 00:00:00 +0000
+++ database/schema/patch-2207-26-0.sql 2010-01-12 21:08:17 +0000
@@ -0,0 +1,28 @@
1SET client_min_messages=ERROR;
2
3ALTER TABLE CodeImport ADD COLUMN url text;
4UPDATE CodeImport SET url = git_repo_url WHERE rcs_type = 4;
5UPDATE CodeImport SET url = svn_branch_url WHERE rcs_type IN (2, 3);
6DROP INDEX codeimport__svn_branch_url__idx;
7DROP INDEX codeimport__git_repo_url__idx;
8ALTER TABLE CodeImport DROP CONSTRAINT valid_vcs_details;
9ALTER TABLE CodeImport ADD CONSTRAINT "valid_vcs_details" CHECK (
10CASE
11 WHEN rcs_type = 1
12 THEN cvs_root IS NOT NULL AND cvs_root <> ''::text AND cvs_module IS NOT NULL AND cvs_module <> ''::text
13 AND url IS NULL
14 WHEN rcs_type IN (2, 3)
15 THEN cvs_root IS NULL AND cvs_module IS NULL
16 AND url IS NOT NULL AND valid_absolute_url(url)
17 WHEN rcs_type IN (4, 5)
18 -- Git and mercurial imports are not checked for valid urls right now,
19 -- this is a bug - 506146
20 THEN cvs_root IS NULL AND cvs_module IS NULL AND url IS NOT NULL
21 ELSE false
22END);
23ALTER TABLE CodeImport DROP COLUMN git_repo_url;
24ALTER TABLE CodeImport DROP COLUMN svn_branch_url;
25
26CREATE UNIQUE INDEX codeimport__url__idx ON CodeImport USING btree (url) WHERE (url is NOT NULL);
27
28INSERT INTO LaunchpadDatabaseRevision VALUES (2207, 26, 0);
029
=== modified file 'lib/lp/code/browser/branch.py'
--- lib/lp/code/browser/branch.py 2010-01-07 05:03:46 +0000
+++ lib/lp/code/browser/branch.py 2010-01-12 21:08:17 +0000
@@ -511,8 +511,8 @@
511 """True if an imported branch's SVN URL is HTTP or HTTPS."""511 """True if an imported branch's SVN URL is HTTP or HTTPS."""
512 # You should only be calling this if it's an SVN code import512 # You should only be calling this if it's an SVN code import
513 assert self.context.code_import513 assert self.context.code_import
514 assert self.context.code_import.svn_branch_url514 url = self.context.code_import.url
515 url = self.context.code_import.svn_branch_url515 assert url
516 # https starts with http too!516 # https starts with http too!
517 return url.startswith("http")517 return url.startswith("http")
518518
519519
=== modified file 'lib/lp/code/browser/codeimport.py'
--- lib/lp/code/browser/codeimport.py 2009-12-08 02:32:03 +0000
+++ lib/lp/code/browser/codeimport.py 2010-01-12 21:08:17 +0000
@@ -15,7 +15,6 @@
15 'CodeImportView',15 'CodeImportView',
16 ]16 ]
1717
18from cgi import escape
1918
20from BeautifulSoup import BeautifulSoup19from BeautifulSoup import BeautifulSoup
21from zope.app.form import CustomWidgetFactory20from zope.app.form import CustomWidgetFactory
@@ -24,16 +23,16 @@
24from zope.component import getUtility23from zope.component import getUtility
25from zope.formlib import form24from zope.formlib import form
26from zope.interface import Interface25from zope.interface import Interface
27from zope.schema import Choice, TextLine26from zope.schema import Choice
2827
29from canonical.cachedproperty import cachedproperty28from canonical.cachedproperty import cachedproperty
30from canonical.launchpad import _29from canonical.launchpad import _
30from canonical.launchpad.fields import URIField
31from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities31from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
32from lp.code.enums import (32from lp.code.enums import (
33 BranchSubscriptionDiffSize, BranchSubscriptionNotificationLevel,33 BranchSubscriptionDiffSize, BranchSubscriptionNotificationLevel,
34 CodeImportReviewStatus, CodeReviewNotificationLevel,34 CodeImportReviewStatus, CodeReviewNotificationLevel,
35 RevisionControlSystems)35 RevisionControlSystems)
36from lp.code.interfaces.branch import branch_name_validator
37from lp.code.interfaces.branchnamespace import (36from lp.code.interfaces.branchnamespace import (
38 get_branch_namespace, IBranchNamespacePolicy)37 get_branch_namespace, IBranchNamespacePolicy)
39from lp.code.interfaces.codeimport import (38from lp.code.interfaces.codeimport import (
@@ -128,8 +127,7 @@
128127
129 custom_widget('cvs_root', StrippedTextWidget, displayWidth=50)128 custom_widget('cvs_root', StrippedTextWidget, displayWidth=50)
130 custom_widget('cvs_module', StrippedTextWidget, displayWidth=20)129 custom_widget('cvs_module', StrippedTextWidget, displayWidth=20)
131 custom_widget('svn_branch_url', URIWidget, displayWidth=50)130 custom_widget('url', URIWidget, displayWidth=50)
132 custom_widget('git_repo_url', URIWidget, displayWidth=50)
133131
134 @cachedproperty132 @cachedproperty
135 def _super_user(self):133 def _super_user(self):
@@ -173,56 +171,73 @@
173 canonical_url(code_import.branch),171 canonical_url(code_import.branch),
174 code_import.branch.unique_name))172 code_import.branch.unique_name))
175173
176 def _validateSVN(self, svn_branch_url, existing_import=None):174 def _validateURL(self, url, existing_import=None, field_name='url'):
177 """If the user has specified a subversion url, we need175 """If the user has specified a url, we need to make sure that there
178 to make sure that there isn't already an import with176 isn't already an import with that url."""
179 that url."""177 if url is None:
180 if svn_branch_url is None:
181 self.setSecondaryFieldError(178 self.setSecondaryFieldError(
182 'svn_branch_url', 'Enter the URL of a Subversion branch.')179 field_name, 'Enter the URL of a foreign VCS branch.')
183 else:180 else:
184 code_import = getUtility(ICodeImportSet).getBySVNDetails(181 code_import = getUtility(ICodeImportSet).getByURL(url)
185 svn_branch_url)
186 if (code_import is not None and182 if (code_import is not None and
187 code_import != existing_import):183 code_import != existing_import):
188 self.setFieldError(184 self.setFieldError(
189 'svn_branch_url',185 field_name,
190 structured("""186 structured("""
191 This Subversion branch URL is already specified for187 This foreign branch URL is already specified for
192 the imported branch <a href="%s">%s</a>.""",188 the imported branch <a href="%s">%s</a>.""",
193 canonical_url(code_import.branch),189 canonical_url(code_import.branch),
194 code_import.branch.unique_name))190 code_import.branch.unique_name))
195191
196 def _validateGit(self, git_repo_url, existing_import=None):192
197 """If the user has specified a git repo url, we need193
198 to make sure that there isn't already an import with194class NewCodeImportForm(Interface):
199 that url."""195 """The fields presented on the form for editing a code import."""
200 if git_repo_url is None:196
201 self.setSecondaryFieldError(197 use_template(
202 'git_repo_url', 'Enter the URL of a Git repo.')198 ICodeImport,
203 else:199 ['product', 'rcs_type', 'cvs_root', 'cvs_module'])
204 code_import = getUtility(ICodeImportSet).getByGitDetails(200
205 git_repo_url)201 svn_branch_url = URIField(
206 if (code_import is not None and202 title=_("Branch URL"), required=False,
207 code_import != existing_import):203 description=_(
208 self.setFieldError(204 "The URL of a Subversion branch, starting with svn:// or"
209 'git_repo_url',205 " http(s)://. Only trunk branches are imported."),
210 structured("""206 allowed_schemes=["http", "https", "svn"],
211 This Git repository URL is already specified for207 allow_userinfo=False,
212 the imported branch <a href="%s">%s</a>.""",208 allow_port=True,
213 escape(canonical_url(code_import.branch)),209 allow_query=False,
214 escape(code_import.branch.unique_name)))210 allow_fragment=False,
211 trailing_slash=False)
212
213 git_repo_url = URIField(
214 title=_("Repo URL"), required=False,
215 description=_(
216 "The URL of the git repository. The MASTER branch will be "
217 "imported."),
218 allowed_schemes=["git"],
219 allow_userinfo=False, # Only anonymous access is supported.
220 allow_port=True,
221 allow_query=False,
222 allow_fragment=False,
223 trailing_slash=False)
224
225 branch_name = copy_field(
226 IBranch['name'],
227 __name__='branch_name',
228 title=_('Branch Name'),
229 description=_(
230 "This will be used in the branch URL to identify the "
231 "imported branch. Examples: main, trunk."),
232 )
215233
216234
217class CodeImportNewView(CodeImportBaseView):235class CodeImportNewView(CodeImportBaseView):
218 """The view to request a new code import."""236 """The view to request a new code import."""
219237
238 schema = NewCodeImportForm
220 for_input = True239 for_input = True
221 label = 'Request a code import'240 label = 'Request a code import'
222 field_names = [
223 'product', 'rcs_type', 'svn_branch_url', 'cvs_root', 'cvs_module',
224 'git_repo_url',
225 ]
226241
227 custom_widget('rcs_type', LaunchpadRadioWidget)242 custom_widget('rcs_type', LaunchpadRadioWidget)
228243
@@ -236,19 +251,6 @@
236 """Cancel should take the user back to the root site."""251 """Cancel should take the user back to the root site."""
237 return '/'252 return '/'
238253
239 def setUpFields(self):
240 CodeImportBaseView.setUpFields(self)
241 # Add in the field for the branch name.
242 name_field = form.Fields(
243 TextLine(
244 __name__='branch_name',
245 title=_('Branch Name'), required=True, description=_(
246 "This will be used in the branch URL to identify the "
247 "imported branch. Examples: main, trunk."),
248 constraint=branch_name_validator),
249 render_context=self.render_context)
250 self.form_fields = self.form_fields + name_field
251
252 def setUpWidgets(self):254 def setUpWidgets(self):
253 CodeImportBaseView.setUpWidgets(self)255 CodeImportBaseView.setUpWidgets(self)
254256
@@ -268,18 +270,31 @@
268 self.rcs_type_git = str(git_button)270 self.rcs_type_git = str(git_button)
269 self.rcs_type_emptymarker = str(empty_marker)271 self.rcs_type_emptymarker = str(empty_marker)
270272
273 def _getImportLocation(self, data):
274 """Return the import location based on type."""
275 rcs_type = data['rcs_type']
276 if rcs_type == RevisionControlSystems.CVS:
277 return data.get('cvs_root'), data.get('cvs_module'), None
278 elif rcs_type == RevisionControlSystems.BZR_SVN:
279 return None, None, data.get('svn_branch_url')
280 elif rcs_type == RevisionControlSystems.GIT:
281 return None, None, data.get('git_repo_url')
282 else:
283 raise AssertionError(
284 'Unexpected revision control type %r.' % rcs_type)
285
271 def _create_import(self, data, status):286 def _create_import(self, data, status):
272 """Create the code import."""287 """Create the code import."""
288 cvs_root, cvs_module, url = self._getImportLocation(data)
273 return getUtility(ICodeImportSet).new(289 return getUtility(ICodeImportSet).new(
274 registrant=self.user,290 registrant=self.user,
275 product=data['product'],291 product=data['product'],
276 branch_name=data['branch_name'],292 branch_name=data['branch_name'],
277 rcs_type=data['rcs_type'],293 rcs_type=data['rcs_type'],
278 svn_branch_url=data['svn_branch_url'],294 url=url,
279 cvs_root=data['cvs_root'],295 cvs_root=cvs_root,
280 cvs_module=data['cvs_module'],296 cvs_module=cvs_module,
281 review_status=status,297 review_status=status)
282 git_repo_url=data['git_repo_url'])
283298
284 def _setBranchExists(self, existing_branch):299 def _setBranchExists(self, existing_branch):
285 """Set a field error indicating that the branch already exists."""300 """Set a field error indicating that the branch already exists."""
@@ -357,19 +372,13 @@
357 # Make sure fields for unselected revision control systems372 # Make sure fields for unselected revision control systems
358 # are blanked out:373 # are blanked out:
359 if rcs_type == RevisionControlSystems.CVS:374 if rcs_type == RevisionControlSystems.CVS:
360 data['svn_branch_url'] = None
361 data['git_repo_url'] = None
362 self._validateCVS(data.get('cvs_root'), data.get('cvs_module'))375 self._validateCVS(data.get('cvs_root'), data.get('cvs_module'))
363 elif rcs_type == RevisionControlSystems.BZR_SVN:376 elif rcs_type == RevisionControlSystems.BZR_SVN:
364 data['cvs_root'] = None377 self._validateURL(
365 data['cvs_module'] = None378 data.get('svn_branch_url'), field_name='svn_branch_url')
366 data['git_repo_url'] = None
367 self._validateSVN(data.get('svn_branch_url'))
368 elif rcs_type == RevisionControlSystems.GIT:379 elif rcs_type == RevisionControlSystems.GIT:
369 data['cvs_root'] = None380 self._validateURL(
370 data['cvs_module'] = None381 data.get('git_repo_url'), field_name='git_repo_url')
371 data['svn_branch_url'] = None
372 self._validateGit(data.get('git_repo_url'))
373 else:382 else:
374 raise AssertionError(383 raise AssertionError(
375 'Unexpected revision control type %r.' % rcs_type)384 'Unexpected revision control type %r.' % rcs_type)
@@ -380,7 +389,7 @@
380389
381 use_template(390 use_template(
382 ICodeImport,391 ICodeImport,
383 ['svn_branch_url', 'cvs_root', 'cvs_module', 'git_repo_url'])392 ['url', 'cvs_root', 'cvs_module'])
384 whiteboard = copy_field(IBranch['whiteboard'])393 whiteboard = copy_field(IBranch['whiteboard'])
385394
386395
@@ -457,15 +466,12 @@
457 # If the import is a Subversion import, then omit the CVS466 # If the import is a Subversion import, then omit the CVS
458 # fields, and vice versa.467 # fields, and vice versa.
459 if self.code_import.rcs_type == RevisionControlSystems.CVS:468 if self.code_import.rcs_type == RevisionControlSystems.CVS:
460 self.form_fields = self.form_fields.omit(469 self.form_fields = self.form_fields.omit('url')
461 'svn_branch_url', 'git_repo_url')
462 elif self.code_import.rcs_type in (RevisionControlSystems.SVN,470 elif self.code_import.rcs_type in (RevisionControlSystems.SVN,
463 RevisionControlSystems.BZR_SVN):471 RevisionControlSystems.BZR_SVN,
464 self.form_fields = self.form_fields.omit(472 RevisionControlSystems.GIT):
465 'cvs_root', 'cvs_module', 'git_repo_url')473 self.form_fields = self.form_fields.omit(
466 elif self.code_import.rcs_type == RevisionControlSystems.GIT:474 'cvs_root', 'cvs_module')
467 self.form_fields = self.form_fields.omit(
468 'cvs_root', 'cvs_module', 'svn_branch_url')
469 else:475 else:
470 raise AssertionError('Unknown rcs_type for code import.')476 raise AssertionError('Unknown rcs_type for code import.')
471477
@@ -496,12 +502,9 @@
496 data.get('cvs_root'), data.get('cvs_module'),502 data.get('cvs_root'), data.get('cvs_module'),
497 self.code_import)503 self.code_import)
498 elif self.code_import.rcs_type in (RevisionControlSystems.SVN,504 elif self.code_import.rcs_type in (RevisionControlSystems.SVN,
499 RevisionControlSystems.BZR_SVN):505 RevisionControlSystems.BZR_SVN,
500 self._validateSVN(506 RevisionControlSystems.GIT):
501 data.get('svn_branch_url'), self.code_import)507 self._validateURL(data.get('url'), self.code_import)
502 elif self.code_import.rcs_type == RevisionControlSystems.GIT:
503 self._validateGit(
504 data.get('git_repo_url'), self.code_import)
505 else:508 else:
506 raise AssertionError('Unknown rcs_type for code import.')509 raise AssertionError('Unknown rcs_type for code import.')
507510
508511
=== modified file 'lib/lp/code/configure.zcml'
--- lib/lp/code/configure.zcml 2010-01-06 14:14:35 +0000
+++ lib/lp/code/configure.zcml 2010-01-12 21:08:17 +0000
@@ -749,8 +749,7 @@
749 rcs_type749 rcs_type
750 cvs_root750 cvs_root
751 cvs_module751 cvs_module
752 svn_branch_url752 url
753 git_repo_url
754 date_last_successful753 date_last_successful
755 source_product_series754 source_product_series
756 update_interval755 update_interval
757756
=== modified file 'lib/lp/code/doc/codeimport-event.txt'
--- lib/lp/code/doc/codeimport-event.txt 2009-07-01 13:16:44 +0000
+++ lib/lp/code/doc/codeimport-event.txt 2010-01-12 21:08:17 +0000
@@ -95,22 +95,11 @@
9595
96 >>> nopriv = getUtility(IPersonSet).getByName('no-priv')96 >>> nopriv = getUtility(IPersonSet).getByName('no-priv')
9797
98 >>> def new_code_import(name, **kw_details):
99 ... vcs_imports = getUtility(ILaunchpadCelebrities).vcs_imports
100 ... product = getUtility(IProductSet).getByName('firefox')
101 ... namespace = get_branch_namespace(vcs_imports, product=product)
102 ... import_branch = namespace.createBranch(
103 ... BranchType.IMPORTED, name, vcs_imports, title='Import branch')
104 ... return CodeImport(
105 ... registrant=nopriv, owner=nopriv, branch=import_branch,
106 ... **kw_details)
107
108First we create a Subversion import.98First we create a Subversion import.
10999
110 >>> from lp.code.enums import RevisionControlSystems100 >>> from lp.code.enums import RevisionControlSystems
111 >>> svn_url = 'svn://svn.example.com/trunk'101 >>> svn_import = factory.makeCodeImport(
112 >>> svn_import = new_code_import('svn-trunk',102 ... svn_branch_url='svn://svn.example.com/trunk')
113 ... rcs_type=RevisionControlSystems.SVN, svn_branch_url=svn_url)
114103
115CodeImportSet.newCreate creates an event from the new CodeImport object104CodeImportSet.newCreate creates an event from the new CodeImport object
116and the person that created it. Here, the creator is the nopriv user.105and the person that created it. Here, the creator is the nopriv user.
@@ -131,11 +120,11 @@
131120
132 >>> print_items(svn_create_event)121 >>> print_items(svn_create_event)
133 CODE_IMPORT <muted>122 CODE_IMPORT <muted>
134 OWNER u'52'123 OWNER ...
135 REVIEW_STATUS u'NEW'124 REVIEW_STATUS u'NEW'
136 ASSIGNEE None125 ASSIGNEE None
137 UPDATE_INTERVAL None126 UPDATE_INTERVAL None
138 SVN_BRANCH_URL u'svn://svn.example.com/trunk'127 URL u'svn://svn.example.com/trunk'
139128
140The database IDs of the CodeImport is also recorded. It is useful to129The database IDs of the CodeImport is also recorded. It is useful to
141collate events associated with deleted CodeImport objects.130collate events associated with deleted CodeImport objects.
@@ -149,14 +138,13 @@
149import source. For a CVS import, CVS details are recorded instead of the138import source. For a CVS import, CVS details are recorded instead of the
150Subversion URL.139Subversion URL.
151140
152 >>> cvs_import = new_code_import('cvs-main',141 >>> cvs_import = factory.makeCodeImport(
153 ... rcs_type=RevisionControlSystems.CVS,
154 ... cvs_root=':pserver:anonymous@cvs.example.com:/cvsroot',142 ... cvs_root=':pserver:anonymous@cvs.example.com:/cvsroot',
155 ... cvs_module='hello')143 ... cvs_module='hello')
156 >>> cvs_create_event = event_set.newCreate(cvs_import, nopriv)144 >>> cvs_create_event = event_set.newCreate(cvs_import, nopriv)
157 >>> print_items(cvs_create_event)145 >>> print_items(cvs_create_event)
158 CODE_IMPORT <muted>146 CODE_IMPORT <muted>
159 OWNER u'52'147 OWNER ...
160 REVIEW_STATUS u'NEW'148 REVIEW_STATUS u'NEW'
161 ASSIGNEE None149 ASSIGNEE None
162 UPDATE_INTERVAL None150 UPDATE_INTERVAL None
@@ -165,17 +153,17 @@
165153
166And for a Git import, the git details are recorded.154And for a Git import, the git details are recorded.
167155
168 >>> git_import = new_code_import('git-main',156 >>> git_import = factory.makeCodeImport(
169 ... rcs_type=RevisionControlSystems.GIT,
170 ... git_repo_url='git://git.example.org/main.git')157 ... git_repo_url='git://git.example.org/main.git')
171 >>> git_create_event = event_set.newCreate(git_import, nopriv)158 >>> git_create_event = event_set.newCreate(git_import, nopriv)
172 >>> print_items(git_create_event)159 >>> print_items(git_create_event)
173 CODE_IMPORT <muted>160 CODE_IMPORT <muted>
174 OWNER u'52'161 OWNER ...
175 REVIEW_STATUS u'NEW'162 REVIEW_STATUS u'REVIEWED'
176 ASSIGNEE None163 ASSIGNEE None
177 UPDATE_INTERVAL None164 UPDATE_INTERVAL None
178 GIT_REPO_URL u'git://git.example.org/main.git'165 URL u'git://git.example.org/main.git'
166
179167
180== MODIFY ==168== MODIFY ==
181169
@@ -204,7 +192,8 @@
204Then changes can be applied.192Then changes can be applied.
205193
206 >>> from lp.code.enums import CodeImportReviewStatus194 >>> from lp.code.enums import CodeImportReviewStatus
207 >>> svn_import.review_status = CodeImportReviewStatus.REVIEWED195 >>> removeSecurityProxy(svn_import).review_status = (
196 ... CodeImportReviewStatus.REVIEWED)
208197
209After applying changes, the newModify method can create an event that198After applying changes, the newModify method can create an event that
210details the changes that have been applied.199details the changes that have been applied.
@@ -229,12 +218,12 @@
229218
230 >>> print_items(modify_event)219 >>> print_items(modify_event)
231 CODE_IMPORT <muted>220 CODE_IMPORT <muted>
232 OWNER u'52'221 OWNER ...
233 REVIEW_STATUS u'REVIEWED'222 REVIEW_STATUS u'REVIEWED'
234 OLD_REVIEW_STATUS u'NEW'223 OLD_REVIEW_STATUS u'NEW'
235 ASSIGNEE None224 ASSIGNEE None
236 UPDATE_INTERVAL None225 UPDATE_INTERVAL None
237 SVN_BRANCH_URL u'svn://svn.example.com/trunk'226 URL u'svn://svn.example.com/trunk'
238227
239If no change of interest is found, no event is created.228If no change of interest is found, no event is created.
240229
@@ -245,55 +234,6 @@
245 >>> len(list(event_set.getAll())) == old_event_set_len234 >>> len(list(event_set.getAll())) == old_event_set_len
246 True235 True
247236
248In most events, only the source details for the selected version control
249system are recorded. If the rcs_type changes, we record old and new
250values for all changed attributes to explicitly represent transitions to
251None and from None.
252
253 >>> token = event_set.beginModify(cvs_import)
254 >>> cvs_import.rcs_type = RevisionControlSystems.SVN
255 >>> cvs_import.svn_branch_url = u'svn://svn.example.com/from-cvs'
256 >>> cvs_import.cvs_root = None
257 >>> cvs_import.cvs_module = None
258 >>> modify_event = event_set.newModify(cvs_import, nopriv, token)
259 >>> print_items(modify_event)
260 CODE_IMPORT <muted>
261 OWNER u'52'
262 REVIEW_STATUS u'NEW'
263 ASSIGNEE None
264 UPDATE_INTERVAL None
265 CVS_ROOT None
266 CVS_MODULE None
267 OLD_CVS_ROOT u':pserver:anonymous@cvs.example.com:/cvsroot'
268 OLD_CVS_MODULE u'hello'
269 SVN_BRANCH_URL u'svn://svn.example.com/from-cvs'
270 OLD_SVN_BRANCH_URL None
271
272Aside from source details changes, MODIFY events can record changes to
273the owner, the review_status, the assignee, and the update_interval of a
274code import.
275
276 >>> from datetime import timedelta
277 >>> sample_owner = getUtility(IPersonSet).getByName('name12')
278 >>> sample_assignee = getUtility(IPersonSet).getByName('ddaa')
279 >>> token = event_set.beginModify(svn_import)
280 >>> svn_import.owner = sample_owner
281 >>> svn_import.review_status = CodeImportReviewStatus.SUSPENDED
282 >>> svn_import.assignee = sample_assignee
283 >>> svn_import.update_interval = timedelta(hours=1)
284 >>> modify_event = event_set.newModify(svn_import, nopriv, token)
285 >>> print_items(modify_event)
286 CODE_IMPORT <muted>
287 OWNER u'12'
288 OLD_OWNER u'52'
289 REVIEW_STATUS u'SUSPENDED'
290 OLD_REVIEW_STATUS u'REVIEWED'
291 ASSIGNEE u'23'
292 OLD_ASSIGNEE None
293 UPDATE_INTERVAL u'1:00:00'
294 OLD_UPDATE_INTERVAL None
295 SVN_BRANCH_URL u'svn://svn.example.com/trunk'
296
297237
298=== REQUEST ===238=== REQUEST ===
299239
300240
=== modified file 'lib/lp/code/doc/codeimport.txt'
--- lib/lp/code/doc/codeimport.txt 2009-12-08 19:21:29 +0000
+++ lib/lp/code/doc/codeimport.txt 2010-01-12 21:08:17 +0000
@@ -59,6 +59,7 @@
59 Subversion via CSCVS59 Subversion via CSCVS
60 Subversion via bzr-svn60 Subversion via bzr-svn
61 Git61 Git
62 Mercurial
6263
6364
64Import from CVS65Import from CVS
@@ -128,7 +129,7 @@
128 >>> svn_url = 'svn://svn.example.com/trunk'129 >>> svn_url = 'svn://svn.example.com/trunk'
129 >>> svn_import = code_import_set.new(130 >>> svn_import = code_import_set.new(
130 ... registrant=nopriv, product=product, branch_name='trunk-svn',131 ... registrant=nopriv, product=product, branch_name='trunk-svn',
131 ... rcs_type=svn, svn_branch_url=svn_url)132 ... rcs_type=svn, url=svn_url)
132 >>> verifyObject(ICodeImport, removeSecurityProxy(svn_import))133 >>> verifyObject(ICodeImport, removeSecurityProxy(svn_import))
133 True134 True
134135
@@ -141,8 +142,7 @@
141The CodeImportSet is also able to retrieve the code imports with the142The CodeImportSet is also able to retrieve the code imports with the
142specified subversion branch url.143specified subversion branch url.
143144
144 >>> existing_import = code_import_set.getBySVNDetails(145 >>> existing_import = code_import_set.getByURL(svn_url)
145 ... svn_branch_url=svn_url)
146 >>> svn_import == existing_import146 >>> svn_import == existing_import
147 True147 True
148148
@@ -158,15 +158,14 @@
158 >>> bzr_svn_url = 'svn://svn.example.com/for-bzr-svn/trunk'158 >>> bzr_svn_url = 'svn://svn.example.com/for-bzr-svn/trunk'
159 >>> bzr_svn_import = code_import_set.new(159 >>> bzr_svn_import = code_import_set.new(
160 ... registrant=nopriv, product=product, branch_name='trunk-bzr-svn',160 ... registrant=nopriv, product=product, branch_name='trunk-bzr-svn',
161 ... rcs_type=bzr_svn, svn_branch_url=bzr_svn_url)161 ... rcs_type=bzr_svn, url=bzr_svn_url)
162 >>> verifyObject(ICodeImport, removeSecurityProxy(svn_import))162 >>> verifyObject(ICodeImport, removeSecurityProxy(svn_import))
163 True163 True
164164
165The CodeImportSet.getBySVNDetails is also able to find bzr-svn165The CodeImportSet.getBySVNDetails is also able to find bzr-svn
166imports.166imports.
167167
168 >>> existing_bzr_svn_import = code_import_set.getBySVNDetails(168 >>> existing_bzr_svn_import = code_import_set.getByURL(bzr_svn_url)
169 ... svn_branch_url=bzr_svn_url)
170 >>> bzr_svn_import == existing_bzr_svn_import169 >>> bzr_svn_import == existing_bzr_svn_import
171 True170 True
172171
@@ -181,7 +180,7 @@
181 >>> git_url = 'git://git.example.com/hello.git'180 >>> git_url = 'git://git.example.com/hello.git'
182 >>> git_import = code_import_set.new(181 >>> git_import = code_import_set.new(
183 ... registrant=nopriv, product=product, branch_name='trunk-git',182 ... registrant=nopriv, product=product, branch_name='trunk-git',
184 ... rcs_type=git, git_repo_url=git_url)183 ... rcs_type=git, url=git_url)
185 >>> verifyObject(ICodeImport, removeSecurityProxy(git_import))184 >>> verifyObject(ICodeImport, removeSecurityProxy(git_import))
186 True185 True
187186
@@ -194,8 +193,7 @@
194The CodeImportSet is also able to retrieve the code imports with the193The CodeImportSet is also able to retrieve the code imports with the
195specified git repo url.194specified git repo url.
196195
197 >>> existing_import = code_import_set.getByGitDetails(196 >>> existing_import = code_import_set.getByURL(git_url)
198 ... git_repo_url=git_url)
199 >>> git_import == existing_import197 >>> git_import == existing_import
200 True198 True
201199
@@ -237,7 +235,7 @@
237 >>> ignore_old_emails = pop_notifications()235 >>> ignore_old_emails = pop_notifications()
238 >>> modify_event = code_import.updateFromData(236 >>> modify_event = code_import.updateFromData(
239 ... {'review_status': CodeImportReviewStatus.REVIEWED,237 ... {'review_status': CodeImportReviewStatus.REVIEWED,
240 ... 'svn_branch_url': 'http://svn.example.com/project/trunk'},238 ... 'url': 'http://svn.example.com/project/trunk'},
241 ... nopriv)239 ... nopriv)
242 >>> print_emails(group_similar=True)240 >>> print_emails(group_similar=True)
243 From: No Privileges Person <no-priv@canonical.com>241 From: No Privileges Person <no-priv@canonical.com>
@@ -288,7 +286,7 @@
288from a 'noreply' address.286from a 'noreply' address.
289287
290 >>> modify_event = code_import.updateFromData(288 >>> modify_event = code_import.updateFromData(
291 ... {'svn_branch_url': 'http://svn.example.org/project/trunk'},289 ... {'url': 'http://svn.example.org/project/trunk'},
292 ... None)290 ... None)
293 >>> print_emails(group_similar=True)291 >>> print_emails(group_similar=True)
294 From: noreply@launchpad.net292 From: noreply@launchpad.net
@@ -375,7 +373,7 @@
375object view for an import and also by branch, which will be used to373object view for an import and also by branch, which will be used to
376present the import's details on the page of the branch.374present the import's details on the page of the branch.
377375
378 >>> code_import_set.get(svn_import.id).svn_branch_url376 >>> code_import_set.get(svn_import.id).url
379 u'svn://svn.example.com/trunk'377 u'svn://svn.example.com/trunk'
380 >>> code_import_set.getByBranch(cvs_import.branch).cvs_root378 >>> code_import_set.getByBranch(cvs_import.branch).cvs_root
381 u':pserver:anonymous@cvs.example.com:/cvsroot'379 u':pserver:anonymous@cvs.example.com:/cvsroot'
@@ -432,25 +430,25 @@
432on those objects.430on those objects.
433431
434 >>> login('david.allouche@canonical.com')432 >>> login('david.allouche@canonical.com')
435 >>> svn_import.svn_branch_url433 >>> svn_import.url
436 u'svn://svn.example.com/trunk'434 u'svn://svn.example.com/trunk'
437 >>> svn_import.svn_branch_url = 'svn://svn.example.com/branch/1.0'435 >>> svn_import.url = 'svn://svn.example.com/branch/1.0'
438 Traceback (most recent call last):436 Traceback (most recent call last):
439 ...437 ...
440 ForbiddenAttribute: ('svn_branch_url', <CodeImport ...>)438 ForbiddenAttribute: ('url', <CodeImport ...>)
441439
442Modifications can be done using the CodeImport.updateFromData440Modifications can be done using the CodeImport.updateFromData
443method. If any change were made, this method creates and returns a441method. If any change were made, this method creates and returns a
444CodeImportEvent describing them. The CodeImportEvent records the user442CodeImportEvent describing them. The CodeImportEvent records the user
445that made the change, so we need to pass the user as an argument.443that made the change, so we need to pass the user as an argument.
446444
447 >>> svn_import.svn_branch_url445 >>> svn_import.url
448 u'svn://svn.example.com/trunk'446 u'svn://svn.example.com/trunk'
449 >>> data = {'svn_branch_url': 'svn://svn.example.com/branch/1.0'}447 >>> data = {'url': 'svn://svn.example.com/branch/1.0'}
450 >>> modify_event = svn_import.updateFromData(data, nopriv)448 >>> modify_event = svn_import.updateFromData(data, nopriv)
451 >>> modify_event.event_type.name449 >>> modify_event.event_type.name
452 'MODIFY'450 'MODIFY'
453 >>> svn_import.svn_branch_url451 >>> svn_import.url
454 u'svn://svn.example.com/branch/1.0'452 u'svn://svn.example.com/branch/1.0'
455 >>> svn_events = event_set.getEventsForCodeImport(svn_import)453 >>> svn_events = event_set.getEventsForCodeImport(svn_import)
456 >>> [event.event_type.name for event in svn_events]454 >>> [event.event_type.name for event in svn_events]
@@ -481,7 +479,7 @@
481479
482And for Git.480And for Git.
483481
484 >>> data = {'git_repo_url': 'git://git.example.com/goodbye.git'}482 >>> data = {'url': 'git://git.example.com/goodbye.git'}
485 >>> modify_event = git_import.updateFromData(data, nopriv)483 >>> modify_event = git_import.updateFromData(data, nopriv)
486 >>> print make_email_body_for_code_import_update(484 >>> print make_email_body_for_code_import_update(
487 ... git_import, modify_event, None)485 ... git_import, modify_event, None)
@@ -492,7 +490,7 @@
492490
493Imports via bzr-svn are also similar.491Imports via bzr-svn are also similar.
494492
495 >>> data = {'svn_branch_url': 'http://svn.example.com/for-bzr-svn/trunk'}493 >>> data = {'url': 'http://svn.example.com/for-bzr-svn/trunk'}
496 >>> modify_event = bzr_svn_import.updateFromData(data, nopriv)494 >>> modify_event = bzr_svn_import.updateFromData(data, nopriv)
497 >>> print make_email_body_for_code_import_update(495 >>> print make_email_body_for_code_import_update(
498 ... bzr_svn_import, modify_event, None)496 ... bzr_svn_import, modify_event, None)
499497
=== modified file 'lib/lp/code/enums.py'
--- lib/lp/code/enums.py 2009-12-08 02:32:03 +0000
+++ lib/lp/code/enums.py 2010-01-12 21:08:17 +0000
@@ -405,6 +405,12 @@
405 Imports from Git using bzr-git.405 Imports from Git using bzr-git.
406 """)406 """)
407407
408 HG = DBItem(5, """
409 Mercurial
410
411 Imports from Mercurial using bzr-hg.
412 """)
413
408414
409class CodeImportReviewStatus(DBEnumeratedType):415class CodeImportReviewStatus(DBEnumeratedType):
410 """CodeImport review status.416 """CodeImport review status.
@@ -666,6 +672,19 @@
666 Previous Git repo URL, when recording on import source change.672 Previous Git repo URL, when recording on import source change.
667 """)673 """)
668674
675 URL = DBItem(240, """
676 Foreign VCS branch URL
677
678 Location of the foreign VCS branch to import.
679 """)
680
681 OLD_URL = DBItem(241, """
682 Previous foreign VCS branch URL
683
684 Previous foreign VCS branch location, when recording an import source
685 change.
686 """)
687
669 # Data related to machine events688 # Data related to machine events
670689
671 OFFLINE_REASON = DBItem(410, """Offline Reason690 OFFLINE_REASON = DBItem(410, """Offline Reason
672691
=== modified file 'lib/lp/code/interfaces/codeimport.py'
--- lib/lp/code/interfaces/codeimport.py 2009-10-19 17:28:59 +0000
+++ lib/lp/code/interfaces/codeimport.py 2010-01-12 21:08:17 +0000
@@ -106,22 +106,9 @@
106 "The version control system to import from. "106 "The version control system to import from. "
107 "Can be CVS or Subversion."))107 "Can be CVS or Subversion."))
108108
109 svn_branch_url = URIField(title=_("Branch URL"), required=False,109 url = URIField(title=_("URL"), required=False,
110 description=_(110 description=_("The URL of the VCS branch."),
111 "The URL of a Subversion branch, starting with svn:// or"111 allowed_schemes=["http", "https", "svn", "git"],
112 " http(s)://. Only trunk branches are imported."),
113 allowed_schemes=["http", "https", "svn"],
114 allow_userinfo=False, # Only anonymous access is supported.
115 allow_port=True,
116 allow_query=False, # Query makes no sense in Subversion.
117 allow_fragment=False, # Fragment makes no sense in Subversion.
118 trailing_slash=False) # See http://launchpad.net/bugs/56357.
119
120 git_repo_url = URIField(title=_("Repo URL"), required=False,
121 description=_(
122 "The URL of the git repository. The MASTER branch will be "
123 "imported."),
124 allowed_schemes=["git"],
125 allow_userinfo=False, # Only anonymous access is supported.112 allow_userinfo=False, # Only anonymous access is supported.
126 allow_port=True,113 allow_port=True,
127 allow_query=False, # Query makes no sense in Subversion.114 allow_query=False, # Query makes no sense in Subversion.
@@ -200,9 +187,8 @@
200class ICodeImportSet(Interface):187class ICodeImportSet(Interface):
201 """Interface representing the set of code imports."""188 """Interface representing the set of code imports."""
202189
203 def new(registrant, product, branch_name, rcs_type, svn_branch_url=None,190 def new(registrant, product, branch_name, rcs_type, url=None,
204 cvs_root=None, cvs_module=None, git_repo_url=None,191 cvs_root=None, cvs_module=None, review_status=None):
205 review_status=None):
206 """Create a new CodeImport."""192 """Create a new CodeImport."""
207193
208 def getAll():194 def getAll():
@@ -230,11 +216,8 @@
230 def getByCVSDetails(cvs_root, cvs_module):216 def getByCVSDetails(cvs_root, cvs_module):
231 """Get the CodeImport with the specified CVS details."""217 """Get the CodeImport with the specified CVS details."""
232218
233 def getByGitDetails(git_repo_url):219 def getByURL(url):
234 """Get the CodeImport with the specified Git details."""220 """Get the CodeImport with the url."""
235
236 def getBySVNDetails(svn_branch_url):
237 """Get the CodeImport with the specified SVN details."""
238221
239 def delete(id):222 def delete(id):
240 """Delete a CodeImport given its id."""223 """Delete a CodeImport given its id."""
241224
=== modified file 'lib/lp/code/mail/codeimport.py'
--- lib/lp/code/mail/codeimport.py 2009-11-26 03:35:35 +0000
+++ lib/lp/code/mail/codeimport.py 2010-01-12 21:08:17 +0000
@@ -96,17 +96,12 @@
96 details_change_prefix + '\n' + new_details +96 details_change_prefix + '\n' + new_details +
97 "\ninstead of:\n" + old_details)97 "\ninstead of:\n" + old_details)
98 elif code_import.rcs_type in (RevisionControlSystems.SVN,98 elif code_import.rcs_type in (RevisionControlSystems.SVN,
99 RevisionControlSystems.BZR_SVN):99 RevisionControlSystems.BZR_SVN,
100 if CodeImportEventDataType.OLD_SVN_BRANCH_URL in event_data:100 RevisionControlSystems.GIT):
101 old_url = event_data[CodeImportEventDataType.OLD_SVN_BRANCH_URL]101 if CodeImportEventDataType.OLD_URL in event_data:
102 body.append(102 old_url = event_data[CodeImportEventDataType.OLD_URL]
103 details_change_prefix + '\n ' +code_import.svn_branch_url +103 body.append(
104 "\ninstead of:\n " + old_url)104 details_change_prefix + '\n ' +code_import.url +
105 elif code_import.rcs_type == RevisionControlSystems.GIT:
106 if CodeImportEventDataType.OLD_GIT_REPO_URL in event_data:
107 old_url = event_data[CodeImportEventDataType.OLD_GIT_REPO_URL]
108 body.append(
109 details_change_prefix + '\n ' +code_import.git_repo_url +
110 "\ninstead of:\n " + old_url)105 "\ninstead of:\n " + old_url)
111 else:106 else:
112 raise AssertionError(107 raise AssertionError(
113108
=== modified file 'lib/lp/code/model/codeimport.py'
--- lib/lp/code/model/codeimport.py 2010-01-07 05:03:46 +0000
+++ lib/lp/code/model/codeimport.py 2010-01-12 21:08:17 +0000
@@ -87,9 +87,7 @@
8787
88 cvs_module = StringCol(default=None)88 cvs_module = StringCol(default=None)
8989
90 svn_branch_url = StringCol(default=None)90 url = StringCol(default=None)
91
92 git_repo_url = StringCol(default=None)
9391
94 date_last_successful = UtcDateTimeCol(default=None)92 date_last_successful = UtcDateTimeCol(default=None)
95 update_interval = IntervalCol(default=None)93 update_interval = IntervalCol(default=None)
@@ -121,12 +119,11 @@
121 "Only makes sense for series with import details set.")119 "Only makes sense for series with import details set.")
122 if self.rcs_type == RevisionControlSystems.CVS:120 if self.rcs_type == RevisionControlSystems.CVS:
123 return '%s %s' % (self.cvs_root, self.cvs_module)121 return '%s %s' % (self.cvs_root, self.cvs_module)
124 elif self.rcs_type == RevisionControlSystems.SVN:122 elif self.rcs_type in (
125 return self.svn_branch_url123 RevisionControlSystems.SVN,
126 elif self.rcs_type == RevisionControlSystems.GIT:124 RevisionControlSystems.GIT,
127 return self.git_repo_url125 RevisionControlSystems.BZR_SVN):
128 elif self.rcs_type == RevisionControlSystems.BZR_SVN:126 return self.url
129 return self.svn_branch_url
130 else:127 else:
131 raise AssertionError(128 raise AssertionError(
132 'Unknown rcs type: %s'% self.rcs_type.title)129 'Unknown rcs type: %s'% self.rcs_type.title)
@@ -214,22 +211,16 @@
214 implements(ICodeImportSet)211 implements(ICodeImportSet)
215212
216 def new(self, registrant, product, branch_name, rcs_type,213 def new(self, registrant, product, branch_name, rcs_type,
217 svn_branch_url=None, cvs_root=None, cvs_module=None,214 url=None, cvs_root=None, cvs_module=None, review_status=None):
218 review_status=None, git_repo_url=None):
219 """See `ICodeImportSet`."""215 """See `ICodeImportSet`."""
220 if rcs_type == RevisionControlSystems.CVS:216 if rcs_type == RevisionControlSystems.CVS:
221 assert cvs_root is not None and cvs_module is not None217 assert cvs_root is not None and cvs_module is not None
222 assert svn_branch_url is None218 assert url is None
223 assert git_repo_url is None
224 elif rcs_type in (RevisionControlSystems.SVN,219 elif rcs_type in (RevisionControlSystems.SVN,
225 RevisionControlSystems.BZR_SVN):220 RevisionControlSystems.BZR_SVN,
226 assert cvs_root is None and cvs_module is None221 RevisionControlSystems.GIT):
227 assert svn_branch_url is not None222 assert cvs_root is None and cvs_module is None
228 assert git_repo_url is None223 assert url is not None
229 elif rcs_type == RevisionControlSystems.GIT:
230 assert cvs_root is None and cvs_module is None
231 assert svn_branch_url is None
232 assert git_repo_url is not None
233 else:224 else:
234 raise AssertionError(225 raise AssertionError(
235 "Don't know how to sanity check source details for unknown "226 "Don't know how to sanity check source details for unknown "
@@ -248,9 +239,9 @@
248239
249 code_import = CodeImport(240 code_import = CodeImport(
250 registrant=registrant, owner=registrant, branch=import_branch,241 registrant=registrant, owner=registrant, branch=import_branch,
251 rcs_type=rcs_type, svn_branch_url=svn_branch_url,242 rcs_type=rcs_type, url=url,
252 cvs_root=cvs_root, cvs_module=cvs_module,243 cvs_root=cvs_root, cvs_module=cvs_module,
253 review_status=review_status, git_repo_url=git_repo_url)244 review_status=review_status)
254245
255 getUtility(ICodeImportEventSet).newCreate(code_import, registrant)246 getUtility(ICodeImportEventSet).newCreate(code_import, registrant)
256 notify(ObjectCreatedEvent(code_import))247 notify(ObjectCreatedEvent(code_import))
@@ -329,13 +320,9 @@
329 return CodeImport.selectOneBy(320 return CodeImport.selectOneBy(
330 cvs_root=cvs_root, cvs_module=cvs_module)321 cvs_root=cvs_root, cvs_module=cvs_module)
331322
332 def getByGitDetails(self, git_repo_url):323 def getByURL(self, url):
333 """See `ICodeImportSet`."""324 """See `ICodeImportSet`."""
334 return CodeImport.selectOneBy(git_repo_url=git_repo_url)325 return CodeImport.selectOneBy(url=url)
335
336 def getBySVNDetails(self, svn_branch_url):
337 """See `ICodeImportSet`."""
338 return CodeImport.selectOneBy(svn_branch_url=svn_branch_url)
339326
340 def getByBranch(self, branch):327 def getByBranch(self, branch):
341 """See `ICodeImportSet`."""328 """See `ICodeImportSet`."""
342329
=== modified file 'lib/lp/code/model/codeimportevent.py'
--- lib/lp/code/model/codeimportevent.py 2009-11-26 03:35:35 +0000
+++ lib/lp/code/model/codeimportevent.py 2010-01-12 21:08:17 +0000
@@ -257,13 +257,12 @@
257 def _iterSourceDetails(self, code_import):257 def _iterSourceDetails(self, code_import):
258 """Yield key-value tuples describing the source of the import."""258 """Yield key-value tuples describing the source of the import."""
259 if code_import.rcs_type in (RevisionControlSystems.SVN,259 if code_import.rcs_type in (RevisionControlSystems.SVN,
260 RevisionControlSystems.BZR_SVN):260 RevisionControlSystems.BZR_SVN,
261 yield 'SVN_BRANCH_URL', code_import.svn_branch_url261 RevisionControlSystems.GIT):
262 yield 'URL', code_import.url
262 elif code_import.rcs_type == RevisionControlSystems.CVS:263 elif code_import.rcs_type == RevisionControlSystems.CVS:
263 yield 'CVS_ROOT', code_import.cvs_root264 yield 'CVS_ROOT', code_import.cvs_root
264 yield 'CVS_MODULE', code_import.cvs_module265 yield 'CVS_MODULE', code_import.cvs_module
265 elif code_import.rcs_type == RevisionControlSystems.GIT:
266 yield 'GIT_REPO_URL', code_import.git_repo_url
267 else:266 else:
268 raise AssertionError(267 raise AssertionError(
269 "Unknown RCS type: %s" % (code_import.rcs_type,))268 "Unknown RCS type: %s" % (code_import.rcs_type,))
270269
=== modified file 'lib/lp/code/model/tests/test_codeimport.py'
--- lib/lp/code/model/tests/test_codeimport.py 2010-01-05 21:28:22 +0000
+++ lib/lp/code/model/tests/test_codeimport.py 2010-01-12 21:08:17 +0000
@@ -51,7 +51,7 @@
51 product=self.factory.makeProduct(),51 product=self.factory.makeProduct(),
52 branch_name='imported',52 branch_name='imported',
53 rcs_type=RevisionControlSystems.SVN,53 rcs_type=RevisionControlSystems.SVN,
54 svn_branch_url=self.factory.getUniqueURL())54 url=self.factory.getUniqueURL())
55 self.assertEqual(55 self.assertEqual(
56 CodeImportReviewStatus.NEW,56 CodeImportReviewStatus.NEW,
57 code_import.review_status)57 code_import.review_status)
@@ -65,7 +65,7 @@
65 product=self.factory.makeProduct(),65 product=self.factory.makeProduct(),
66 branch_name='imported',66 branch_name='imported',
67 rcs_type=RevisionControlSystems.SVN,67 rcs_type=RevisionControlSystems.SVN,
68 svn_branch_url=self.factory.getUniqueURL(),68 url=self.factory.getUniqueURL(),
69 review_status=CodeImportReviewStatus.REVIEWED)69 review_status=CodeImportReviewStatus.REVIEWED)
70 self.assertEqual(70 self.assertEqual(
71 CodeImportReviewStatus.REVIEWED,71 CodeImportReviewStatus.REVIEWED,
@@ -111,7 +111,7 @@
111 product=self.factory.makeProduct(),111 product=self.factory.makeProduct(),
112 branch_name='imported',112 branch_name='imported',
113 rcs_type=RevisionControlSystems.GIT,113 rcs_type=RevisionControlSystems.GIT,
114 git_repo_url=self.factory.getUniqueURL(),114 url=self.factory.getUniqueURL(),
115 review_status=None)115 review_status=None)
116 self.assertEqual(116 self.assertEqual(
117 CodeImportReviewStatus.REVIEWED,117 CodeImportReviewStatus.REVIEWED,
118118
=== modified file 'lib/lp/code/stories/codeimport/xx-admin-codeimport.txt'
--- lib/lp/code/stories/codeimport/xx-admin-codeimport.txt 2009-12-08 04:31:34 +0000
+++ lib/lp/code/stories/codeimport/xx-admin-codeimport.txt 2010-01-12 21:08:17 +0000
@@ -84,7 +84,7 @@
84 ... print '%s: %s' % (tag['name'], tag['value'])84 ... print '%s: %s' % (tag['name'], tag['value'])
8585
86 >>> print_form_fields(import_browser)86 >>> print_form_fields(import_browser)
87 field.svn_branch_url: svn://svn.example.com/fooix/trunk87 field.url: svn://svn.example.com/fooix/trunk
8888
89 >>> import_browser.open(cvs_import_location)89 >>> import_browser.open(cvs_import_location)
90 >>> import_browser.getLink('Edit import source or review import').click()90 >>> import_browser.getLink('Edit import source or review import').click()
@@ -95,7 +95,7 @@
95 >>> import_browser.open(git_import_location)95 >>> import_browser.open(git_import_location)
96 >>> import_browser.getLink('Edit import source or review import').click()96 >>> import_browser.getLink('Edit import source or review import').click()
97 >>> print_form_fields(import_browser)97 >>> print_form_fields(import_browser)
98 field.git_repo_url: git://git.example.org/fooix98 field.url: git://git.example.org/fooix
9999
100Editing the import location100Editing the import location
101+++++++++++++++++++++++++++101+++++++++++++++++++++++++++
@@ -106,7 +106,7 @@
106This is true for Subversion imports,106This is true for Subversion imports,
107107
108 >>> import_browser.open(svn_import_location + '/+edit-import')108 >>> import_browser.open(svn_import_location + '/+edit-import')
109 >>> import_browser.getControl('Branch URL').value = \109 >>> import_browser.getControl('URL').value = \
110 ... 'svn://svn-new.example.com/fooix/trunk'110 ... 'svn://svn-new.example.com/fooix/trunk'
111 >>> import_browser.getControl('Update').click()111 >>> import_browser.getControl('Update').click()
112 >>> for message in get_feedback_messages(import_browser.contents):112 >>> for message in get_feedback_messages(import_browser.contents):
@@ -116,7 +116,7 @@
116bzr-svn imports,116bzr-svn imports,
117117
118 >>> import_browser.open(bzr_svn_import_location + '/+edit-import')118 >>> import_browser.open(bzr_svn_import_location + '/+edit-import')
119 >>> import_browser.getControl('Branch URL').value = \119 >>> import_browser.getControl('URL').value = \
120 ... 'svn://svn-new.example.com/bzr-svn/trunk'120 ... 'svn://svn-new.example.com/bzr-svn/trunk'
121 >>> import_browser.getControl('Update').click()121 >>> import_browser.getControl('Update').click()
122 >>> for message in get_feedback_messages(import_browser.contents):122 >>> for message in get_feedback_messages(import_browser.contents):
@@ -138,7 +138,7 @@
138and Git imports.138and Git imports.
139139
140 >>> import_browser.open(git_import_location + '/+edit-import')140 >>> import_browser.open(git_import_location + '/+edit-import')
141 >>> import_browser.getControl('Repo URL').value = \141 >>> import_browser.getControl('URL').value = \
142 ... 'git://git-new.example.org/fooix'142 ... 'git://git-new.example.org/fooix'
143 >>> import_browser.getControl('Update').click()143 >>> import_browser.getControl('Update').click()
144 >>> for message in get_feedback_messages(import_browser.contents):144 >>> for message in get_feedback_messages(import_browser.contents):
145145
=== modified file 'lib/lp/code/stories/codeimport/xx-create-codeimport.txt'
--- lib/lp/code/stories/codeimport/xx-create-codeimport.txt 2009-12-08 02:32:03 +0000
+++ lib/lp/code/stories/codeimport/xx-create-codeimport.txt 2010-01-12 21:08:17 +0000
@@ -167,7 +167,7 @@
167 >>> for message in get_feedback_messages(browser.contents):167 >>> for message in get_feedback_messages(browser.contents):
168 ... print extract_text(message)168 ... print extract_text(message)
169 There is 1 error.169 There is 1 error.
170 This Subversion branch URL is already specified for170 This foreign branch URL is already specified for
171 the imported branch ~no-priv/firefox/imported.171 the imported branch ~no-priv/firefox/imported.
172172
173173
174174
=== modified file 'lib/lp/code/templates/branch-import-details.pt'
--- lib/lp/code/templates/branch-import-details.pt 2009-12-08 22:40:31 +0000
+++ lib/lp/code/templates/branch-import-details.pt 2010-01-12 21:08:17 +0000
@@ -41,7 +41,7 @@
4141
42 <tal:git-import condition="code_import/rcs_type/enumvalue:GIT">42 <tal:git-import condition="code_import/rcs_type/enumvalue:GIT">
43 <p>This branch is an import of the MASTER branch from the Git repo at43 <p>This branch is an import of the MASTER branch from the Git repo at
44 <span tal:replace="code_import/git_repo_url" />.44 <span tal:replace="code_import/url" />.
45 </p>45 </p>
46 </tal:git-import>46 </tal:git-import>
4747
@@ -51,11 +51,11 @@
51 <span tal:attributes="title code_import/rcs_type/title">Subversion</span>51 <span tal:attributes="title code_import/rcs_type/title">Subversion</span>
52 branch from52 branch from
53 <tal:is-web-url condition="view/svn_url_is_web">53 <tal:is-web-url condition="view/svn_url_is_web">
54 <a tal:attributes="href code_import/svn_branch_url"54 <a tal:attributes="href code_import/url"
55 tal:content="code_import/svn_branch_url" />.55 tal:content="code_import/url" />.
56 </tal:is-web-url>56 </tal:is-web-url>
57 <tal:not-web-url condition="not: view/svn_url_is_web">57 <tal:not-web-url condition="not: view/svn_url_is_web">
58 <span tal:replace="code_import/svn_branch_url" />.58 <span tal:replace="code_import/url" />.
59 </tal:not-web-url>59 </tal:not-web-url>
60 </p>60 </p>
61 </tal:svn-import>61 </tal:svn-import>
6262
=== modified file 'lib/lp/codehosting/codeimport/tests/test_worker.py'
--- lib/lp/codehosting/codeimport/tests/test_worker.py 2009-12-22 23:35:26 +0000
+++ lib/lp/codehosting/codeimport/tests/test_worker.py 2010-01-12 21:08:17 +0000
@@ -403,7 +403,7 @@
403 working_tree = store._getForeignTree('path')403 working_tree = store._getForeignTree('path')
404 self.assertIsSameRealPath(working_tree.local_path, 'path')404 self.assertIsSameRealPath(working_tree.local_path, 'path')
405 self.assertEqual(405 self.assertEqual(
406 working_tree.remote_url, source_details.svn_branch_url)406 working_tree.remote_url, source_details.url)
407407
408 def test_getForeignTreeCVS(self):408 def test_getForeignTreeCVS(self):
409 # _getForeignTree() returns a CVS working tree for CVS code imports.409 # _getForeignTree() returns a CVS working tree for CVS code imports.
@@ -770,7 +770,7 @@
770 def makeForeignCommit(self, source_details):770 def makeForeignCommit(self, source_details):
771 """Change the foreign tree."""771 """Change the foreign tree."""
772 client = pysvn.Client()772 client = pysvn.Client()
773 client.checkout(source_details.svn_branch_url, 'working_tree')773 client.checkout(source_details.url, 'working_tree')
774 file = open('working_tree/newfile', 'w')774 file = open('working_tree/newfile', 'w')
775 file.write('No real content\n')775 file.write('No real content\n')
776 file.close()776 file.close()
@@ -790,7 +790,7 @@
790 svn_branch_url = svn_branch_url.replace('://localhost/', ':///')790 svn_branch_url = svn_branch_url.replace('://localhost/', ':///')
791 self.foreign_commit_count = 2791 self.foreign_commit_count = 2
792 return self.factory.makeCodeImportSourceDetails(792 return self.factory.makeCodeImportSourceDetails(
793 rcstype=self.rcstype, svn_branch_url=svn_branch_url)793 rcstype=self.rcstype, url=svn_branch_url)
794794
795795
796class TestSubversionImport(WorkerTest, SubversionImportHelpers,796class TestSubversionImport(WorkerTest, SubversionImportHelpers,
@@ -822,14 +822,11 @@
822 # import should be rejected.822 # import should be rejected.
823 args = {'rcstype': self.rcstype}823 args = {'rcstype': self.rcstype}
824 reference_url = self.createBranchReference()824 reference_url = self.createBranchReference()
825 if self.rcstype == 'git':825 if self.rcstype in ('git', 'bzr-svn'):
826 args['git_repo_url'] = reference_url826 args['url'] = reference_url
827 elif self.rcstype == 'bzr-svn':
828 args['svn_branch_url'] = reference_url
829 else:827 else:
830 raise AssertionError("unexpected rcs_type %r" % self.rcs_type)828 raise AssertionError("unexpected rcs_type %r" % self.rcs_type)
831 source_details = self.factory.makeCodeImportSourceDetails(**args)829 source_details = self.factory.makeCodeImportSourceDetails(**args)
832
833 worker = self.makeImportWorker(source_details)830 worker = self.makeImportWorker(source_details)
834 self.assertRaises(NotBranchError, worker.run)831 self.assertRaises(NotBranchError, worker.run)
835832
@@ -866,7 +863,7 @@
866 """Change the foreign tree, generating exactly one commit."""863 """Change the foreign tree, generating exactly one commit."""
867 from bzrlib.plugins.git.tests import run_git864 from bzrlib.plugins.git.tests import run_git
868 wd = os.getcwd()865 wd = os.getcwd()
869 os.chdir(source_details.git_repo_url)866 os.chdir(source_details.url)
870 try:867 try:
871 run_git('config', 'user.name', 'Joe Random Hacker')868 run_git('config', 'user.name', 'Joe Random Hacker')
872 run_git('commit', '-m', 'dsadas')869 run_git('commit', '-m', 'dsadas')
@@ -886,7 +883,7 @@
886 self.foreign_commit_count = 1883 self.foreign_commit_count = 1
887884
888 return self.factory.makeCodeImportSourceDetails(885 return self.factory.makeCodeImportSourceDetails(
889 rcstype='git', git_repo_url=repository_path)886 rcstype='git', url=repository_path)
890887
891888
892class TestBzrSvnImport(WorkerTest, SubversionImportHelpers,889class TestBzrSvnImport(WorkerTest, SubversionImportHelpers,
893890
=== modified file 'lib/lp/codehosting/codeimport/tests/test_workermonitor.py'
--- lib/lp/codehosting/codeimport/tests/test_workermonitor.py 2009-12-04 03:31:06 +0000
+++ lib/lp/codehosting/codeimport/tests/test_workermonitor.py 2010-01-12 21:08:17 +0000
@@ -203,7 +203,7 @@
203 def check_source_details(details):203 def check_source_details(details):
204 job = self.worker_monitor.getJob()204 job = self.worker_monitor.getJob()
205 self.assertEqual(205 self.assertEqual(
206 details.svn_branch_url, job.code_import.svn_branch_url)206 details.url, job.code_import.url)
207 self.assertEqual(207 self.assertEqual(
208 details.cvs_root, job.code_import.cvs_root)208 details.cvs_root, job.code_import.cvs_root)
209 self.assertEqual(209 self.assertEqual(
@@ -470,12 +470,11 @@
470 self.subversion_server = SubversionServer(self.repo_path)470 self.subversion_server = SubversionServer(self.repo_path)
471 self.subversion_server.setUp()471 self.subversion_server.setUp()
472 self.addCleanup(self.subversion_server.tearDown)472 self.addCleanup(self.subversion_server.tearDown)
473 svn_branch_url = self.subversion_server.makeBranch(473 url = self.subversion_server.makeBranch(
474 'trunk', [('README', 'contents')])474 'trunk', [('README', 'contents')])
475 self.foreign_commit_count = 2475 self.foreign_commit_count = 2
476476
477 return self.factory.makeCodeImport(477 return self.factory.makeCodeImport(svn_branch_url=url)
478 svn_branch_url=svn_branch_url)
479478
480 def makeBzrSvnCodeImport(self):479 def makeBzrSvnCodeImport(self):
481 """Make a `CodeImport` that points to a real Subversion repository."""480 """Make a `CodeImport` that points to a real Subversion repository."""
@@ -483,13 +482,12 @@
483 self.repo_path, use_svn_serve=True)482 self.repo_path, use_svn_serve=True)
484 self.subversion_server.setUp()483 self.subversion_server.setUp()
485 self.addCleanup(self.subversion_server.tearDown)484 self.addCleanup(self.subversion_server.tearDown)
486 svn_branch_url = self.subversion_server.makeBranch(485 url = self.subversion_server.makeBranch(
487 'trunk', [('README', 'contents')])486 'trunk', [('README', 'contents')])
488 self.foreign_commit_count = 2487 self.foreign_commit_count = 2
489488
490 return self.factory.makeCodeImport(489 return self.factory.makeCodeImport(
491 svn_branch_url=svn_branch_url,490 svn_branch_url=url, rcs_type=RevisionControlSystems.BZR_SVN)
492 rcs_type=RevisionControlSystems.BZR_SVN)
493491
494 def makeGitCodeImport(self):492 def makeGitCodeImport(self):
495 """Make a `CodeImport` that points to a real Git repository."""493 """Make a `CodeImport` that points to a real Git repository."""
496494
=== modified file 'lib/lp/codehosting/codeimport/worker.py'
--- lib/lp/codehosting/codeimport/worker.py 2009-12-22 23:50:27 +0000
+++ lib/lp/codehosting/codeimport/worker.py 2010-01-12 21:08:17 +0000
@@ -107,80 +107,62 @@
107 :ivar branch_id: The id of the branch associated to this code import, used107 :ivar branch_id: The id of the branch associated to this code import, used
108 for locating the existing import and the foreign tree.108 for locating the existing import and the foreign tree.
109 :ivar rcstype: 'svn' or 'cvs' as appropriate.109 :ivar rcstype: 'svn' or 'cvs' as appropriate.
110 :ivar svn_branch_url: The branch URL if rcstype in ['svn', 'bzr-svn'],110 :ivar url: The branch URL if rcstype in ['svn', 'bzr-svn',
111 None otherwise.111 'git'], None otherwise.
112 :ivar cvs_root: The $CVSROOT if rcstype == 'cvs', None otherwise.112 :ivar cvs_root: The $CVSROOT if rcstype == 'cvs', None otherwise.
113 :ivar cvs_module: The CVS module if rcstype == 'cvs', None otherwise.113 :ivar cvs_module: The CVS module if rcstype == 'cvs', None otherwise.
114 :ivar git_repo_url: The URL of the git repo, if rcstype == 'git', None,
115 otherwise.
116 """114 """
117115
118 def __init__(self, branch_id, rcstype, svn_branch_url=None, cvs_root=None,116 def __init__(self, branch_id, rcstype, url=None, cvs_root=None,
119 cvs_module=None, git_repo_url=None):117 cvs_module=None):
120 self.branch_id = branch_id118 self.branch_id = branch_id
121 self.rcstype = rcstype119 self.rcstype = rcstype
122 self.svn_branch_url = svn_branch_url120 self.url = url
123 self.cvs_root = cvs_root121 self.cvs_root = cvs_root
124 self.cvs_module = cvs_module122 self.cvs_module = cvs_module
125 self.git_repo_url = git_repo_url
126123
127 @classmethod124 @classmethod
128 def fromArguments(cls, arguments):125 def fromArguments(cls, arguments):
129 """Convert command line-style arguments to an instance."""126 """Convert command line-style arguments to an instance."""
130 branch_id = int(arguments.pop(0))127 branch_id = int(arguments.pop(0))
131 rcstype = arguments.pop(0)128 rcstype = arguments.pop(0)
132 if rcstype in ['svn', 'bzr-svn']:129 if rcstype in ['svn', 'bzr-svn', 'git']:
133 [svn_branch_url] = arguments130 [url] = arguments
134 cvs_root = cvs_module = git_repo_url = None131 cvs_root = cvs_module = None
135 elif rcstype == 'cvs':132 elif rcstype == 'cvs':
136 svn_branch_url = git_repo_url = None133 url = None
137 [cvs_root, cvs_module] = arguments134 [cvs_root, cvs_module] = arguments
138 elif rcstype == 'git':
139 cvs_root = cvs_module = svn_branch_url = None
140 [git_repo_url] = arguments
141 else:135 else:
142 raise AssertionError("Unknown rcstype %r." % rcstype)136 raise AssertionError("Unknown rcstype %r." % rcstype)
143 return cls(137 return cls(branch_id, rcstype, url, cvs_root, cvs_module)
144 branch_id, rcstype, svn_branch_url, cvs_root, cvs_module,
145 git_repo_url)
146138
147 @classmethod139 @classmethod
148 def fromCodeImport(cls, code_import):140 def fromCodeImport(cls, code_import):
149 """Convert a `CodeImport` to an instance."""141 """Convert a `CodeImport` to an instance."""
142 branch_id = code_import.branch.id
150 if code_import.rcs_type == RevisionControlSystems.SVN:143 if code_import.rcs_type == RevisionControlSystems.SVN:
151 rcstype = 'svn'144 return cls(branch_id, 'svn', str(code_import.url))
152 svn_branch_url = str(code_import.svn_branch_url)
153 cvs_root = cvs_module = git_repo_url = None
154 elif code_import.rcs_type == RevisionControlSystems.BZR_SVN:145 elif code_import.rcs_type == RevisionControlSystems.BZR_SVN:
155 rcstype = 'bzr-svn'146 return cls(branch_id, 'bzr-svn', str(code_import.url))
156 svn_branch_url = str(code_import.svn_branch_url)
157 cvs_root = cvs_module = git_repo_url = None
158 elif code_import.rcs_type == RevisionControlSystems.CVS:147 elif code_import.rcs_type == RevisionControlSystems.CVS:
159 rcstype = 'cvs'148 return cls(
160 svn_branch_url = git_repo_url = None149 branch_id, 'cvs',
161 cvs_root = str(code_import.cvs_root)150 cvs_root=str(code_import.cvs_root),
162 cvs_module = str(code_import.cvs_module)151 cvs_module=str(code_import.cvs_module))
163 elif code_import.rcs_type == RevisionControlSystems.GIT:152 elif code_import.rcs_type == RevisionControlSystems.GIT:
164 rcstype = 'git'153 return cls(branch_id, 'git', str(code_import.url))
165 svn_branch_url = cvs_root = cvs_module = None
166 git_repo_url = str(code_import.git_repo_url)
167 else:154 else:
168 raise AssertionError("Unknown rcstype %r." % code_import.rcs_type)155 raise AssertionError("Unknown rcstype %r." % code_import.rcs_type)
169 return cls(
170 code_import.branch.id, rcstype, svn_branch_url,
171 cvs_root, cvs_module, git_repo_url)
172156
173 def asArguments(self):157 def asArguments(self):
174 """Return a list of arguments suitable for passing to a child process.158 """Return a list of arguments suitable for passing to a child process.
175 """159 """
176 result = [str(self.branch_id), self.rcstype]160 result = [str(self.branch_id), self.rcstype]
177 if self.rcstype in ['svn', 'bzr-svn']:161 if self.rcstype in ['svn', 'bzr-svn', 'git']:
178 result.append(self.svn_branch_url)162 result.append(self.url)
179 elif self.rcstype == 'cvs':163 elif self.rcstype == 'cvs':
180 result.append(self.cvs_root)164 result.append(self.cvs_root)
181 result.append(self.cvs_module)165 result.append(self.cvs_module)
182 elif self.rcstype == 'git':
183 result.append(self.git_repo_url)
184 else:166 else:
185 raise AssertionError("Unknown rcstype %r." % self.rcstype)167 raise AssertionError("Unknown rcstype %r." % self.rcstype)
186 return result168 return result
@@ -294,7 +276,7 @@
294 source_details = self.import_data_store.source_details276 source_details = self.import_data_store.source_details
295 if source_details.rcstype == 'svn':277 if source_details.rcstype == 'svn':
296 return SubversionWorkingTree(278 return SubversionWorkingTree(
297 source_details.svn_branch_url, str(target_path))279 source_details.url, str(target_path))
298 elif source_details.rcstype == 'cvs':280 elif source_details.rcstype == 'cvs':
299 return CVSWorkingTree(281 return CVSWorkingTree(
300 source_details.cvs_root, source_details.cvs_module,282 source_details.cvs_root, source_details.cvs_module,
@@ -492,12 +474,8 @@
492class PullingImportWorker(ImportWorker):474class PullingImportWorker(ImportWorker):
493 """An import worker for imports that can be done by a bzr plugin.475 """An import worker for imports that can be done by a bzr plugin.
494476
495 Subclasses need to implement `pull_url` and `format_classes`.477 Subclasses need to implement `format_classes`.
496 """478 """
497 @property
498 def pull_url(self):
499 """Return the URL that should be pulled from."""
500 raise NotImplementedError
501479
502 @property480 @property
503 def format_classes(self):481 def format_classes(self):
@@ -512,7 +490,7 @@
512 bzrlib.ui.ui_factory = LoggingUIFactory(490 bzrlib.ui.ui_factory = LoggingUIFactory(
513 writer=lambda m: self._logger.info('%s', m))491 writer=lambda m: self._logger.info('%s', m))
514 try:492 try:
515 transport = get_transport(self.pull_url)493 transport = get_transport(self.source_details.url)
516 for format_class in self.format_classes:494 for format_class in self.format_classes:
517 try:495 try:
518 format = format_class.probe_transport(transport)496 format = format_class.probe_transport(transport)
@@ -520,7 +498,7 @@
520 except NotBranchError:498 except NotBranchError:
521 pass499 pass
522 else:500 else:
523 raise NotBranchError(self.pull_url)501 raise NotBranchError(self.source_details.url)
524 foreign_branch = format.open(transport).open_branch()502 foreign_branch = format.open(transport).open_branch()
525 bazaar_tree.branch.pull(foreign_branch, overwrite=True)503 bazaar_tree.branch.pull(foreign_branch, overwrite=True)
526 finally:504 finally:
@@ -535,11 +513,6 @@
535 """513 """
536514
537 @property515 @property
538 def pull_url(self):
539 """See `PullingImportWorker.pull_url`."""
540 return self.source_details.git_repo_url
541
542 @property
543 def format_classes(self):516 def format_classes(self):
544 """See `PullingImportWorker.opening_format`."""517 """See `PullingImportWorker.opening_format`."""
545 # We only return LocalGitBzrDirFormat for tests.518 # We only return LocalGitBzrDirFormat for tests.
@@ -575,11 +548,6 @@
575 """An import worker for importing Subversion via bzr-svn."""548 """An import worker for importing Subversion via bzr-svn."""
576549
577 @property550 @property
578 def pull_url(self):
579 """See `PullingImportWorker.pull_url`."""
580 return self.source_details.svn_branch_url
581
582 @property
583 def format_classes(self):551 def format_classes(self):
584 """See `PullingImportWorker.opening_format`."""552 """See `PullingImportWorker.opening_format`."""
585 from bzrlib.plugins.svn.format import SvnRemoteFormat553 from bzrlib.plugins.svn.format import SvnRemoteFormat
586554
=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py 2010-01-05 00:53:47 +0000
+++ lib/lp/testing/factory.py 2010-01-12 21:08:17 +0000
@@ -1242,13 +1242,13 @@
1242 RevisionControlSystems.BZR_SVN)1242 RevisionControlSystems.BZR_SVN)
1243 return code_import_set.new(1243 return code_import_set.new(
1244 registrant, product, branch_name, rcs_type=rcs_type,1244 registrant, product, branch_name, rcs_type=rcs_type,
1245 svn_branch_url=svn_branch_url)1245 url=svn_branch_url)
1246 elif git_repo_url is not None:1246 elif git_repo_url is not None:
1247 assert rcs_type in (None, RevisionControlSystems.GIT)1247 assert rcs_type in (None, RevisionControlSystems.GIT)
1248 return code_import_set.new(1248 return code_import_set.new(
1249 registrant, product, branch_name,1249 registrant, product, branch_name,
1250 rcs_type=RevisionControlSystems.GIT,1250 rcs_type=RevisionControlSystems.GIT,
1251 git_repo_url=git_repo_url)1251 url=git_repo_url)
1252 else:1252 else:
1253 assert rcs_type in (None, RevisionControlSystems.CVS)1253 assert rcs_type in (None, RevisionControlSystems.CVS)
1254 return code_import_set.new(1254 return code_import_set.new(
@@ -1317,31 +1317,29 @@
1317 result_status, date_started, date_finished)1317 result_status, date_started, date_finished)
13181318
1319 def makeCodeImportSourceDetails(self, branch_id=None, rcstype=None,1319 def makeCodeImportSourceDetails(self, branch_id=None, rcstype=None,
1320 svn_branch_url=None, cvs_root=None,1320 url=None, cvs_root=None, cvs_module=None):
1321 cvs_module=None, git_repo_url=None):
1322 if branch_id is None:1321 if branch_id is None:
1323 branch_id = self.getUniqueInteger()1322 branch_id = self.getUniqueInteger()
1324 if rcstype is None:1323 if rcstype is None:
1325 rcstype = 'svn'1324 rcstype = 'svn'
1326 if rcstype in ['svn', 'bzr-svn']:1325 if rcstype in ['svn', 'bzr-svn']:
1327 assert cvs_root is cvs_module is git_repo_url is None1326 assert cvs_root is cvs_module is None
1328 if svn_branch_url is None:1327 if url is None:
1329 svn_branch_url = self.getUniqueURL()1328 url = self.getUniqueURL()
1330 elif rcstype == 'cvs':1329 elif rcstype == 'cvs':
1331 assert svn_branch_url is git_repo_url is None1330 assert url is None
1332 if cvs_root is None:1331 if cvs_root is None:
1333 cvs_root = self.getUniqueString()1332 cvs_root = self.getUniqueString()
1334 if cvs_module is None:1333 if cvs_module is None:
1335 cvs_module = self.getUniqueString()1334 cvs_module = self.getUniqueString()
1336 elif rcstype == 'git':1335 elif rcstype == 'git':
1337 assert cvs_root is cvs_module is svn_branch_url is None1336 assert cvs_root is cvs_module is None
1338 if git_repo_url is None:1337 if url is None:
1339 git_repo_url = self.getUniqueURL(scheme='git')1338 url = self.getUniqueURL(scheme='git')
1340 else:1339 else:
1341 raise AssertionError("Unknown rcstype %r." % rcstype)1340 raise AssertionError("Unknown rcstype %r." % rcstype)
1342 return CodeImportSourceDetails(1341 return CodeImportSourceDetails(
1343 branch_id, rcstype, svn_branch_url, cvs_root, cvs_module,1342 branch_id, rcstype, url, cvs_root, cvs_module)
1344 git_repo_url)
13451343
1346 def makeCodeReviewComment(self, sender=None, subject=None, body=None,1344 def makeCodeReviewComment(self, sender=None, subject=None, body=None,
1347 vote=None, vote_tag=None, parent=None,1345 vote=None, vote_tag=None, parent=None,

Subscribers

People subscribed via source and target branches

to status/vote changes: