Code review comment for lp:~michael.nelson/launchpad/436182-newlines-in-sources-fix-without-workaround

Michael Nelson (michael.nelson) wrote :

Just adding a incremental that fixes test breakages - ensuring that we
always format the changes before displaying it in emails (so it appears
exactly as it used to in emails - without the '\n .' blank line token or
initial spaces.

Julian has already reviewed the incremental and I've put it through ec2
test so it's ready for testing on dogfood.

--
Michael

1=== modified file 'lib/canonical/launchpad/emailtemplates/upload-accepted.txt'
2--- lib/canonical/launchpad/emailtemplates/upload-accepted.txt 2008-09-18 11:08:16 +0000
3+++ lib/canonical/launchpad/emailtemplates/upload-accepted.txt 2009-10-12 09:21:07 +0000
4@@ -1,4 +1,5 @@
5 %(CHANGESFILE)s
6+
7 %(DATE)s%(CHANGEDBY)s%(MAINTAINER)s%(SIGNER)s%(ORIGIN)s
8 %(SPR_URL)s
9
10
11=== modified file 'lib/canonical/launchpad/emailtemplates/upload-announcement.txt'
12--- lib/canonical/launchpad/emailtemplates/upload-announcement.txt 2008-09-18 11:08:16 +0000
13+++ lib/canonical/launchpad/emailtemplates/upload-announcement.txt 2009-10-12 09:27:30 +0000
14@@ -1,3 +1,4 @@
15 %(CHANGESFILE)s
16+
17 %(DATE)s%(CHANGEDBY)s%(MAINTAINER)s%(SIGNER)s%(ORIGIN)s
18 %(SPR_URL)s
19
20=== modified file 'lib/canonical/launchpad/emailtemplates/upload-new.txt'
21--- lib/canonical/launchpad/emailtemplates/upload-new.txt 2007-07-03 11:15:10 +0000
22+++ lib/canonical/launchpad/emailtemplates/upload-new.txt 2009-10-12 09:17:07 +0000
23@@ -2,6 +2,7 @@
24
25 %(CHANGESFILE)s
26
27+
28 Your package contains new components which requires manual editing of
29 the override file. It is ok otherwise, so please be patient. New
30 packages are usually added to the overrides about once a week.
31
32=== modified file 'lib/canonical/launchpad/emailtemplates/upload-rejection.txt'
33--- lib/canonical/launchpad/emailtemplates/upload-rejection.txt 2008-09-26 07:34:37 +0000
34+++ lib/canonical/launchpad/emailtemplates/upload-rejection.txt 2009-10-12 09:34:50 +0000
35@@ -2,6 +2,7 @@
36 %(SUMMARY)s
37
38 %(CHANGESFILE)s
39+
40 %(DATE)s%(CHANGEDBY)s%(MAINTAINER)s%(SIGNER)s%(ORIGIN)s
41
42 ===
43
44=== modified file 'lib/lp/archiveuploader/changesfile.py'
45--- lib/lp/archiveuploader/changesfile.py 2009-06-24 23:33:29 +0000
46+++ lib/lp/archiveuploader/changesfile.py 2009-10-12 08:33:56 +0000
47@@ -307,10 +307,24 @@
48 """Return changesfile claimed version."""
49 return self._dict['version']
50
51+ @classmethod
52+ def formatChangesComment(cls, comment):
53+ """A class utility method for formatting changes for display."""
54+
55+ # Return the display version of the comment using the
56+ # debian policy rules. First replacing the blank line
57+ # indicator '\n .' and then stripping one space from each
58+ # successive line.
59+ comment = comment.replace('\n .', '\n')
60+ comment = comment.replace('\n ', '\n')
61+ return comment
62+
63 @property
64 def changes_comment(self):
65 """Return changesfile 'change' comment."""
66- return self._dict['changes']
67+ comment = self._dict['changes']
68+
69+ return self.formatChangesComment(comment)
70
71 @property
72 def date(self):
73
74=== modified file 'lib/lp/soyuz/model/queue.py'
75--- lib/lp/soyuz/model/queue.py 2009-10-01 07:05:22 +0000
76+++ lib/lp/soyuz/model/queue.py 2009-10-12 07:53:03 +0000
77@@ -33,6 +33,7 @@
78 from lp.archivepublisher.config import getPubConfig
79 from lp.archivepublisher.customupload import CustomUploadError
80 from lp.archivepublisher.utils import get_ppa_reference
81+from lp.archiveuploader.changesfile import ChangesFile
82 from lp.archiveuploader.tagfiles import parse_tagfile_lines
83 from lp.archiveuploader.utils import safe_fix_maintainer
84 from lp.buildmaster.pas import BuildDaemonPackagesArchSpecific
85@@ -737,14 +738,16 @@
86 """PPA rejected message."""
87 template = get_email_template('ppa-upload-rejection.txt')
88 SUMMARY = sanitize_string(summary_text)
89- CHANGESFILE = sanitize_string("".join(changes_lines))
90+ CHANGESFILE = sanitize_string(
91+ ChangesFile.formatChangesComment("".join(changes_lines)))
92 USERS_ADDRESS = config.launchpad.users_address
93
94 class RejectedMessage:
95 """Rejected message."""
96 template = get_email_template('upload-rejection.txt')
97 SUMMARY = sanitize_string(summary_text)
98- CHANGESFILE = sanitize_string(changes['changes'])
99+ CHANGESFILE = sanitize_string(
100+ ChangesFile.formatChangesComment(changes['changes']))
101 CHANGEDBY = ''
102 ORIGIN = ''
103 SIGNER = ''
104@@ -821,7 +824,8 @@
105
106 STATUS = "New"
107 SUMMARY = summarystring
108- CHANGESFILE = sanitize_string(changes['changes'])
109+ CHANGESFILE = sanitize_string(
110+ ChangesFile.formatChangesComment(changes['changes']))
111 DISTRO = self.distroseries.distribution.title
112 if announce_list:
113 ANNOUNCE = 'Announcing to %s' % announce_list
114@@ -835,7 +839,8 @@
115 STATUS = "Waiting for approval"
116 SUMMARY = summarystring + (
117 "\nThis upload awaits approval by a distro manager\n")
118- CHANGESFILE = sanitize_string(changes['changes'])
119+ CHANGESFILE = sanitize_string(
120+ ChangesFile.formatChangesComment(changes['changes']))
121 DISTRO = self.distroseries.distribution.title
122 if announce_list:
123 ANNOUNCE = 'Announcing to %s' % announce_list
124@@ -853,7 +858,8 @@
125
126 STATUS = "Accepted"
127 SUMMARY = summarystring
128- CHANGESFILE = sanitize_string(changes['changes'])
129+ CHANGESFILE = sanitize_string(
130+ ChangesFile.formatChangesComment(changes['changes']))
131 DISTRO = self.distroseries.distribution.title
132 if announce_list:
133 ANNOUNCE = 'Announcing to %s' % announce_list
134@@ -871,14 +877,16 @@
135
136 STATUS = "Accepted"
137 SUMMARY = summarystring
138- CHANGESFILE = guess_encoding("".join(changes_lines))
139+ CHANGESFILE = guess_encoding(
140+ ChangesFile.formatChangesComment("".join(changes_lines)))
141
142 class AnnouncementMessage:
143 template = get_email_template('upload-announcement.txt')
144
145 STATUS = "Accepted"
146 SUMMARY = summarystring
147- CHANGESFILE = sanitize_string(changes['changes'])
148+ CHANGESFILE = sanitize_string(
149+ ChangesFile.formatChangesComment(changes['changes']))
150 CHANGEDBY = ''
151 ORIGIN = ''
152 SIGNER = ''

« Back to merge proposal