Merge lp:~wgrant/launchpad/bugzilla-alias-list into lp:launchpad

Proposed by William Grant
Status: Merged
Merged at revision: 18303
Proposed branch: lp:~wgrant/launchpad/bugzilla-alias-list
Merge into: lp:launchpad
Diff against target: 162 lines (+67/-8)
5 files modified
lib/lp/bugs/browser/bugtracker.py (+1/-3)
lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt (+25/-3)
lib/lp/bugs/externalbugtracker/bugzilla.py (+8/-2)
lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt (+15/-0)
lib/lp/bugs/tests/externalbugtracker.py (+18/-0)
To merge this branch: bzr merge lp:~wgrant/launchpad/bugzilla-alias-list
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+314265@code.launchpad.net

Commit message

Fix Bugzilla bug watches to support new versions that permit multiple aliases.

Description of the change

Fix Bugzilla bug watches to support new versions that permit multiple aliases.

eg. OOPS-ff5db6643741d0fe0357f384beb3bef0

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/browser/bugtracker.py'
2--- lib/lp/bugs/browser/bugtracker.py 2016-09-09 16:37:01 +0000
3+++ lib/lp/bugs/browser/bugtracker.py 2017-01-14 07:42:28 +0000
4@@ -264,9 +264,7 @@
5 'contactdetails',
6 ]
7
8- # Members of the admin team can set the bug tracker's active
9- # state.
10- if check_permission("launchpad.Admin", self.user):
11+ if check_permission("launchpad.Admin", self.context):
12 field_names.append('active')
13
14 return field_names
15
16=== modified file 'lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt'
17--- lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2016-09-21 02:49:42 +0000
18+++ lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2017-01-14 07:42:28 +0000
19@@ -191,8 +191,8 @@
20
21 >>> bugzilla._bugs = {}
22 >>> bugzilla._bug_aliases = {}
23- >>> bugzilla.initializeRemoteBugDB([2, 'bug-two'])
24- CALLED Bug.get({'ids': [2, 'bug-two'], 'permissive': True})
25+ >>> bugzilla.initializeRemoteBugDB([2, 'bug-two', 3])
26+ CALLED Bug.get({'ids': [2, 'bug-two', 3], 'permissive': True})
27
28 >>> print_bugs(bugzilla._bugs)
29 Bug 2:
30@@ -211,14 +211,32 @@
31 severity: high
32 status: NEW
33 summary: Collect unknown persons in docking bay 2.
34+ Bug 3:
35+ alias: ['bug-three', 'bad-diodes']
36+ assigned_to: marvin@heartofgold.ship
37+ component: Crew
38+ creation_time: 2008-06-10 09:23:12
39+ id: 3
40+ internals:...
41+ is_open: True
42+ last_change_time: 2008-06-10 09:24:29
43+ priority: P1
44+ product: Marvin
45+ resolution:
46+ see_also: []
47+ severity: high
48+ status: NEW
49+ summary: Pain in all the diodes down my left hand side.
50 <BLANKLINE>
51 <BLANKLINE>
52
53 Aliases are stored in a separate dict, which contains a mapping between
54 the alias and the bug's actual ID.
55
56- >>> for alias, bug_id in bugzilla._bug_aliases.items():
57+ >>> for alias, bug_id in sorted(bugzilla._bug_aliases.items()):
58 ... print "%s: %s" % (alias, bug_id)
59+ bad-diodes: 3
60+ bug-three: 3
61 bug-two: 2
62
63 The method _getActualBugId() returns the correct bug ID for a passed bug
64@@ -230,6 +248,10 @@
65 >>> bugzilla._getActualBugId(2)
66 2
67
68+ >>> bugzilla._getActualBugId('bad-diodes')
69+ 3
70+
71+
72 Sometimes a Bugzilla will return bug data without an alias field.
73 _storeBugs() handles that, too.
74
75
76=== modified file 'lib/lp/bugs/externalbugtracker/bugzilla.py'
77--- lib/lp/bugs/externalbugtracker/bugzilla.py 2015-07-08 16:05:11 +0000
78+++ lib/lp/bugs/externalbugtracker/bugzilla.py 2017-01-14 07:42:28 +0000
79@@ -21,6 +21,7 @@
80 import xmlrpclib
81
82 import pytz
83+import six
84 from zope.component import getUtility
85 from zope.interface import implementer
86
87@@ -620,8 +621,13 @@
88 # IDs. We use the aliases dict to look up the correct ID for
89 # a bug. This allows us to reference a bug by either ID or
90 # alias.
91- if remote_bug.get('alias', '') != '':
92- self._bug_aliases[remote_bug['alias']] = remote_bug['id']
93+ # Some versions of Bugzilla return a single alias string,
94+ # others return a (possibly empty) list.
95+ aliases = remote_bug.get('alias', '')
96+ if isinstance(aliases, six.string_types):
97+ aliases = [] if not aliases else [aliases]
98+ for alias in aliases:
99+ self._bug_aliases[alias] = remote_bug['id']
100
101 @ensure_no_transaction
102 def getCurrentDBTime(self):
103
104=== modified file 'lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt'
105--- lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt 2016-09-21 02:49:42 +0000
106+++ lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt 2017-01-14 07:42:28 +0000
107@@ -269,6 +269,21 @@
108 severity: high
109 status: NEW
110 summary: Collect unknown persons in docking bay 2.
111+ alias: ['bug-three', 'bad-diodes']
112+ assigned_to: marvin@heartofgold.ship
113+ component: Crew
114+ creation_time: 2008-06-10 09:23:12
115+ id: 3
116+ internals:...
117+ is_open: True
118+ last_change_time: 2008-06-10 09:24:29
119+ priority: P1
120+ product: Marvin
121+ resolution:
122+ see_also: []
123+ severity: high
124+ status: NEW
125+ summary: Pain in all the diodes down my left hand side.
126
127
128 Getting the comments for a bug
129
130=== modified file 'lib/lp/bugs/tests/externalbugtracker.py'
131--- lib/lp/bugs/tests/externalbugtracker.py 2013-05-09 08:53:01 +0000
132+++ lib/lp/bugs/tests/externalbugtracker.py 2017-01-14 07:42:28 +0000
133@@ -424,11 +424,29 @@
134 'status': 'NEW',
135 'summary': 'Collect unknown persons in docking bay 2.',
136 },
137+ 3: {'alias': ['bug-three', 'bad-diodes'],
138+ 'assigned_to': 'marvin@heartofgold.ship',
139+ 'component': 'Crew',
140+ 'creation_time': datetime(2008, 6, 10, 9, 23, 12),
141+ 'id': 3,
142+ 'internals': {},
143+ 'is_open': True,
144+ 'last_change_time': datetime(2008, 6, 10, 9, 24, 29),
145+ 'priority': 'P1',
146+ 'product': 'Marvin',
147+ 'resolution': '',
148+ 'see_also': [],
149+ 'severity': 'high',
150+ 'status': 'NEW',
151+ 'summary': "Pain in all the diodes down my left hand side.",
152+ },
153 }
154
155 # Map aliases onto bugs.
156 _bug_aliases = {
157 'bug-two': 2,
158+ 'bug-three': 3,
159+ 'bad-diodes': 3,
160 }
161
162 # Comments are mapped to bug IDs.