Merge lp:~allenap/launchpad/launchpad-naughty-naughty-comment-sync-bug-499113 into lp:launchpad

Proposed by Gavin Panella
Status: Merged
Approved by: Gavin Panella
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~allenap/launchpad/launchpad-naughty-naughty-comment-sync-bug-499113
Merge into: lp:launchpad
Diff against target: 80 lines (+20/-4)
4 files modified
lib/lp/bugs/doc/checkwatches.txt (+3/-1)
lib/lp/bugs/doc/externalbugtracker-linking-back.txt (+11/-0)
lib/lp/bugs/scripts/checkwatches.py (+5/-3)
lib/lp/bugs/scripts/tests/test_bugimport.py (+1/-0)
To merge this branch: bzr merge lp:~allenap/launchpad/launchpad-naughty-naughty-comment-sync-bug-499113
Reviewer Review Type Date Requested Status
Abel Deuring (community) code Approve
Review via email: mp+19181@code.launchpad.net

Commit message

Don't sync bug comments with remote bug trackers unless there are one or more bug tasks related to the watch.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

Checks that a bug watch is related to at least one bug task before syncing comments or back-linking.

Revision history for this message
Abel Deuring (adeuring) :
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/checkwatches.txt'
2--- lib/lp/bugs/doc/checkwatches.txt 2009-11-23 16:17:59 +0000
3+++ lib/lp/bugs/doc/checkwatches.txt 2010-02-12 15:59:16 +0000
4@@ -439,12 +439,14 @@
5 ... def setLaunchpadBugId(self, bug_id, lp_bug_id):
6 ... print "setLaunchpadBugId() called"
7
8-We'll generate a bug watch with which to test this.
9+We'll generate a bug watch with which to test this. The bug watch must
10+be associated with at least one bug task to enable syncing.
11
12 >>> LaunchpadZopelessLayer.switchDbUser('launchpad')
13 >>> login('foo.bar@canonical.com')
14 >>> bug_tracker = factory.makeBugTracker()
15 >>> bug_watch = factory.makeBugWatch(bugtracker=bug_tracker)
16+ >>> bug_watch.bug.default_bugtask.bugwatch = bug_watch
17 >>> transaction.commit()
18 >>> LaunchpadZopelessLayer.switchDbUser(config.checkwatches.dbuser)
19
20
21=== modified file 'lib/lp/bugs/doc/externalbugtracker-linking-back.txt'
22--- lib/lp/bugs/doc/externalbugtracker-linking-back.txt 2009-06-15 11:10:49 +0000
23+++ lib/lp/bugs/doc/externalbugtracker-linking-back.txt 2010-02-12 15:59:16 +0000
24@@ -34,7 +34,12 @@
25 >>> LaunchpadZopelessLayer.switchDbUser('launchpad')
26
27 >>> bug_watch = factory.makeBugWatch('42')
28+ >>> bug_watch.bug.default_bugtask.bugwatch = bug_watch
29 >>> bug_watch_2 = factory.makeBugWatch('42', bug_watch.bugtracker)
30+ >>> bug_watch_2.bug.default_bugtask.bugwatch = bug_watch_2
31+ >>> bug_watch_without_bugtask = (
32+ ... factory.makeBugWatch('42', bug_watch.bugtracker))
33+
34 >>> unlinked_bug = factory.makeBug()
35
36 >>> txn.commit()
37@@ -52,6 +57,12 @@
38 >>> external_bugtracker.last_launchpad_bug_id == bug_watch.bug.id
39 True
40
41+For comment syncing and back-linking to be attempted, bug watches must
42+be related to a bug task, not just a bug.
43+
44+ >>> bug_watch_updater.updateBugWatches(
45+ ... external_bugtracker, [bug_watch_without_bugtask])
46+
47
48 == BugWatchUpdater.linkLaunchpadBug() ==
49
50
51=== modified file 'lib/lp/bugs/scripts/checkwatches.py'
52--- lib/lp/bugs/scripts/checkwatches.py 2010-01-20 15:58:04 +0000
53+++ lib/lp/bugs/scripts/checkwatches.py 2010-02-12 15:59:16 +0000
54@@ -867,10 +867,12 @@
55 if new_malone_importance is not None:
56 bug_watch.updateImportance(new_remote_importance,
57 new_malone_importance)
58- if bug_watch.bug.duplicateof is None:
59+ if (bug_watch.bug.duplicateof is None and
60+ len(bug_watch.bugtasks) > 0):
61 # Only sync comments and backlink if the local
62- # bug isn't a duplicate. This helps us to avoid
63- # spamming upstream.
64+ # bug isn't a duplicate, *and* if the bug
65+ # watch is associated with a bug task. This
66+ # helps us to avoid spamming upstream.
67 if can_import_comments:
68 self.importBugComments(remotesystem, bug_watch)
69 if can_push_comments:
70
71=== modified file 'lib/lp/bugs/scripts/tests/test_bugimport.py'
72--- lib/lp/bugs/scripts/tests/test_bugimport.py 2010-01-04 16:08:32 +0000
73+++ lib/lp/bugs/scripts/tests/test_bugimport.py 2010-02-12 15:59:16 +0000
74@@ -770,6 +770,7 @@
75 self.id = id
76 self.remotebug = str(self.id)
77 self.bug = bug
78+ self.bugtasks = [self.bug.default_bugtask]
79 self.failing = failing
80 self.url = 'http://bugs.example.com/issues/%d' % id
81