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
=== modified file 'lib/lp/bugs/doc/checkwatches.txt'
--- lib/lp/bugs/doc/checkwatches.txt 2009-11-23 16:17:59 +0000
+++ lib/lp/bugs/doc/checkwatches.txt 2010-02-12 15:59:16 +0000
@@ -439,12 +439,14 @@
439 ... def setLaunchpadBugId(self, bug_id, lp_bug_id):439 ... def setLaunchpadBugId(self, bug_id, lp_bug_id):
440 ... print "setLaunchpadBugId() called"440 ... print "setLaunchpadBugId() called"
441441
442We'll generate a bug watch with which to test this.442We'll generate a bug watch with which to test this. The bug watch must
443be associated with at least one bug task to enable syncing.
443444
444 >>> LaunchpadZopelessLayer.switchDbUser('launchpad')445 >>> LaunchpadZopelessLayer.switchDbUser('launchpad')
445 >>> login('foo.bar@canonical.com')446 >>> login('foo.bar@canonical.com')
446 >>> bug_tracker = factory.makeBugTracker()447 >>> bug_tracker = factory.makeBugTracker()
447 >>> bug_watch = factory.makeBugWatch(bugtracker=bug_tracker)448 >>> bug_watch = factory.makeBugWatch(bugtracker=bug_tracker)
449 >>> bug_watch.bug.default_bugtask.bugwatch = bug_watch
448 >>> transaction.commit()450 >>> transaction.commit()
449 >>> LaunchpadZopelessLayer.switchDbUser(config.checkwatches.dbuser)451 >>> LaunchpadZopelessLayer.switchDbUser(config.checkwatches.dbuser)
450452
451453
=== modified file 'lib/lp/bugs/doc/externalbugtracker-linking-back.txt'
--- lib/lp/bugs/doc/externalbugtracker-linking-back.txt 2009-06-15 11:10:49 +0000
+++ lib/lp/bugs/doc/externalbugtracker-linking-back.txt 2010-02-12 15:59:16 +0000
@@ -34,7 +34,12 @@
34 >>> LaunchpadZopelessLayer.switchDbUser('launchpad')34 >>> LaunchpadZopelessLayer.switchDbUser('launchpad')
3535
36 >>> bug_watch = factory.makeBugWatch('42')36 >>> bug_watch = factory.makeBugWatch('42')
37 >>> bug_watch.bug.default_bugtask.bugwatch = bug_watch
37 >>> bug_watch_2 = factory.makeBugWatch('42', bug_watch.bugtracker)38 >>> bug_watch_2 = factory.makeBugWatch('42', bug_watch.bugtracker)
39 >>> bug_watch_2.bug.default_bugtask.bugwatch = bug_watch_2
40 >>> bug_watch_without_bugtask = (
41 ... factory.makeBugWatch('42', bug_watch.bugtracker))
42
38 >>> unlinked_bug = factory.makeBug()43 >>> unlinked_bug = factory.makeBug()
3944
40 >>> txn.commit()45 >>> txn.commit()
@@ -52,6 +57,12 @@
52 >>> external_bugtracker.last_launchpad_bug_id == bug_watch.bug.id57 >>> external_bugtracker.last_launchpad_bug_id == bug_watch.bug.id
53 True58 True
5459
60For comment syncing and back-linking to be attempted, bug watches must
61be related to a bug task, not just a bug.
62
63 >>> bug_watch_updater.updateBugWatches(
64 ... external_bugtracker, [bug_watch_without_bugtask])
65
5566
56== BugWatchUpdater.linkLaunchpadBug() ==67== BugWatchUpdater.linkLaunchpadBug() ==
5768
5869
=== modified file 'lib/lp/bugs/scripts/checkwatches.py'
--- lib/lp/bugs/scripts/checkwatches.py 2010-01-20 15:58:04 +0000
+++ lib/lp/bugs/scripts/checkwatches.py 2010-02-12 15:59:16 +0000
@@ -867,10 +867,12 @@
867 if new_malone_importance is not None:867 if new_malone_importance is not None:
868 bug_watch.updateImportance(new_remote_importance,868 bug_watch.updateImportance(new_remote_importance,
869 new_malone_importance)869 new_malone_importance)
870 if bug_watch.bug.duplicateof is None:870 if (bug_watch.bug.duplicateof is None and
871 len(bug_watch.bugtasks) > 0):
871 # Only sync comments and backlink if the local872 # Only sync comments and backlink if the local
872 # bug isn't a duplicate. This helps us to avoid873 # bug isn't a duplicate, *and* if the bug
873 # spamming upstream.874 # watch is associated with a bug task. This
875 # helps us to avoid spamming upstream.
874 if can_import_comments:876 if can_import_comments:
875 self.importBugComments(remotesystem, bug_watch)877 self.importBugComments(remotesystem, bug_watch)
876 if can_push_comments:878 if can_push_comments:
877879
=== modified file 'lib/lp/bugs/scripts/tests/test_bugimport.py'
--- lib/lp/bugs/scripts/tests/test_bugimport.py 2010-01-04 16:08:32 +0000
+++ lib/lp/bugs/scripts/tests/test_bugimport.py 2010-02-12 15:59:16 +0000
@@ -770,6 +770,7 @@
770 self.id = id770 self.id = id
771 self.remotebug = str(self.id)771 self.remotebug = str(self.id)
772 self.bug = bug772 self.bug = bug
773 self.bugtasks = [self.bug.default_bugtask]
773 self.failing = failing774 self.failing = failing
774 self.url = 'http://bugs.example.com/issues/%d' % id775 self.url = 'http://bugs.example.com/issues/%d' % id
775776