launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #22614
[Merge] lp:~cjwatson/launchpad/bugzilla-comment-creator-field into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/bugzilla-comment-creator-field into lp:launchpad.
Commit message:
Cope with the comment 'author' field being renamed to 'creator' in recent Bugzilla versions.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1774838 in Launchpad itself: "Launchpad issue watching bugs from the Linux Kernel Bug Tracker"
https://bugs.launchpad.net/launchpad/+bug/1774838
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/bugzilla-comment-creator-field/+merge/347442
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/bugzilla-comment-creator-field into lp:launchpad.
=== modified file 'lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt'
--- lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2018-06-03 08:25:27 +0000
+++ lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2018-06-05 12:47:45 +0000
@@ -541,7 +541,7 @@
>>> remote_bug = bug_watch_two.remotebug
>>> transaction.commit()
- >>> bugzilla.fetchComments(remote_bug, ['2', '4', '5'])
+ >>> bugzilla.fetchComments(remote_bug, ['2', '4', '5', '6'])
>>> displayname, email = bugzilla.getPosterForComment(remote_bug, '4')
>>> print displayname, email
Ford Prefect ford.prefect@xxxxxxxx
@@ -564,6 +564,13 @@
>>> print displayname, email
trillian None
+Bugzilla 4.0 renamed the 'author' field to 'creator', but kept the old field
+for compatibility. Bugzilla 5.0 dropped the compatibility field.
+
+ >>> displayname, email = bugzilla.getPosterForComment(remote_bug, '6')
+ >>> print displayname, email
+ Slartibartfast slarti@xxxxxxxxxxxxxxxxxxxxx
+
getMessageForComment()
----------------------
@@ -634,20 +641,20 @@
'id': 1})
>>> comment_id
- '6'
+ '7'
The comment will be stored on the remote server with the other comments.
>>> bugzilla.xmlrpc_transport.print_method_calls = False
>>> print sorted(bugzilla.getCommentIds(bug_watch.remotebug))
- ['1', '3', '6']
+ ['1', '3', '7']
>>> remote_bug = bug_watch.remotebug
>>> transaction.commit()
- >>> bugzilla.fetchComments(remote_bug, ['6'])
+ >>> bugzilla.fetchComments(remote_bug, ['7'])
>>> message = bugzilla.getMessageForComment(
- ... bug_watch.remotebug, '6', sample_person)
+ ... bug_watch.remotebug, '7', sample_person)
>>> print message.text_contents
This is a new remote comment.
<BLANKLINE>
=== modified file 'lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt'
--- lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt 2017-10-20 11:07:01 +0000
+++ lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt 2018-06-05 12:47:45 +0000
@@ -460,7 +460,7 @@
'id': 1})
>>> comment_id
- '6'
+ '7'
The comment will be stored on the remote server with the other comments.
@@ -469,13 +469,13 @@
>>> bugzilla.xmlrpc_transport.print_method_calls = False
>>> print sorted(bugzilla.getCommentIds(remote_bug))
- ['1', '3', '6']
+ ['1', '3', '7']
>>> transaction.commit()
- >>> bugzilla.fetchComments(remote_bug, ['6'])
+ >>> bugzilla.fetchComments(remote_bug, ['7'])
>>> message = bugzilla.getMessageForComment(
- ... remote_bug, '6', sample_person)
+ ... remote_bug, '7', sample_person)
>>> print message.text_contents
This is a new remote comment.
<BLANKLINE>
=== modified file 'lib/lp/bugs/externalbugtracker/bugzilla.py'
--- lib/lp/bugs/externalbugtracker/bugzilla.py 2018-06-03 08:25:27 +0000
+++ lib/lp/bugs/externalbugtracker/bugzilla.py 2018-06-05 12:47:45 +0000
@@ -858,7 +858,12 @@
comment_id = int(comment_id)
comment = self._bugs[actual_bug_id]['comments'][comment_id]
- display_name, email = parseaddr(comment['author'])
+ if 'creator' in comment:
+ # Bugzilla >= 4.0
+ creator = comment['creator']
+ else:
+ creator = comment['author']
+ display_name, email = parseaddr(creator)
# If the email isn't valid, return the email address as the
# display name (a Launchpad Person will be created with this
=== modified file 'lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt'
--- lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt 2017-10-20 11:07:01 +0000
+++ lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt 2018-06-05 12:47:45 +0000
@@ -353,6 +353,13 @@
text: I never could get the hang of Thursdays.
time: 2008-06-19 09:30:00
<BLANKLINE>
+ bug_id: 2
+ creator: Slartibartfast <slarti@xxxxxxxxxxxxxxxxxxxxx>
+ id: 6
+ is_private: False
+ text: You know the fjords in Norway? I got a prize for creating those, you know.
+ time: 2008-06-20 12:37:00
+ <BLANKLINE>
<BLANKLINE>
Passing a list of comment IDs to Bug.comments will cause it to return
@@ -393,7 +400,7 @@
returned for each comment.
>>> return_dict = server.Bug.comments(
- ... {'ids': [1, 2], 'include_fields': ('id', 'author')})
+ ... {'ids': [1, 2], 'include_fields': ('id', 'author', 'creator')})
>>> bugs_dict = return_dict['bugs']
>>> print_bug_comments(bugs_dict, sort_key='id')
@@ -414,6 +421,9 @@
<BLANKLINE>
author: arthur.dent@xxxxxxxxxxxxxxxxx
id: 5
+ <BLANKLINE>
+ creator: Slartibartfast <slarti@xxxxxxxxxxxxxxxxxxxxx>
+ id: 6
>>> return_dict = server.Bug.comments(
... {'comment_ids': [1, 4], 'include_fields': ('id', 'author')})
@@ -455,12 +465,12 @@
>>> bugzilla_transport.auth_cookie = 'open sesame'
>>> return_dict = server.Bug.add_comment({'id': 1, 'comment': comment})
>>> return_dict
- {'id': 6}
+ {'id': 7}
The comment will be stored with the other comments on the remote server.
>>> return_dict = server.Bug.comments({
- ... 'id': [1], 'comment_ids': [6]})
+ ... 'id': [1], 'comment_ids': [7]})
>>> comments_dict = return_dict['comments']
>>> for comment_id, comment in comments_dict.items():
@@ -468,10 +478,10 @@
... for comment_key in sorted(comment):
... print " %s: %s" % (
... comment_key, comment[comment_key])
- Comment 6:
+ Comment 7:
author: launchpad
bug_id: 1
- id: 6
+ id: 7
is_private: False
text: I'm supposed to write something apposite here.
time: ...
=== modified file 'lib/lp/bugs/tests/bugzilla-xmlrpc-transport.txt'
--- lib/lp/bugs/tests/bugzilla-xmlrpc-transport.txt 2017-10-20 11:07:01 +0000
+++ lib/lp/bugs/tests/bugzilla-xmlrpc-transport.txt 2018-06-05 12:47:45 +0000
@@ -451,17 +451,17 @@
>>> return_dict = server.Launchpad.add_comment(
... {'id': 1, 'comment': comment})
>>> print return_dict['comment_id']
- 6
+ 7
The comment will be stored with the other comments on the remote server.
- >>> return_dict = server.Launchpad.comments({'bug_ids': [1], 'ids': [6]})
+ >>> return_dict = server.Launchpad.comments({'bug_ids': [1], 'ids': [7]})
>>> bugs_dict = return_dict['bugs']
>>> print_bug_comments(bugs_dict, sort_key='id')
Bug 1:
author: launchpad
- id: 6
+ id: 7
number: 3
text: Didn't we have a lovely time the day we went to Bangor?
time: ...
=== modified file 'lib/lp/bugs/tests/externalbugtracker.py'
--- lib/lp/bugs/tests/externalbugtracker.py 2018-06-03 08:25:27 +0000
+++ lib/lp/bugs/tests/externalbugtracker.py 2018-06-05 12:47:45 +0000
@@ -450,7 +450,7 @@
}
# Comments are mapped to bug IDs.
- comment_id_index = 5
+ comment_id_index = 6
new_comment_time = datetime(2008, 6, 20, 11, 42, 42)
_bug_comments = {
1: {
@@ -868,6 +868,15 @@
'text': "I never could get the hang of Thursdays.",
'time': datetime(2008, 6, 19, 9, 30, 0),
},
+ 4: {'creator': 'Slartibartfast <slarti@xxxxxxxxxxxxxxxxxxxxx>',
+ 'bug_id': 2,
+ 'id': 6,
+ 'is_private': False,
+ 'text': (
+ "You know the fjords in Norway? I got a prize for "
+ "creating those, you know."),
+ 'time': datetime(2008, 6, 20, 12, 37, 0),
+ },
},
}
Follow ups