Merge lp:~jelmer/launchpad/621778-parse-homepage-field into lp:launchpad/db-devel

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merged at revision: 9738
Proposed branch: lp:~jelmer/launchpad/621778-parse-homepage-field
Merge into: lp:launchpad/db-devel
Prerequisite: lp:~jelmer/launchpad/621778-homepage-field
Diff against target: 296 lines (+52/-26)
6 files modified
lib/lp/archiveuploader/dscfile.py (+2/-0)
lib/lp/archiveuploader/nascentuploadfile.py (+14/-14)
lib/lp/archiveuploader/tests/test_nascentuploadfile.py (+29/-7)
lib/lp/registry/browser/product.py (+3/-1)
lib/lp/registry/stories/product/xx-product-add.txt (+2/-2)
lib/lp/soyuz/tests/test_publishing.py (+2/-2)
To merge this branch: bzr merge lp:~jelmer/launchpad/621778-parse-homepage-field
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) code Approve
Review via email: mp+33334@code.launchpad.net

Commit message

Parse Homepage field and store it in SourcePackageRelease/BinaryPackageRelease.

Description of the change

This adds support for parsing the Homepage field from SourcePackageRelease/BinaryPackageRelease control files and storing that information in the appropriate database fields.

To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Looks good. Just two notes:

In line 49 of the diff: don't bother documenting tests as "Test that…" That's obvious from them being test methods. Just takes up space.

In line 94 of the diff: badly formatted line break. Try putting both arguments to the assertEqual together on the line after the invocation.

Please mention the "make lint" output in your merge proposals so that your reviewer doesn't need to worry about whether they have to play human linter. If there's too much pre-existing lint, well, throw in some drive-by cleanups!

review: Approve (code)
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

> Looks good. Just two notes:
>
> In line 49 of the diff: don't bother documenting tests as "Test that…" That's
> obvious from them being test methods. Just takes up space.
>
> In line 94 of the diff: badly formatted line break. Try putting both
> arguments to the assertEqual together on the line after the invocation.
>
> Please mention the "make lint" output in your merge proposals so that your
> reviewer doesn't need to worry about whether they have to play human linter.
> If there's too much pre-existing lint, well, throw in some drive-by cleanups!
Thanks. I've fixed the issues you've mentioned and cleaned up the lint in the files I've changed.

