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
=== modified file 'lib/lp/archiveuploader/dscfile.py'
--- lib/lp/archiveuploader/dscfile.py 2010-08-30 15:00:23 +0000
+++ lib/lp/archiveuploader/dscfile.py 2010-09-02 11:38:52 +0000
@@ -250,6 +250,7 @@
250 "format",250 "format",
251 "standards-version",251 "standards-version",
252 "filecontents",252 "filecontents",
253 "homepage",
253 ]))254 ]))
254255
255 # Note that files is actually only set inside verify().256 # Note that files is actually only set inside verify().
@@ -707,6 +708,7 @@
707 architecturehintlist=encoded.get('architecture', ''),708 architecturehintlist=encoded.get('architecture', ''),
708 creator=self.changes.changed_by['person'],709 creator=self.changes.changed_by['person'],
709 urgency=self.changes.converted_urgency,710 urgency=self.changes.converted_urgency,
711 homepage=encoded.get('homepage'),
710 dsc=encoded['filecontents'],712 dsc=encoded['filecontents'],
711 dscsigningkey=self.signingkey,713 dscsigningkey=self.signingkey,
712 dsc_maintainer_rfc822=encoded['maintainer'],714 dsc_maintainer_rfc822=encoded['maintainer'],
713715
=== modified file 'lib/lp/archiveuploader/nascentuploadfile.py'
--- lib/lp/archiveuploader/nascentuploadfile.py 2010-08-30 15:00:23 +0000
+++ lib/lp/archiveuploader/nascentuploadfile.py 2010-09-02 11:38:52 +0000
@@ -60,9 +60,11 @@
6060
61apt_pkg.InitSystem()61apt_pkg.InitSystem()
6262
63
63class UploadError(Exception):64class UploadError(Exception):
64 """All upload errors are returned in this form."""65 """All upload errors are returned in this form."""
6566
67
66class UploadWarning(Warning):68class UploadWarning(Warning):
67 """All upload warnings are returned in this form."""69 """All upload warnings are returned in this form."""
6870
@@ -72,6 +74,7 @@
7274
73 This was taken from jennifer in the DAK suite.75 This was taken from jennifer in the DAK suite.
74 """76 """
77
75 def __init__(self, future_cutoff, past_cutoff):78 def __init__(self, future_cutoff, past_cutoff):
76 """Setup timestamp limits """79 """Setup timestamp limits """
77 self.reset()80 self.reset()
@@ -126,7 +129,7 @@
126 ".deb": "application/x-debian-package",129 ".deb": "application/x-debian-package",
127 ".udeb": "application/x-micro-debian-package",130 ".udeb": "application/x-micro-debian-package",
128 ".diff.gz": "application/gzipped-patch",131 ".diff.gz": "application/gzipped-patch",
129 ".tar.gz": "application/gzipped-tar"132 ".tar.gz": "application/gzipped-tar",
130 }133 }
131134
132 def __init__(self, filepath, digest, size, component_and_section,135 def __init__(self, filepath, digest, size, component_and_section,
@@ -146,7 +149,6 @@
146 #149 #
147 # Helpers used quen inserting into queue150 # Helpers used quen inserting into queue
148 #151 #
149
150 @property152 @property
151 def content_type(self):153 def content_type(self):
152 """The content type for this file.154 """The content type for this file.
@@ -172,7 +174,6 @@
172 """Return the NascentUpload filename."""174 """Return the NascentUpload filename."""
173 return os.path.dirname(self.filepath)175 return os.path.dirname(self.filepath)
174176
175
176 @property177 @property
177 def exists_on_disk(self):178 def exists_on_disk(self):
178 """Whether or not the file is present on disk."""179 """Whether or not the file is present on disk."""
@@ -181,7 +182,6 @@
181 #182 #
182 # DB storage helpers183 # DB storage helpers
183 #184 #
184
185 def storeInDatabase(self):185 def storeInDatabase(self):
186 """Implement this to store this representation in the database."""186 """Implement this to store this representation in the database."""
187 raise NotImplementedError187 raise NotImplementedError
@@ -189,7 +189,6 @@
189 #189 #
190 # Verification190 # Verification
191 #191 #
192
193 def verify(self):192 def verify(self):
194 """Implemented locally.193 """Implemented locally.
195194
@@ -267,7 +266,7 @@
267 'raw-ddtp-tarball': PackageUploadCustomFormat.DDTP_TARBALL,266 'raw-ddtp-tarball': PackageUploadCustomFormat.DDTP_TARBALL,
268 'raw-translations-static':267 'raw-translations-static':
269 PackageUploadCustomFormat.STATIC_TRANSLATIONS,268 PackageUploadCustomFormat.STATIC_TRANSLATIONS,
270 'raw-meta-data' :269 'raw-meta-data':
271 PackageUploadCustomFormat.META_DATA,270 PackageUploadCustomFormat.META_DATA,
272 }271 }
273272
@@ -408,6 +407,7 @@
408 "Section",407 "Section",
409 "Maintainer",408 "Maintainer",
410 "Source",409 "Source",
410 "Homepage",
411 ]))411 ]))
412412
413 # Map priorities to their dbschema valuesa413 # Map priorities to their dbschema valuesa
@@ -419,7 +419,7 @@
419 "standard": PackagePublishingPriority.STANDARD,419 "standard": PackagePublishingPriority.STANDARD,
420 "optional": PackagePublishingPriority.OPTIONAL,420 "optional": PackagePublishingPriority.OPTIONAL,
421 "extra": PackagePublishingPriority.EXTRA,421 "extra": PackagePublishingPriority.EXTRA,
422 "-": PackagePublishingPriority.EXTRA422 "-": PackagePublishingPriority.EXTRA,
423 }423 }
424424
425 # These are divined when parsing the package file in verify(), and425 # These are divined when parsing the package file in verify(), and
@@ -452,7 +452,6 @@
452 #452 #
453 # Useful properties.453 # Useful properties.
454 #454 #
455
456 @property455 @property
457 def is_archindep(self):456 def is_archindep(self):
458 """Check if the binary is targeted to architecture 'all'.457 """Check if the binary is targeted to architecture 'all'.
@@ -753,15 +752,15 @@
753 % (self.filename, error))752 % (self.filename, error))
754753
755754
756#755 #
757# Database relationship methods756 # Database relationship methods
758#757 #
759
760 def findSourcePackageRelease(self):758 def findSourcePackageRelease(self):
761 """Return the respective ISourcePackagRelease for this binary upload.759 """Return the respective ISourcePackagRelease for this binary upload.
762760
763 It inspect publication in the targeted DistroSeries and also the761 It inspect publication in the targeted DistroSeries and also the
764 ACCEPTED queue for sources matching stored (source_name, source_version).762 ACCEPTED queue for sources matching stored
763 (source_name, source_version).
765764
766 It raises UploadError if the source was not found.765 It raises UploadError if the source was not found.
767766
@@ -897,7 +896,7 @@
897896
898 is_essential = encoded.get('Essential', '').lower() == 'yes'897 is_essential = encoded.get('Essential', '').lower() == 'yes'
899 architecturespecific = not self.is_archindep898 architecturespecific = not self.is_archindep
900 installedsize = int(self.control.get('Installed-Size','0'))899 installedsize = int(self.control.get('Installed-Size', '0'))
901 binary_name = getUtility(900 binary_name = getUtility(
902 IBinaryPackageNameSet).getOrCreateByName(self.package)901 IBinaryPackageNameSet).getOrCreateByName(self.package)
903902
@@ -929,6 +928,7 @@
929 pre_depends=encoded.get('Pre-Depends', ''),928 pre_depends=encoded.get('Pre-Depends', ''),
930 enhances=encoded.get('Enhances', ''),929 enhances=encoded.get('Enhances', ''),
931 breaks=encoded.get('Breaks', ''),930 breaks=encoded.get('Breaks', ''),
931 homepage=encoded.get('Homepage'),
932 essential=is_essential,932 essential=is_essential,
933 installedsize=installedsize,933 installedsize=installedsize,
934 architecturespecific=architecturespecific,934 architecturespecific=architecturespecific,
935935
=== modified file 'lib/lp/archiveuploader/tests/test_nascentuploadfile.py'
--- lib/lp/archiveuploader/tests/test_nascentuploadfile.py 2010-08-27 02:21:01 +0000
+++ lib/lp/archiveuploader/tests/test_nascentuploadfile.py 2010-09-02 11:38:52 +0000
@@ -176,7 +176,7 @@
176 self.assertEquals("dpkg, bzr", release.builddepends)176 self.assertEquals("dpkg, bzr", release.builddepends)
177177
178 def test_user_defined_fields(self):178 def test_user_defined_fields(self):
179 # Test that storeInDatabase updates user_defined_fields.179 # storeInDatabase updates user_defined_fields.
180 dsc = self.getBaseDsc()180 dsc = self.getBaseDsc()
181 dsc["Python-Version"] = "2.5"181 dsc["Python-Version"] = "2.5"
182 changes = self.getBaseChanges()182 changes = self.getBaseChanges()
@@ -190,6 +190,19 @@
190 self.assertEquals(190 self.assertEquals(
191 [["python-version", u"2.5"]], release.user_defined_fields)191 [["python-version", u"2.5"]], release.user_defined_fields)
192192
193 def test_homepage(self):
194 # storeInDatabase updates homepage.
195 dsc = self.getBaseDsc()
196 dsc["Homepage"] = "http://samba.org/~jelmer/bzr"
197 changes = self.getBaseChanges()
198 uploadfile = self.createDSCFile(
199 "foo.dsc", dsc, "main/net", "extra", "dulwich", "0.42",
200 self.createChangesFile("foo.changes", changes))
201 uploadfile.changelog = "DUMMY"
202 uploadfile.files = []
203 release = uploadfile.storeInDatabase(None)
204 self.assertEquals(u"http://samba.org/~jelmer/bzr", release.homepage)
205
193206
194class DebBinaryUploadFileTests(PackageUploadFileTestCase):207class DebBinaryUploadFileTests(PackageUploadFileTestCase):
195 """Tests for DebBinaryUploadFile."""208 """Tests for DebBinaryUploadFile."""
@@ -211,7 +224,7 @@
211 "Homepage": "http://samba.org/~jelmer/dulwich",224 "Homepage": "http://samba.org/~jelmer/dulwich",
212 "Description": "Pure-python Git library\n"225 "Description": "Pure-python Git library\n"
213 "Dulwich is a Python implementation of the file formats and "226 "Dulwich is a Python implementation of the file formats and "
214 "protocols"227 "protocols",
215 }228 }
216229
217 def createDebBinaryUploadFile(self, filename, component_and_section,230 def createDebBinaryUploadFile(self, filename, component_and_section,
@@ -270,10 +283,7 @@
270 build = self.factory.makeBinaryPackageBuild()283 build = self.factory.makeBinaryPackageBuild()
271 bpr = uploadfile.storeInDatabase(build)284 bpr = uploadfile.storeInDatabase(build)
272 self.assertEquals(285 self.assertEquals(
273 [286 [[u"Python-Version", u"2.5"]], bpr.user_defined_fields)
274 [u"Homepage", u"http://samba.org/~jelmer/dulwich"],
275 [u"Python-Version", u"2.5"]
276 ], bpr.user_defined_fields)
277287
278 def test_user_defined_fields_newlines(self):288 def test_user_defined_fields_newlines(self):
279 # storeInDatabase stores user defined fields and keeps newlines.289 # storeInDatabase stores user defined fields and keeps newlines.
@@ -288,5 +298,17 @@
288 self.assertEquals(298 self.assertEquals(
289 [299 [
290 [u"RandomData", u"Foo\nbar\nbla\n"],300 [u"RandomData", u"Foo\nbar\nbla\n"],
291 [u"Homepage", u"http://samba.org/~jelmer/dulwich"],
292 ], bpr.user_defined_fields)301 ], bpr.user_defined_fields)
302
303 def test_homepage(self):
304 # storeInDatabase stores homepage field.
305 uploadfile = self.createDebBinaryUploadFile(
306 "foo_0.42_i386.deb", "main/python", "unknown", "mypkg", "0.42",
307 None)
308 control = self.getBaseControl()
309 control["Python-Version"] = "2.5"
310 uploadfile.parseControl(control)
311 build = self.factory.makeBinaryPackageBuild()
312 bpr = uploadfile.storeInDatabase(build)
313 self.assertEquals(
314 u"http://samba.org/~jelmer/dulwich", bpr.homepage)
293315
=== modified file 'lib/lp/registry/browser/product.py'
--- lib/lp/registry/browser/product.py 2010-08-25 23:43:13 +0000
+++ lib/lp/registry/browser/product.py 2010-09-02 11:38:52 +0000
@@ -2001,7 +2001,7 @@
2001 """Step 2 (of 2) in the +new project add wizard."""2001 """Step 2 (of 2) in the +new project add wizard."""
20022002
2003 _field_names = ['displayname', 'name', 'title', 'summary',2003 _field_names = ['displayname', 'name', 'title', 'summary',
2004 'description', 'licenses', 'license_info',2004 'description', 'homepageurl', 'licenses', 'license_info',
2005 ]2005 ]
2006 schema = IProduct2006 schema = IProduct
2007 step_name = 'projectaddstep2'2007 step_name = 'projectaddstep2'
@@ -2012,6 +2012,7 @@
20122012
2013 custom_widget('displayname', TextWidget, displayWidth=50, label='Name')2013 custom_widget('displayname', TextWidget, displayWidth=50, label='Name')
2014 custom_widget('name', ProductNameWidget, label='URL')2014 custom_widget('name', ProductNameWidget, label='URL')
2015 custom_widget('homepageurl', TextWidget, displayWidth=30)
2015 custom_widget('licenses', LicenseWidget)2016 custom_widget('licenses', LicenseWidget)
2016 custom_widget('license_info', GhostWidget)2017 custom_widget('license_info', GhostWidget)
20172018
@@ -2169,6 +2170,7 @@
2169 title=data['title'],2170 title=data['title'],
2170 summary=data['summary'],2171 summary=data['summary'],
2171 description=description,2172 description=description,
2173 homepageurl=data.get('homepageurl'),
2172 licenses=data['licenses'],2174 licenses=data['licenses'],
2173 license_info=data['license_info'],2175 license_info=data['license_info'],
2174 project=project)2176 project=project)
21752177
=== modified file 'lib/lp/registry/stories/product/xx-product-add.txt'
--- lib/lp/registry/stories/product/xx-product-add.txt 2010-06-18 18:07:11 +0000
+++ lib/lp/registry/stories/product/xx-product-add.txt 2010-09-02 11:38:52 +0000
@@ -95,9 +95,9 @@
95The second step of the registration process does not allow Sample Person to95The second step of the registration process does not allow Sample Person to
96modify the project's URL.96modify the project's URL.
9797
98 >>> user_browser.getControl('URL')98 >>> user_browser.getControl(name='field.name')
99 <Control name='field.name' type='hidden'>99 <Control name='field.name' type='hidden'>
100 >>> print user_browser.getControl('URL').value100 >>> print user_browser.getControl(name='field.name').value
101 aardvark101 aardvark
102102
103Sample Person is given the opportunity though to change the title and103Sample Person is given the opportunity though to change the title and
104104
=== modified file 'lib/lp/soyuz/tests/test_publishing.py'
--- lib/lp/soyuz/tests/test_publishing.py 2010-08-30 15:00:23 +0000
+++ lib/lp/soyuz/tests/test_publishing.py 2010-09-02 11:38:52 +0000
@@ -357,7 +357,7 @@
357 depends=None, recommends=None, suggests=None, conflicts=None,357 depends=None, recommends=None, suggests=None, conflicts=None,
358 replaces=None, provides=None, pre_depends=None, enhances=None,358 replaces=None, provides=None, pre_depends=None, enhances=None,
359 breaks=None, format=BinaryPackageFormat.DEB, debug_package=None,359 breaks=None, format=BinaryPackageFormat.DEB, debug_package=None,
360 user_defined_fields=None):360 user_defined_fields=None, homepage=None):
361 """Return the corresponding `BinaryPackageRelease`."""361 """Return the corresponding `BinaryPackageRelease`."""
362 sourcepackagerelease = build.source_package_release362 sourcepackagerelease = build.source_package_release
363 distroarchseries = build.distro_arch_series363 distroarchseries = build.distro_arch_series
@@ -390,7 +390,7 @@
390 binpackageformat=format,390 binpackageformat=format,
391 priority=PackagePublishingPriority.STANDARD,391 priority=PackagePublishingPriority.STANDARD,
392 debug_package=debug_package,392 debug_package=debug_package,
393 user_defined_fields=user_defined_fields)393 user_defined_fields=user_defined_fields, homepage=homepage)
394394
395 # Create the corresponding binary file.395 # Create the corresponding binary file.
396 if architecturespecific:396 if architecturespecific:

Subscribers

People subscribed via source and target branches

to status/vote changes: