Merge lp:~jcsackett/launchpad/mirrors-tell-where-they-live-652134 into lp:launchpad

Proposed by j.c.sackett on 2010-10-08
Status: Merged
Approved by: Gavin Panella on 2010-10-08
Approved revision: no longer in the source branch.
Merged at revision: 11722
Proposed branch: lp:~jcsackett/launchpad/mirrors-tell-where-they-live-652134
Merge into: lp:launchpad
Diff against target: 125 lines (+57/-9)
4 files modified
lib/lp/code/browser/tests/test_product.py (+22/-0)
lib/lp/code/stories/branches/xx-product-branches.txt (+10/-3)
lib/lp/code/templates/product-branch-summary.pt (+22/-5)
lib/lp/registry/model/product.py (+3/-1)
To merge this branch: bzr merge lp:~jcsackett/launchpad/mirrors-tell-where-they-live-652134
Reviewer Review Type Date Requested Status
Gavin Panella (community) 2010-10-08 Approve on 2010-10-08
Review via email: mp+37925@code.launchpad.net

Commit Message

Updates imported branches on products to display upstream information and present as EXTERNAL codehosting_usage.

Description of the Change

Summary
=======

Updates presentation of products with an imported development focus branch to
reflect a codehosting_usage of EXTERNAL, not NOT_APPLICABLE, and to show
the appropriate upstream data.

Proposed fix
============

Update the product code index page to show the upstream information if the
development focus branch is imported.

Pre-implementation notes
========================

Spoke with Curtis Hovey.

Implementation details
======================

Largely as in Proposed; however, the branch also corrected the
codehosting_usage enum to display a branch_type of IMPORTED as a
ServiceUsage of EXTERNAL. Previously it was NOT_APPLICABLE.

Tests
=====

bin/test -t code.*external_imported

Demo and Q/A
============

In launchpad.dev, add the gnome-terminal/imported branch as the focus branch
for gnome-terminal; gnome-terminal should show the upstream links for the
branch.

Lint
====

make lint output:

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/code/browser/tests/test_product.py
  lib/lp/code/templates/product-branch-summary.pt
  lib/lp/registry/model/product.py

To post a comment you must log in.
Gavin Panella (allenap) wrote :

Looks good, only one comment:

+ # Test that the correct information is shown for an import

I think the style here should be more declarative (if that's the right
term), so something like:

  The correct information is shown for an import.

It's probably worth explaining what's being tested rather than only
saying "correct information", unless it's easier to read the test than
to describe. Something like:

  The page for an imports of an external branch includes an
  explanation of where it came from and what it can be now be used
  for.

review: Approve
j.c.sackett (jcsackett) wrote :

> Looks good, only one comment:
>
> + # Test that the correct information is shown for an import
>
> I think the style here should be more declarative (if that's the right
> term), so something like:
>
> The correct information is shown for an import.
>
> It's probably worth explaining what's being tested rather than only
> saying "correct information", unless it's easier to read the test than
> to describe. Something like:
>
> The page for an imports of an external branch includes an
> explanation of where it came from and what it can be now be used
> for.

