Merge lp:~stevenk/launchpad/gina-populate-changelog into lp:launchpad

Proposed by Steve Kowalik
Status: Merged
Approved by: Graham Binns
Approved revision: no longer in the source branch.
Merged at revision: 11967
Proposed branch: lp:~stevenk/launchpad/gina-populate-changelog
Merge into: lp:launchpad
Diff against target: 126 lines (+37/-12)
3 files modified
lib/lp/soyuz/doc/gina.txt (+15/-0)
lib/lp/soyuz/scripts/gina/handlers.py (+13/-6)
lib/lp/soyuz/scripts/gina/packages.py (+9/-6)
To merge this branch: bzr merge lp:~stevenk/launchpad/gina-populate-changelog
Reviewer Review Type Date Requested Status
Graham Binns (community) code Approve
Review via email: mp+41559@code.launchpad.net

Commit message

[r=gmb][ui=none][bug=680382] Gina now imports changelogs into the Librarian when processing new source packages.

Description of the change

This branch changes gina (the script that imports sources from Debian into LP) to also upload full changelogs to the librarian, and link the SourcePackageRelease to the changelog.

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) wrote :

> 8 +Check that the changelog was uploaded to the librarian correctly:
> 9 +
> 10 + >>> print x11p.changelog.content.sha1
> 11 + 759bd2df0d886f9f06c383048afb90eaa81418f6
> 12 +

This looks like either a) sampledata or b) a magic number to me. I can't
see where it came from, and grepping isn't turning anything up. Given
that the changelog is a LibraryFileAlias I'm guessing this is buried in
test data somewhere.

Can you change this so that the sha1 is something obviously
manufactured (e.g. 4242424242424242424242424242424242424242 or
similar)? At the very least, you need to add a comment explaining where
the data comes from in the first place.