Is there an easy way to lint all affected files, other than through the lpreview-body plugin?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/archiveuploader/dscfile.py'
2--- lib/lp/archiveuploader/dscfile.py 2010-08-30 15:00:23 +0000
3+++ lib/lp/archiveuploader/dscfile.py 2010-09-02 11:38:52 +0000
4@@ -250,6 +250,7 @@
5 "format",
6 "standards-version",
7 "filecontents",
8+ "homepage",
9 ]))
10
11 # Note that files is actually only set inside verify().
12@@ -707,6 +708,7 @@
13 architecturehintlist=encoded.get('architecture', ''),
14 creator=self.changes.changed_by['person'],
15 urgency=self.changes.converted_urgency,
16+ homepage=encoded.get('homepage'),
17 dsc=encoded['filecontents'],
18 dscsigningkey=self.signingkey,
19 dsc_maintainer_rfc822=encoded['maintainer'],
20
21=== modified file 'lib/lp/archiveuploader/nascentuploadfile.py'
22--- lib/lp/archiveuploader/nascentuploadfile.py 2010-08-30 15:00:23 +0000
23+++ lib/lp/archiveuploader/nascentuploadfile.py 2010-09-02 11:38:52 +0000
24@@ -60,9 +60,11 @@
25
26 apt_pkg.InitSystem()
27
28+
29 class UploadError(Exception):
30 """All upload errors are returned in this form."""
31
32+
33 class UploadWarning(Warning):
34 """All upload warnings are returned in this form."""
35
36@@ -72,6 +74,7 @@
37
38 This was taken from jennifer in the DAK suite.
39 """
40+
41 def __init__(self, future_cutoff, past_cutoff):
42 """Setup timestamp limits """
43 self.reset()
44@@ -126,7 +129,7 @@
45 ".deb": "application/x-debian-package",
46 ".udeb": "application/x-micro-debian-package",
47 ".diff.gz": "application/gzipped-patch",
48- ".tar.gz": "application/gzipped-tar"
49+ ".tar.gz": "application/gzipped-tar",
50 }
51
52 def __init__(self, filepath, digest, size, component_and_section,
53@@ -146,7 +149,6 @@
54 #
55 # Helpers used quen inserting into queue
56 #
57-
58 @property
59 def content_type(self):
60 """The content type for this file.
61@@ -172,7 +174,6 @@
62 """Return the NascentUpload filename."""
63 return os.path.dirname(self.filepath)
64
65-
66 @property
67 def exists_on_disk(self):
68 """Whether or not the file is present on disk."""
69@@ -181,7 +182,6 @@
70 #
71 # DB storage helpers
72 #
73-
74 def storeInDatabase(self):
75 """Implement this to store this representation in the database."""
76 raise NotImplementedError
77@@ -189,7 +189,6 @@
78 #
79 # Verification
80 #
81-
82 def verify(self):
83 """Implemented locally.
84
85@@ -267,7 +266,7 @@
86 'raw-ddtp-tarball': PackageUploadCustomFormat.DDTP_TARBALL,
87 'raw-translations-static':
88 PackageUploadCustomFormat.STATIC_TRANSLATIONS,
89- 'raw-meta-data' :
90+ 'raw-meta-data':
91 PackageUploadCustomFormat.META_DATA,
92 }
93
94@@ -408,6 +407,7 @@
95 "Section",
96 "Maintainer",
97 "Source",
98+ "Homepage",
99 ]))
100
101 # Map priorities to their dbschema valuesa
102@@ -419,7 +419,7 @@
103 "standard": PackagePublishingPriority.STANDARD,
104 "optional": PackagePublishingPriority.OPTIONAL,
105 "extra": PackagePublishingPriority.EXTRA,
106- "-": PackagePublishingPriority.EXTRA
107+ "-": PackagePublishingPriority.EXTRA,
108 }
109
110 # These are divined when parsing the package file in verify(), and
111@@ -452,7 +452,6 @@
112 #
113 # Useful properties.
114 #
115-
116 @property
117 def is_archindep(self):
118 """Check if the binary is targeted to architecture 'all'.
119@@ -753,15 +752,15 @@
120 % (self.filename, error))
121
122
123-#
124-# Database relationship methods
125-#
126-
127+ #
128+ # Database relationship methods
129+ #
130 def findSourcePackageRelease(self):
131 """Return the respective ISourcePackagRelease for this binary upload.
132
133 It inspect publication in the targeted DistroSeries and also the
134- ACCEPTED queue for sources matching stored (source_name, source_version).
135+ ACCEPTED queue for sources matching stored
136+ (source_name, source_version).
137
138 It raises UploadError if the source was not found.
139
140@@ -897,7 +896,7 @@
141
142 is_essential = encoded.get('Essential', '').lower() == 'yes'
143 architecturespecific = not self.is_archindep
144- installedsize = int(self.control.get('Installed-Size','0'))
145+ installedsize = int(self.control.get('Installed-Size', '0'))
146 binary_name = getUtility(
147 IBinaryPackageNameSet).getOrCreateByName(self.package)
148
149@@ -929,6 +928,7 @@
150 pre_depends=encoded.get('Pre-Depends', ''),
151 enhances=encoded.get('Enhances', ''),
152 breaks=encoded.get('Breaks', ''),
153+ homepage=encoded.get('Homepage'),
154 essential=is_essential,
155 installedsize=installedsize,
156 architecturespecific=architecturespecific,
157
158=== modified file 'lib/lp/archiveuploader/tests/test_nascentuploadfile.py'
159--- lib/lp/archiveuploader/tests/test_nascentuploadfile.py 2010-08-27 02:21:01 +0000
160+++ lib/lp/archiveuploader/tests/test_nascentuploadfile.py 2010-09-02 11:38:52 +0000
161@@ -176,7 +176,7 @@
162 self.assertEquals("dpkg, bzr", release.builddepends)
163
164 def test_user_defined_fields(self):
165- # Test that storeInDatabase updates user_defined_fields.
166+ # storeInDatabase updates user_defined_fields.
167 dsc = self.getBaseDsc()
168 dsc["Python-Version"] = "2.5"
169 changes = self.getBaseChanges()
170@@ -190,6 +190,19 @@
171 self.assertEquals(
172 [["python-version", u"2.5"]], release.user_defined_fields)
173
174+ def test_homepage(self):
175+ # storeInDatabase updates homepage.
176+ dsc = self.getBaseDsc()
177+ dsc["Homepage"] = "http://samba.org/~jelmer/bzr"
178+ changes = self.getBaseChanges()
179+ uploadfile = self.createDSCFile(
180+ "foo.dsc", dsc, "main/net", "extra", "dulwich", "0.42",
181+ self.createChangesFile("foo.changes", changes))
182+ uploadfile.changelog = "DUMMY"
183+ uploadfile.files = []
184+ release = uploadfile.storeInDatabase(None)
185+ self.assertEquals(u"http://samba.org/~jelmer/bzr", release.homepage)
186+
187
188 class DebBinaryUploadFileTests(PackageUploadFileTestCase):
189 """Tests for DebBinaryUploadFile."""
190@@ -211,7 +224,7 @@
191 "Homepage": "http://samba.org/~jelmer/dulwich",
192 "Description": "Pure-python Git library\n"
193 "Dulwich is a Python implementation of the file formats and "
194- "protocols"
195+ "protocols",
196 }
197
198 def createDebBinaryUploadFile(self, filename, component_and_section,
199@@ -270,10 +283,7 @@
200 build = self.factory.makeBinaryPackageBuild()
201 bpr = uploadfile.storeInDatabase(build)
202 self.assertEquals(
203- [
204- [u"Homepage", u"http://samba.org/~jelmer/dulwich"],
205- [u"Python-Version", u"2.5"]
206- ], bpr.user_defined_fields)
207+ [[u"Python-Version", u"2.5"]], bpr.user_defined_fields)
208
209 def test_user_defined_fields_newlines(self):
210 # storeInDatabase stores user defined fields and keeps newlines.
211@@ -288,5 +298,17 @@
212 self.assertEquals(
213 [
214 [u"RandomData", u"Foo\nbar\nbla\n"],
215- [u"Homepage", u"http://samba.org/~jelmer/dulwich"],
216 ], bpr.user_defined_fields)
217+
218+ def test_homepage(self):
219+ # storeInDatabase stores homepage field.
220+ uploadfile = self.createDebBinaryUploadFile(
221+ "foo_0.42_i386.deb", "main/python", "unknown", "mypkg", "0.42",
222+ None)
223+ control = self.getBaseControl()
224+ control["Python-Version"] = "2.5"
225+ uploadfile.parseControl(control)
226+ build = self.factory.makeBinaryPackageBuild()
227+ bpr = uploadfile.storeInDatabase(build)
228+ self.assertEquals(
229+ u"http://samba.org/~jelmer/dulwich", bpr.homepage)
230
231=== modified file 'lib/lp/registry/browser/product.py'
232--- lib/lp/registry/browser/product.py 2010-08-25 23:43:13 +0000
233+++ lib/lp/registry/browser/product.py 2010-09-02 11:38:52 +0000
234@@ -2001,7 +2001,7 @@
235 """Step 2 (of 2) in the +new project add wizard."""
236
237 _field_names = ['displayname', 'name', 'title', 'summary',
238- 'description', 'licenses', 'license_info',
239+ 'description', 'homepageurl', 'licenses', 'license_info',
240 ]
241 schema = IProduct
242 step_name = 'projectaddstep2'
243@@ -2012,6 +2012,7 @@
244
245 custom_widget('displayname', TextWidget, displayWidth=50, label='Name')
246 custom_widget('name', ProductNameWidget, label='URL')
247+ custom_widget('homepageurl', TextWidget, displayWidth=30)
248 custom_widget('licenses', LicenseWidget)
249 custom_widget('license_info', GhostWidget)
250
251@@ -2169,6 +2170,7 @@
252 title=data['title'],
253 summary=data['summary'],
254 description=description,
255+ homepageurl=data.get('homepageurl'),
256 licenses=data['licenses'],
257 license_info=data['license_info'],
258 project=project)
259
260=== modified file 'lib/lp/registry/stories/product/xx-product-add.txt'
261--- lib/lp/registry/stories/product/xx-product-add.txt 2010-06-18 18:07:11 +0000
262+++ lib/lp/registry/stories/product/xx-product-add.txt 2010-09-02 11:38:52 +0000
263@@ -95,9 +95,9 @@
264 The second step of the registration process does not allow Sample Person to
265 modify the project's URL.
266
267- >>> user_browser.getControl('URL')
268+ >>> user_browser.getControl(name='field.name')
269 <Control name='field.name' type='hidden'>
270- >>> print user_browser.getControl('URL').value
271+ >>> print user_browser.getControl(name='field.name').value
272 aardvark
273
274 Sample Person is given the opportunity though to change the title and
275
276=== modified file 'lib/lp/soyuz/tests/test_publishing.py'
277--- lib/lp/soyuz/tests/test_publishing.py 2010-08-30 15:00:23 +0000
278+++ lib/lp/soyuz/tests/test_publishing.py 2010-09-02 11:38:52 +0000
279@@ -357,7 +357,7 @@
280 depends=None, recommends=None, suggests=None, conflicts=None,
281 replaces=None, provides=None, pre_depends=None, enhances=None,
282 breaks=None, format=BinaryPackageFormat.DEB, debug_package=None,
283- user_defined_fields=None):
284+ user_defined_fields=None, homepage=None):
285 """Return the corresponding `BinaryPackageRelease`."""
286 sourcepackagerelease = build.source_package_release
287 distroarchseries = build.distro_arch_series
288@@ -390,7 +390,7 @@
289 binpackageformat=format,
290 priority=PackagePublishingPriority.STANDARD,
291 debug_package=debug_package,
292- user_defined_fields=user_defined_fields)
293+ user_defined_fields=user_defined_fields, homepage=homepage)
294
295 # Create the corresponding binary file.
296 if architecturespecific:

Subscribers

People subscribed via source and target branches

to status/vote changes: