Merge lp:~allenap/launchpad/external-bugzilla-3.4-api-bug-434580 into lp:launchpad

Proposed by Gavin Panella
Status: Merged
Approved by: Brad Crittenden
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~allenap/launchpad/external-bugzilla-3.4-api-bug-434580
Merge into: lp:launchpad
Diff against target: None lines
To merge this branch: bzr merge lp:~allenap/launchpad/external-bugzilla-3.4-api-bug-434580
Reviewer Review Type Date Requested Status
Brad Crittenden (community) release-critical Approve
Graham Binns (community) code Approve
Review via email: mp+12230@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

Please see the bug for a description of the changes; gmb's done a good job of describing what's going on.

Lint free.

bin/test -vvt 'bug-?tracker'

Revision history for this message
Graham Binns (gmb) :
review: Approve (code)
Revision history for this message
Brad Crittenden (bac) :
review: Approve (release-critical)

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.txt'
2--- lib/lp/bugs/doc/externalbugtracker.txt 2009-08-21 18:00:25 +0000
3+++ lib/lp/bugs/doc/externalbugtracker.txt 2009-09-22 15:22:53 +0000
4@@ -225,7 +225,7 @@
5 watches against that product will be returned as a batch from
6 _getExternalBugTrackersAndWatches() along with a BugzillaAPI
7 instance. All the other bug watches will be returned as a batch with
8-Bugzilla instance.
9+another BugzillaAPI instance which has syncing disabled.
10
11 >>> trackers_and_watches = get_trackers_and_watches(
12 ... gnome_bugzilla, bug_watches)
13@@ -234,31 +234,32 @@
14 >>> len(trackers_and_watches)
15 2
16
17- >>> bugzilla_api, api_watches = trackers_and_watches[0]
18- >>> isinstance(bugzilla_api, BugzillaAPI)
19+ >>> bugzilla_for_sync, sync_watches = trackers_and_watches[0]
20+ >>> isinstance(bugzilla_for_sync, BugzillaAPI)
21+ True
22+ >>> bugzilla_for_sync.sync_comments
23 True
24
25 >>> from operator import attrgetter
26- >>> for watch in sorted(api_watches, key=attrgetter('remotebug')):
27+ >>> for watch in sorted(sync_watches, key=attrgetter('remotebug')):
28 ... print watch.remotebug
29 1
30 3
31
32- >>> normal_bugzilla, normal_watches = trackers_and_watches[1]
33- >>> isinstance(normal_bugzilla, Bugzilla)
34+ >>> bugzilla_other, other_watches = trackers_and_watches[1]
35+ >>> isinstance(bugzilla_other, BugzillaAPI)
36 True
37-
38- >>> isinstance(normal_bugzilla, BugzillaAPI)
39+ >>> bugzilla_other.sync_comments
40 False
41
42- >>> for watch in sorted(normal_watches, key=attrgetter('remotebug')):
43+ >>> for watch in sorted(other_watches, key=attrgetter('remotebug')):
44 ... print watch.remotebug
45 2
46 4
47 5
48
49 If we alter the SYNCABLE_GNOME_PRODUCTS list, different batches of bug
50-watches will be returned for the different Bugzilla ExternalBugTrackers.
51+watches will be returned for the two Bugzilla ExternalBugTrackers.
52
53 >>> syncable_products = [
54 ... 'HeartOfGold',
55@@ -274,25 +275,27 @@
56 >>> len(trackers_and_watches)
57 2
58
59- >>> bugzilla_api, api_watches = trackers_and_watches[0]
60- >>> normal_bugzilla, normal_watches = trackers_and_watches[1]
61- >>> isinstance(bugzilla_api, BugzillaAPI)
62- True
63-
64- >>> isinstance(normal_bugzilla, Bugzilla)
65- True
66-
67- >>> isinstance(normal_bugzilla, BugzillaAPI)
68+ >>> bugzilla_for_sync, sync_watches = trackers_and_watches[0]
69+ >>> bugzilla_other, other_watches = trackers_and_watches[1]
70+
71+ >>> isinstance(bugzilla_for_sync, BugzillaAPI)
72+ True
73+ >>> bugzilla_for_sync.sync_comments
74+ True
75+
76+ >>> isinstance(bugzilla_other, BugzillaAPI)
77+ True
78+ >>> bugzilla_other.sync_comments
79 False
80
81- >>> for watch in sorted(api_watches, key=attrgetter('remotebug')):
82+ >>> for watch in sorted(sync_watches, key=attrgetter('remotebug')):
83 ... print watch.remotebug
84 1
85 2
86 3
87 5
88
89- >>> for watch in sorted(normal_watches, key=attrgetter('remotebug')):
90+ >>> for watch in sorted(other_watches, key=attrgetter('remotebug')):
91 ... print watch.remotebug
92 4
93
94
95=== modified file 'lib/lp/bugs/scripts/checkwatches.py'
96--- lib/lp/bugs/scripts/checkwatches.py 2009-09-02 09:24:37 +0000
97+++ lib/lp/bugs/scripts/checkwatches.py 2009-09-22 15:22:53 +0000
98@@ -6,6 +6,7 @@
99 __metaclass__ = type
100
101
102+from copy import copy
103 from datetime import datetime, timedelta
104 import socket
105 import sys
106@@ -294,8 +295,8 @@
107 if (bug_tracker == gnome_bugzilla and
108 isinstance(remotesystem_to_use, BugzillaAPI)):
109
110- api_watches = []
111- normal_watches = []
112+ syncable_watches = []
113+ other_watches = []
114
115 bug_ids = [bug_watch.remotebug for bug_watch in bug_watches]
116 remote_products = remotesystem_to_use.getProductsForRemoteBugs(
117@@ -304,17 +305,22 @@
118 # For bug watches on remote bugs that are against products
119 # in the _syncable_gnome_products list - i.e. ones with which
120 # we want to sync comments - we return a BugzillaAPI
121- # instance. Otherwise we return a normal Bugzilla instance.
122+ # instance with sync_comments=True, otherwise we return a
123+ # similar BugzillaAPI instance, but with sync_comments=False.
124+ remotesystem_for_syncables = remotesystem_to_use
125+ remotesystem_for_others = copy(remotesystem_to_use)
126+ remotesystem_for_others.sync_comments = False
127+
128 for bug_watch in bug_watches:
129 if (remote_products[bug_watch.remotebug] in
130 self._syncable_gnome_products):
131- api_watches.append(bug_watch)
132+ syncable_watches.append(bug_watch)
133 else:
134- normal_watches.append(bug_watch)
135+ other_watches.append(bug_watch)
136
137 trackers_and_watches = [
138- (remotesystem_to_use, api_watches),
139- (remotesystem, normal_watches),
140+ (remotesystem_for_syncables, syncable_watches),
141+ (remotesystem_for_others, other_watches),
142 ]
143 else:
144 trackers_and_watches = [(remotesystem_to_use, bug_watches)]