Colin Watson has proposed merging
lp:~cjwatson/launchpad/codeimport-git-read-only-views into lp:launchpad with
lp:~cjwatson/launchpad/git-code-import-security-deletion as a prerequisite.
Commit message:
Add read-only views for Git-targeted code imports.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1469459 in Launchpad itself: "import external code into a LP git repo
(natively)"
https://bugs.launchpad.net/launchpad/+bug/1469459
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/codeimport-git-read-only-views/+merge/308374
We don't have much in the way of tests for this yet, but that will be easier to
bring up once we have creation webservice/view handling in place.
--
Your team Launchpad code reviewers is requested to review the proposed merge of
lp:~cjwatson/launchpad/codeimport-git-read-only-views into lp:launchpad.
=== modified file 'lib/lp/code/browser/branch.py'
--- lib/lp/code/browser/branch.py 2016-05-07 00:40:18 +
+++ lib/lp/code/browser/branch.py 2016-10-13 12:55:20 +
@@ -89,12 +89,12 @@
latest_proposals_for_each_branch,
)
from lp.code.browser.branchref import BranchRef
+from lp.code.browser.codeimport import CodeImportTargetMixin
from lp.code.browser.decorations import DecoratedBranch
from lp.code.browser.sourcepackagerecipelisting import HasRecipesMenuMixin
from lp.code.browser.widgets.branchtarget import BranchTargetWidget
from lp.code.enums import (
BranchType,
-CodeImportResultStatus,
CodeImportReviewStatus,
)
from lp.code.errors import (
@@ -403,7 +403,7 @@
class BranchView(InformationTypePortletMixin, FeedsMixin, BranchMirrorMixin,
- LaunchpadView, HasSnapsViewMixin):
+ LaunchpadView, HasSnapsViewMixin, CodeImportTargetMixin):
feed_types = (
BranchFeedLink,
@@ -596,31 +596,6 @@
return collection.getExtendedRevisionDetails(
self.user, self.context.latest_revisions)
-@cachedproperty
-def latest_code_import_results(self):
-"""Return the last 10 CodeImportResults."""
-return list(self.context.code_import.results[:10])
-
-def iconForCodeImportResultStatus(self, status):
-"""The icon to represent the `CodeImportResultStatus` `status`."""
-if status == CodeImportResultStatus.SUCCESS_PARTIAL:
-return "/@@/yes-gray"
-elif status in CodeImportResultStatus.successes:
-return "/@@/yes"
-else:
-return "/@@/no"
-
-@property
-def url_is_web(self):
-"""True if an imported branch's URL is HTTP or HTTPS."""
-# You should only be calling this if it's an SVN, BZR or GIT code
-# import
-assert self.context.code_import
-url = self.context.code_import.url
-assert url
-# https starts with http too!
-return url.startswith("http")
-
@property
def show_merge_links(self):
"""Return whether or not merge proposal links should be shown.
@@ -799,7 +774,7 @@
target is not None and target != self.context.target):
try:
self.context.setTarget(self.user, project=target)
-except BranchTargetError, e:
+except BranchTargetError as e:
self.setFieldError('target', e.message)
return
=== modified file 'lib/lp/code/browser/codeimport.py'
--- lib/lp/code/browser/codeimport.py 2016-10-06 15:59:34 +
+++ lib/lp/code/browser/codeimport.py 2016-10-13 12:55:20 +
@@ -12,6 +12,7 @@
'CodeImportSetBreadcrumb',
'CodeImportSetNavigation',
'CodeImportSetView',
+'CodeImportTargetMixin',
'validate_import_url',
]
@@ -49,6 +50,7 @@
from lp.code.enums import (
BranchSubscriptionDiffSize,
BranchSubscriptionNotificationLevel,
+CodeImportResultStatus,
CodeImportReviewStatus,
CodeReviewNotificationLevel,
NON_CVS_RCS_TYPES,
@@ -191,8 +193,8 @@
self.addError(structured("""
Those CVS details are already specified for
the imported branch %s.""",
-canonical_url(code_import.branch),
-code_import.branch.unique_name))
+canonical_url(code_import.target),
+code_import.target.unique_name))
def _validateURL(self, url, rcs_type, existing_import=None,
field_name='url'):
@@ -495,12 +497,12 @@
class CodeImportEditView(CodeImportBaseView):
"""View for editing code imports.
-This view is registered against the branch, but mostly edits the code
-import for that branch -- the exception being that it also allows the
-editing of the branch whiteboard. If the branch has no associated code
-import, then the result is a 404. If the branch does have a code import,
-then the adapters property allows the form internals