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
1=== modified file 'lib/lp/soyuz/doc/gina.txt'
2--- lib/lp/soyuz/doc/gina.txt 2010-11-11 11:55:53 +0000
3+++ lib/lp/soyuz/doc/gina.txt 2010-11-23 10:58:17 +0000
4@@ -215,6 +215,21 @@
5 >>> x11p.urgency == SourcePackageUrgency.LOW
6 True
7
8+Check that the changelog was uploaded to the librarian correctly:
9+
10+ >>> print x11p.changelog.read()
11+ x11proto-damage (6.8.99.7-2) breezy; urgency=low
12+ <BLANKLINE>
13+ * Add dependency on x11proto-fixes-dev.
14+ <BLANKLINE>
15+ -- Daniel Stone <daniel.stone@ubuntu.com> Mon, 11 Jul 2005 19:11:11 +1000
16+ <BLANKLINE>
17+ x11proto-damage (6.8.99.7-1) breezy; urgency=low
18+ <BLANKLINE>
19+ * First x11proto-damage release.
20+ <BLANKLINE>
21+ -- Daniel Stone <daniel.stone@ubuntu.com> Mon, 16 May 2005 22:10:17 +1000
22+
23 Same for the copyright:
24
25 >>> print x11p.copyright
26
27=== modified file 'lib/lp/soyuz/scripts/gina/handlers.py'
28--- lib/lp/soyuz/scripts/gina/handlers.py 2010-09-02 16:28:50 +0000
29+++ lib/lp/soyuz/scripts/gina/handlers.py 2010-11-23 10:58:17 +0000
30@@ -17,6 +17,7 @@
31 'DistroHandler',
32 ]
33
34+from cStringIO import StringIO
35 import os
36 import re
37
38@@ -31,6 +32,7 @@
39 quote,
40 sqlvalues,
41 )
42+from canonical.launchpad.interfaces.librarian import ILibraryFileAliasSet
43 from canonical.launchpad.scripts import log
44 from lp.archivepublisher.diskpool import poolify
45 from lp.archiveuploader.tagfiles import parse_tagfile
46@@ -624,11 +626,7 @@
47 to_upload = check_not_in_librarian(src.files, src.archive_root,
48 src.directory)
49
50- #
51- # DO IT! At this point, we've decided we have everything we need
52- # to create the SPR.
53- #
54-
55+ # Create the SourcePackageRelease (SPR)
56 componentID = self.distro_handler.getComponentByName(src.component).id
57 sectionID = self.distro_handler.ensureSection(src.section).id
58 maintainer_line = "%s <%s>" % (displayname, emailaddress)
59@@ -645,7 +643,7 @@
60 dsc=src.dsc,
61 copyright=src.copyright,
62 version=src.version,
63- changelog_entry=src.changelog,
64+ changelog_entry=src.changelog_entry,
65 builddepends=src.build_depends,
66 builddependsindep=src.build_depends_indep,
67 build_conflicts=src.build_conflicts,
68@@ -661,6 +659,15 @@
69 log.info('Source Package Release %s (%s) created' %
70 (name.name, src.version))
71
72+ # Upload the changelog to the Librarian
73+ if src.changelog is not None:
74+ changelog_lfa = getUtility(ILibraryFileAliasSet).create(
75+ "changelog",
76+ len(src.changelog),
77+ StringIO(src.changelog),
78+ "text/x-debian-source-changelog")
79+ spr.changelog = changelog_lfa
80+
81 # Insert file into the library and create the
82 # SourcePackageReleaseFile entry on lp db.
83 for fname, path in to_upload:
84
85=== modified file 'lib/lp/soyuz/scripts/gina/packages.py'
86--- lib/lp/soyuz/scripts/gina/packages.py 2010-10-19 11:53:02 +0000
87+++ lib/lp/soyuz/scripts/gina/packages.py 2010-11-23 10:58:17 +0000
88@@ -133,9 +133,7 @@
89 fullpath = os.path.join(source_dir, "debian", "changelog")
90 changelog = None
91 if os.path.exists(fullpath):
92- clfile = open(fullpath)
93- changelog = parse_changelog(clfile)
94- clfile.close()
95+ changelog = open(fullpath).read().strip()
96 else:
97 log.warn("No changelog file found for %s in %s" %
98 (package, source_dir))
99@@ -401,11 +399,15 @@
100
101 self.dsc = encoding.guess(dsc)
102 self.copyright = encoding.guess(copyright)
103+ parsed_changelog = None
104+ if changelog:
105+ parsed_changelog = parse_changelog(changelog.split('\n'))
106
107 self.urgency = None
108 self.changelog = None
109- if changelog and changelog[0]:
110- cldata = changelog[0]
111+ self.changelog_entry = None
112+ if parsed_changelog and parsed_changelog[0]:
113+ cldata = parsed_changelog[0]
114 if 'changes' in cldata:
115 if cldata["package"] != self.package:
116 log.warn("Changelog package %s differs from %s" %
117@@ -413,7 +415,8 @@
118 if cldata["version"] != self.version:
119 log.warn("Changelog version %s differs from %s" %
120 (cldata["version"], self.version))
121- self.changelog = encoding.guess(cldata["changes"])
122+ self.changelog_entry = encoding.guess(cldata["changes"])
123+ self.changelog = changelog
124 self.urgency = cldata["urgency"]
125 else:
126 log.warn("Changelog empty for source %s (%s)" %