review: Needs Fixing (code)
Revision history for this message
Graham Binns (gmb) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/soyuz/doc/gina.txt'
--- lib/lp/soyuz/doc/gina.txt 2010-11-11 11:55:53 +0000
+++ lib/lp/soyuz/doc/gina.txt 2010-11-23 10:58:17 +0000
@@ -215,6 +215,21 @@
215 >>> x11p.urgency == SourcePackageUrgency.LOW215 >>> x11p.urgency == SourcePackageUrgency.LOW
216 True216 True
217217
218Check that the changelog was uploaded to the librarian correctly:
219
220 >>> print x11p.changelog.read()
221 x11proto-damage (6.8.99.7-2) breezy; urgency=low
222 <BLANKLINE>
223 * Add dependency on x11proto-fixes-dev.
224 <BLANKLINE>
225 -- Daniel Stone <daniel.stone@ubuntu.com> Mon, 11 Jul 2005 19:11:11 +1000
226 <BLANKLINE>
227 x11proto-damage (6.8.99.7-1) breezy; urgency=low
228 <BLANKLINE>
229 * First x11proto-damage release.
230 <BLANKLINE>
231 -- Daniel Stone <daniel.stone@ubuntu.com> Mon, 16 May 2005 22:10:17 +1000
232
218Same for the copyright:233Same for the copyright:
219234
220 >>> print x11p.copyright235 >>> print x11p.copyright
221236
=== modified file 'lib/lp/soyuz/scripts/gina/handlers.py'
--- lib/lp/soyuz/scripts/gina/handlers.py 2010-09-02 16:28:50 +0000
+++ lib/lp/soyuz/scripts/gina/handlers.py 2010-11-23 10:58:17 +0000
@@ -17,6 +17,7 @@
17 'DistroHandler',17 'DistroHandler',
18 ]18 ]
1919
20from cStringIO import StringIO
20import os21import os
21import re22import re
2223
@@ -31,6 +32,7 @@
31 quote,32 quote,
32 sqlvalues,33 sqlvalues,
33 )34 )
35from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet
34from canonical.launchpad.scripts import log36from canonical.launchpad.scripts import log
35from lp.archivepublisher.diskpool import poolify37from lp.archivepublisher.diskpool import poolify
36from lp.archiveuploader.tagfiles import parse_tagfile38from lp.archiveuploader.tagfiles import parse_tagfile
@@ -624,11 +626,7 @@
624 to_upload = check_not_in_librarian(src.files, src.archive_root,626 to_upload = check_not_in_librarian(src.files, src.archive_root,
625 src.directory)627 src.directory)
626628
627 #629 # Create the SourcePackageRelease (SPR)
628 # DO IT! At this point, we've decided we have everything we need
629 # to create the SPR.
630 #
631
632 componentID = self.distro_handler.getComponentByName(src.component).id630 componentID = self.distro_handler.getComponentByName(src.component).id
633 sectionID = self.distro_handler.ensureSection(src.section).id631 sectionID = self.distro_handler.ensureSection(src.section).id
634 maintainer_line = "%s <%s>" % (displayname, emailaddress)632 maintainer_line = "%s <%s>" % (displayname, emailaddress)
@@ -645,7 +643,7 @@
645 dsc=src.dsc,643 dsc=src.dsc,
646 copyright=src.copyright,644 copyright=src.copyright,
647 version=src.version,645 version=src.version,
648 changelog_entry=src.changelog,646 changelog_entry=src.changelog_entry,
649 builddepends=src.build_depends,647 builddepends=src.build_depends,
650 builddependsindep=src.build_depends_indep,648 builddependsindep=src.build_depends_indep,
651 build_conflicts=src.build_conflicts,649 build_conflicts=src.build_conflicts,
@@ -661,6 +659,15 @@
661 log.info('Source Package Release %s (%s) created' %659 log.info('Source Package Release %s (%s) created' %
662 (name.name, src.version))660 (name.name, src.version))
663661
662 # Upload the changelog to the Librarian
663 if src.changelog is not None:
664 changelog_lfa = getUtility(ILibraryFileAliasSet).create(
665 "changelog",
666 len(src.changelog),
667 StringIO(src.changelog),
668 "text/x-debian-source-changelog")
669 spr.changelog = changelog_lfa
670
664 # Insert file into the library and create the671 # Insert file into the library and create the
665 # SourcePackageReleaseFile entry on lp db.672 # SourcePackageReleaseFile entry on lp db.
666 for fname, path in to_upload:673 for fname, path in to_upload:
667674
=== modified file 'lib/lp/soyuz/scripts/gina/packages.py'
--- lib/lp/soyuz/scripts/gina/packages.py 2010-10-19 11:53:02 +0000
+++ lib/lp/soyuz/scripts/gina/packages.py 2010-11-23 10:58:17 +0000
@@ -133,9 +133,7 @@
133 fullpath = os.path.join(source_dir, "debian", "changelog")133 fullpath = os.path.join(source_dir, "debian", "changelog")
134 changelog = None134 changelog = None
135 if os.path.exists(fullpath):135 if os.path.exists(fullpath):
136 clfile = open(fullpath)136 changelog = open(fullpath).read().strip()
137 changelog = parse_changelog(clfile)
138 clfile.close()
139 else:137 else:
140 log.warn("No changelog file found for %s in %s" %138 log.warn("No changelog file found for %s in %s" %
141 (package, source_dir))139 (package, source_dir))
@@ -401,11 +399,15 @@
401399
402 self.dsc = encoding.guess(dsc)400 self.dsc = encoding.guess(dsc)
403 self.copyright = encoding.guess(copyright)401 self.copyright = encoding.guess(copyright)
402 parsed_changelog = None
403 if changelog:
404 parsed_changelog = parse_changelog(changelog.split('\n'))
404405
405 self.urgency = None406 self.urgency = None
406 self.changelog = None407 self.changelog = None
407 if changelog and changelog[0]:408 self.changelog_entry = None
408 cldata = changelog[0]409 if parsed_changelog and parsed_changelog[0]:
410 cldata = parsed_changelog[0]
409 if 'changes' in cldata:411 if 'changes' in cldata:
410 if cldata["package"] != self.package:412 if cldata["package"] != self.package:
411 log.warn("Changelog package %s differs from %s" %413 log.warn("Changelog package %s differs from %s" %
@@ -413,7 +415,8 @@
413 if cldata["version"] != self.version:415 if cldata["version"] != self.version:
414 log.warn("Changelog version %s differs from %s" %416 log.warn("Changelog version %s differs from %s" %
415 (cldata["version"], self.version))417 (cldata["version"], self.version))
416 self.changelog = encoding.guess(cldata["changes"])418 self.changelog_entry = encoding.guess(cldata["changes"])
419 self.changelog = changelog
417 self.urgency = cldata["urgency"]420 self.urgency = cldata["urgency"]
418 else:421 else:
419 log.warn("Changelog empty for source %s (%s)" %422 log.warn("Changelog empty for source %s (%s)" %