I have replaced the test comment with a better one per your suggestion. Thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/browser/tests/test_product.py'
2--- lib/lp/code/browser/tests/test_product.py 2010-10-08 16:38:43 +0000
3+++ lib/lp/code/browser/tests/test_product.py 2010-10-15 20:41:30 +0000
4@@ -31,6 +31,7 @@
5 BrowserTestCase,
6 login,
7 login_person,
8+ logout,
9 TestCaseWithFactory,
10 time_counter,
11 )
12@@ -157,6 +158,27 @@
13 class TestProductCodeIndexServiceUsages(ProductTestBase, BrowserTestCase):
14 """Tests for the product code page, especially the usage messasges."""
15
16+ def test_external_imported(self):
17+ # A product with an imported development focus branch should say so,
18+ # and should display the upstream information along with the LP info.
19+ product = self.factory.makeProduct()
20+ code_import = self.factory.makeProductCodeImport(
21+ svn_branch_url='http://svn.example.org/branch')
22+ login_person(product.owner)
23+ product.development_focus.branch = code_import.branch
24+ logout()
25+ self.assertEqual(ServiceUsage.EXTERNAL, product.codehosting_usage)
26+ browser = self.getUserBrowser(canonical_url(product, rootsite='code'))
27+ login(ANONYMOUS)
28+ content = find_tag_by_id(browser.contents, 'external')
29+ text = extract_text(content)
30+ expected = ("%(product_title)s hosts its code at %(branch_url)s. "
31+ "Launchpad imports the master branch and you can create "
32+ "branches from it." % dict(
33+ product_title=product.title,
34+ branch_url=code_import.url))
35+ self.assertTextMatchesExpressionIgnoreWhitespace(expected, text)
36+
37 def test_external_mirrored(self):
38 # A mirrored branch says code is hosted externally, and displays
39 # upstream data.
40
41=== modified file 'lib/lp/code/stories/branches/xx-product-branches.txt'
42--- lib/lp/code/stories/branches/xx-product-branches.txt 2010-09-28 19:25:54 +0000
43+++ lib/lp/code/stories/branches/xx-product-branches.txt 2010-10-15 20:41:30 +0000
44@@ -93,9 +93,16 @@
45 >>> browser.open('http://code.launchpad.dev/evolution')
46 >>> summary = get_summary(browser)
47 >>> print extract_text(get_summary(browser))
48- You can get a copy of the development focus branch using the
49- command:
50- bzr branch lp://dev/evolution
51+ The Evolution Groupware Application hosts its code
52+ externally.
53+ You can learn more at the project's
54+ web page.
55+ Launchpad imports the master branch and you can create branches from
56+ it.
57+ You can
58+ get a copy of the development focus branch
59+ using the command:
60+ bzr branch lp://dev/evolution
61
62 >>> links = summary.findAll('a')
63
64
65=== modified file 'lib/lp/code/templates/product-branch-summary.pt'
66--- lib/lp/code/templates/product-branch-summary.pt 2010-09-28 19:25:54 +0000
67+++ lib/lp/code/templates/product-branch-summary.pt 2010-10-15 20:41:30 +0000
68@@ -19,14 +19,26 @@
69 </div>
70
71 <div id="external"
72- tal:condition="context/codehosting_usage/enumvalue:EXTERNAL">
73- <p>
74- <strong>
75+ tal:condition="context/codehosting_usage/enumvalue:EXTERNAL"
76+ tal:define="branch view/branch">
77+ <strong>
78+ <p tal:condition="not: branch/branch_type/enumvalue:IMPORTED">
79 <tal:project_title replace="context/title" /> hosts its code at
80 <a tal:attributes="href view/mirror_location"
81 tal:content="view/mirror_location"></a>.
82- </strong>
83- </p>
84+ </p>
85+ <p tal:condition="branch/branch_type/enumvalue:IMPORTED">
86+ <tal:has-import-data condition="branch/code_import">
87+ <tal:project_title replace="context/title" /> hosts its code at
88+ <a tal:attributes="href branch/code_import/url"
89+ tal:content="branch/code_import/url"></a>.
90+ </tal:has-import-data>
91+ <tal:no-import-data condition="not: branch/code_import">
92+ <tal:project_title replace="context/title" /> hosts its code
93+ externally.
94+ </tal:no-import-data>
95+ </p>
96+ </strong>
97 <p tal:condition="context/homepageurl">
98 You can learn more at the project's
99 <a tal:attributes="href context/homepageurl">web page</a>.
100@@ -35,6 +47,11 @@
101 Launchpad has a mirror of the master branch and you can create branches
102 from it.
103 </p>
104+ <p tal:condition="view/branch/branch_type/enumvalue:IMPORTED">
105+ Launchpad imports the master branch and you can create branches from
106+ it.
107+ </p>
108+
109 <p tal:condition="view/branch/branch_type/enumvalue:REMOTE">
110 Launchpad does not have a copy of the remote branch.
111 </p>
112
113=== modified file 'lib/lp/registry/model/product.py'
114--- lib/lp/registry/model/product.py 2010-10-03 15:30:06 +0000
115+++ lib/lp/registry/model/product.py 2010-10-15 20:41:30 +0000
116@@ -405,7 +405,9 @@
117 elif self.development_focus.branch.branch_type == BranchType.HOSTED:
118 return ServiceUsage.LAUNCHPAD
119 elif self.development_focus.branch.branch_type in (
120- BranchType.MIRRORED, BranchType.REMOTE):
121+ BranchType.MIRRORED,
122+ BranchType.REMOTE,
123+ BranchType.IMPORTED):
124 return ServiceUsage.EXTERNAL
125 return ServiceUsage.NOT_APPLICABLE
126