Do not reopen closed bugs due to bug mentions

Do not let update_bug.py reopen a FixCommitted or FixReleased bug just
because the bug number was mentioned in a commit message. In most cases
that mention is just a simple reference to a closed bug. In the rare
cases the committer actually wanted to reopen a closed bug, he should
rather have open a specific bug about it anyway.

Fixes bug 1078745

Change-Id: I513e6fc73d6bab02de21628e55a5d28189834632
Reviewed-on: https://review.openstack.org/16080
Reviewed-by: Monty Taylor <mordred@inaugust.com>
Reviewed-by: Jeremy Stanley <fungi@yuggoth.org>
Approved: James E. Blair <corvus@inaugust.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
diff --git a/update_bug.py b/update_bug.py
index 1ff0b3b..9479a81 100755
--- a/update_bug.py
+++ b/update_bug.py
@@ -138,14 +138,16 @@
             if is_direct_release(args.project):
                 set_fix_released(bugtask)
             else:
-                set_fix_committed(bugtask)
+                if bugtask.status != u'Fix Released':
+                    set_fix_committed(bugtask)
         elif args.branch == 'milestone-proposed':
             release_fixcommitted(bugtask)
         elif args.branch.startswith('stable/'):
             series = args.branch[7:]
             # Look for a related task matching the series
             for reltask in bugtask.related_tasks:
-                if reltask.bug_target_name.endswith("/" + series):
+                if (reltask.bug_target_name.endswith("/" + series) and
+                    reltask.status != u'Fix Released'):
                     # Use fixcommitted if there is any
                     set_fix_committed(reltask)
                     break
@@ -159,11 +161,14 @@
 
     if args.hook == "patchset-created":
         if args.branch == 'master':
-            set_in_progress(bugtask, launchpad, args.uploader, args.change_url)
+            if bugtask.status not in [u'Fix Committed', u'Fix Released']:
+                set_in_progress(bugtask, launchpad, args.uploader,
+                                args.change_url)
         elif args.branch.startswith('stable/'):
             series = args.branch[7:]
             for reltask in bugtask.related_tasks:
-                if reltask.bug_target_name.endswith("/" + series):
+                if (reltask.bug_target_name.endswith("/" + series) and
+                    reltask.status not in [u'Fix Committed', u'Fix Released']):
                     set_in_progress(reltask, launchpad,
                                     args.uploader, args.change_url)
                     break