Merge lp:~cjwatson/launchpad/bugzilla-comment-creator-field into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18684
Proposed branch: lp:~cjwatson/launchpad/bugzilla-comment-creator-field
Merge into: lp:launchpad
Diff against target: 217 lines (+50/-19)
6 files modified
lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt (+12/-5)
lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt (+4/-4)
lib/lp/bugs/externalbugtracker/bugzilla.py (+6/-1)
lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt (+15/-5)
lib/lp/bugs/tests/bugzilla-xmlrpc-transport.txt (+3/-3)
lib/lp/bugs/tests/externalbugtracker.py (+10/-1)
To merge this branch: bzr merge lp:~cjwatson/launchpad/bugzilla-comment-creator-field
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+347442@code.launchpad.net

Commit message

Cope with the comment 'author' field being renamed to 'creator' in recent Bugzilla versions.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
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/bugs/doc/externalbugtracker-bugzilla-api.txt'
2--- lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2018-06-03 08:25:27 +0000
3+++ lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2018-06-05 12:47:45 +0000
4@@ -541,7 +541,7 @@
5 >>> remote_bug = bug_watch_two.remotebug
6 >>> transaction.commit()
7
8- >>> bugzilla.fetchComments(remote_bug, ['2', '4', '5'])
9+ >>> bugzilla.fetchComments(remote_bug, ['2', '4', '5', '6'])
10 >>> displayname, email = bugzilla.getPosterForComment(remote_bug, '4')
11 >>> print displayname, email
12 Ford Prefect ford.prefect@h2g2.com
13@@ -564,6 +564,13 @@
14 >>> print displayname, email
15 trillian None
16
17+Bugzilla 4.0 renamed the 'author' field to 'creator', but kept the old field
18+for compatibility. Bugzilla 5.0 dropped the compatibility field.
19+
20+ >>> displayname, email = bugzilla.getPosterForComment(remote_bug, '6')
21+ >>> print displayname, email
22+ Slartibartfast slarti@magrathea.example.net
23+
24
25 getMessageForComment()
26 ----------------------
27@@ -634,20 +641,20 @@
28 'id': 1})
29
30 >>> comment_id
31- '6'
32+ '7'
33
34 The comment will be stored on the remote server with the other comments.
35
36 >>> bugzilla.xmlrpc_transport.print_method_calls = False
37 >>> print sorted(bugzilla.getCommentIds(bug_watch.remotebug))
38- ['1', '3', '6']
39+ ['1', '3', '7']
40
41 >>> remote_bug = bug_watch.remotebug
42 >>> transaction.commit()
43
44- >>> bugzilla.fetchComments(remote_bug, ['6'])
45+ >>> bugzilla.fetchComments(remote_bug, ['7'])
46 >>> message = bugzilla.getMessageForComment(
47- ... bug_watch.remotebug, '6', sample_person)
48+ ... bug_watch.remotebug, '7', sample_person)
49 >>> print message.text_contents
50 This is a new remote comment.
51 <BLANKLINE>
52
53=== modified file 'lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt'
54--- lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt 2017-10-20 11:07:01 +0000
55+++ lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt 2018-06-05 12:47:45 +0000
56@@ -460,7 +460,7 @@
57 'id': 1})
58
59 >>> comment_id
60- '6'
61+ '7'
62
63 The comment will be stored on the remote server with the other comments.
64
65@@ -469,13 +469,13 @@
66
67 >>> bugzilla.xmlrpc_transport.print_method_calls = False
68 >>> print sorted(bugzilla.getCommentIds(remote_bug))
69- ['1', '3', '6']
70+ ['1', '3', '7']
71
72 >>> transaction.commit()
73
74- >>> bugzilla.fetchComments(remote_bug, ['6'])
75+ >>> bugzilla.fetchComments(remote_bug, ['7'])
76 >>> message = bugzilla.getMessageForComment(
77- ... remote_bug, '6', sample_person)
78+ ... remote_bug, '7', sample_person)
79 >>> print message.text_contents
80 This is a new remote comment.
81 <BLANKLINE>
82
83=== modified file 'lib/lp/bugs/externalbugtracker/bugzilla.py'
84--- lib/lp/bugs/externalbugtracker/bugzilla.py 2018-06-03 08:25:27 +0000
85+++ lib/lp/bugs/externalbugtracker/bugzilla.py 2018-06-05 12:47:45 +0000
86@@ -858,7 +858,12 @@
87 comment_id = int(comment_id)
88
89 comment = self._bugs[actual_bug_id]['comments'][comment_id]
90- display_name, email = parseaddr(comment['author'])
91+ if 'creator' in comment:
92+ # Bugzilla >= 4.0
93+ creator = comment['creator']
94+ else:
95+ creator = comment['author']
96+ display_name, email = parseaddr(creator)
97
98 # If the email isn't valid, return the email address as the
99 # display name (a Launchpad Person will be created with this
100
101=== modified file 'lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt'
102--- lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt 2017-10-20 11:07:01 +0000
103+++ lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt 2018-06-05 12:47:45 +0000
104@@ -353,6 +353,13 @@
105 text: I never could get the hang of Thursdays.
106 time: 2008-06-19 09:30:00
107 <BLANKLINE>
108+ bug_id: 2
109+ creator: Slartibartfast <slarti@magrathea.example.net>
110+ id: 6
111+ is_private: False
112+ text: You know the fjords in Norway? I got a prize for creating those, you know.
113+ time: 2008-06-20 12:37:00
114+ <BLANKLINE>
115 <BLANKLINE>
116
117 Passing a list of comment IDs to Bug.comments will cause it to return
118@@ -393,7 +400,7 @@
119 returned for each comment.
120
121 >>> return_dict = server.Bug.comments(
122- ... {'ids': [1, 2], 'include_fields': ('id', 'author')})
123+ ... {'ids': [1, 2], 'include_fields': ('id', 'author', 'creator')})
124 >>> bugs_dict = return_dict['bugs']
125
126 >>> print_bug_comments(bugs_dict, sort_key='id')
127@@ -414,6 +421,9 @@
128 <BLANKLINE>
129 author: arthur.dent@earth.example.com
130 id: 5
131+ <BLANKLINE>
132+ creator: Slartibartfast <slarti@magrathea.example.net>
133+ id: 6
134
135 >>> return_dict = server.Bug.comments(
136 ... {'comment_ids': [1, 4], 'include_fields': ('id', 'author')})
137@@ -455,12 +465,12 @@
138 >>> bugzilla_transport.auth_cookie = 'open sesame'
139 >>> return_dict = server.Bug.add_comment({'id': 1, 'comment': comment})
140 >>> return_dict
141- {'id': 6}
142+ {'id': 7}
143
144 The comment will be stored with the other comments on the remote server.
145
146 >>> return_dict = server.Bug.comments({
147- ... 'id': [1], 'comment_ids': [6]})
148+ ... 'id': [1], 'comment_ids': [7]})
149 >>> comments_dict = return_dict['comments']
150
151 >>> for comment_id, comment in comments_dict.items():
152@@ -468,10 +478,10 @@
153 ... for comment_key in sorted(comment):
154 ... print " %s: %s" % (
155 ... comment_key, comment[comment_key])
156- Comment 6:
157+ Comment 7:
158 author: launchpad
159 bug_id: 1
160- id: 6
161+ id: 7
162 is_private: False
163 text: I'm supposed to write something apposite here.
164 time: ...
165
166=== modified file 'lib/lp/bugs/tests/bugzilla-xmlrpc-transport.txt'
167--- lib/lp/bugs/tests/bugzilla-xmlrpc-transport.txt 2017-10-20 11:07:01 +0000
168+++ lib/lp/bugs/tests/bugzilla-xmlrpc-transport.txt 2018-06-05 12:47:45 +0000
169@@ -451,17 +451,17 @@
170 >>> return_dict = server.Launchpad.add_comment(
171 ... {'id': 1, 'comment': comment})
172 >>> print return_dict['comment_id']
173- 6
174+ 7
175
176 The comment will be stored with the other comments on the remote server.
177
178- >>> return_dict = server.Launchpad.comments({'bug_ids': [1], 'ids': [6]})
179+ >>> return_dict = server.Launchpad.comments({'bug_ids': [1], 'ids': [7]})
180 >>> bugs_dict = return_dict['bugs']
181
182 >>> print_bug_comments(bugs_dict, sort_key='id')
183 Bug 1:
184 author: launchpad
185- id: 6
186+ id: 7
187 number: 3
188 text: Didn't we have a lovely time the day we went to Bangor?
189 time: ...
190
191=== modified file 'lib/lp/bugs/tests/externalbugtracker.py'
192--- lib/lp/bugs/tests/externalbugtracker.py 2018-06-03 08:25:27 +0000
193+++ lib/lp/bugs/tests/externalbugtracker.py 2018-06-05 12:47:45 +0000
194@@ -450,7 +450,7 @@
195 }
196
197 # Comments are mapped to bug IDs.
198- comment_id_index = 5
199+ comment_id_index = 6
200 new_comment_time = datetime(2008, 6, 20, 11, 42, 42)
201 _bug_comments = {
202 1: {
203@@ -868,6 +868,15 @@
204 'text': "I never could get the hang of Thursdays.",
205 'time': datetime(2008, 6, 19, 9, 30, 0),
206 },
207+ 4: {'creator': 'Slartibartfast <slarti@magrathea.example.net>',
208+ 'bug_id': 2,
209+ 'id': 6,
210+ 'is_private': False,
211+ 'text': (
212+ "You know the fjords in Norway? I got a prize for "
213+ "creating those, you know."),
214+ 'time': datetime(2008, 6, 20, 12, 37, 0),
215+ },
216 },
217 }
218