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