List:Commits« Previous MessageNext Message »
From:Timothy Smith Date:June 19 2008 2:03am
Subject:bzr commit into mysql_plugins branch (timothy.smith:121)
View as plain text  
#At file:///home/tsmith/.bazaar/plugins/mysql/

  121 Timothy Smith	2008-06-18 [merge]
      Auto merge
modified:
  .bzr-mysql/default.conf
  __init__.py
  emailer.py
  hooks.py

=== modified file '.bzr-mysql/default.conf'
--- a/.bzr-mysql/default.conf	2008-05-21 22:17:24 +0000
+++ b/.bzr-mysql/default.conf	2008-06-18 10:43:25 +0000
@@ -1,5 +1,5 @@
 [MYSQL]
 tree_location = bzr+ssh://bk-internal.mysql.com/home/bk/bazaar/mysql_plugins/
-post_commit_to = mtaylor@stripped, cmiller@stripped
 post_push_to = bzr@stripped
+post_commit_to = commits@stripped, bzr@stripped
 tree_name = mysql_plugins

=== modified file '__init__.py'
--- a/__init__.py	2008-06-12 20:03:34 +0000
+++ b/__init__.py	2008-06-18 13:03:09 +0000
@@ -34,7 +34,7 @@ import hooks
 import sanity
 """)
 
-version_info = (0, 3, 8)
+version_info = (0, 3, 10)
 
 register_command(parent.cmd_parent)
 register_command(collapse.cmd_collapse)

=== modified file 'emailer.py'
--- a/emailer.py	2008-06-19 00:02:03 +0000
+++ b/emailer.py	2008-06-19 00:03:41 +0000
@@ -133,16 +133,13 @@ class EmailSender(object):
     def search_for_bugs(self, commit_message):
         """ scan entire log output for mentions of bugs, worklogs """
 
-        self.bug_ids_found = list(set(re.findall(r"(?i)\bbug[#:=]? ?(\d+)",
+        self.bug_ids_found = list(set(re.findall(r"(?i)\bbug[ ]*#[ ]*(\d+)",
                                                  commit_message.encode("utf8"))))
-        self.worklog_ids_found = list(set(re.findall(r"(?i)\bwl[#:=]? ?(\d+)",
+        self.worklog_ids_found = list(set(re.findall(r"(?i)\bwl[ ]*#[ ]*(\d+)",
                                                      commit_message.encode("utf8"))))
-        self.blueprint_ids_found = list(set(re.findall(r"(?i)\bblueprint[#:=]? ?(\d+)",
+        self.blueprint_ids_found = list(set(re.findall(r"(?i)\bblueprint[ ]*#[ ]*(\d+)",
                                                        commit_message.encode("utf8"))))
 
-        self.bug_ids_found.sort()
-        self.worklog_ids_found.sort()
-        self.blueprint_ids_found.sort()
 
     def pre_message(self):
         # This had better be in the same encoding as the output.  :\
@@ -278,8 +275,8 @@ class EmailSender(object):
         project = self.project()
         if project is not None:
             the_headers.append(('X-Project',project))
-        for bug_id in self.bug_ids_found:
-            the_headers.append(('X-Bug',str(bug_id)))
+        if len(self.bug_ids_found) > 0:
+            the_headers.append(('X-Bug',str(self.bug_ids_found[0])))
         for wl_id in self.worklog_ids_found:
             the_headers.append(('X-Worklog',str(wl_id)))
         for blueprint_id in self.blueprint_ids_found:
@@ -438,6 +435,25 @@ class PushSender(EmailSender):
     def body(self):
         """ Return the bzr log to work as the 'commit message' here """
         if self._body is None:
+            # We need the revno of the old revision in-the-new-tree
+            note("Generating post-push message")
+            try:
+                # Optimized case - if it works on the old_revid, we don't need
+                # to do the slow code below.
+                self.old_revno = self.branch.revision_id_to_revno(self.old_revid)
+            except:
+                b=self.branch
+                b.lock_read()
+                g = b.repository.get_graph()
+                last = b.last_revision()
+                while True:
+                    last_but_one = b.repository.get_revision(last).parent_ids[0]
+                    introduced_by_last = g.find_unique_ancestors(last, [last_but_one])
+                    if self.old_revid in introduced_by_last:
+                        break
+                    last = last_but_one
+                self.old_revno = b.revision_id_to_revno(last)
+
             outf = StringIO.StringIO()
 
             lf = log_formatter('short',
@@ -445,13 +461,14 @@ class PushSender(EmailSender):
                                to_file=outf
                                )
 
-            mutter("Getting log information for (%s:%s)" %
(self.old_revno+1,self.new_revno))
+            mutter("Getting log information for (%s:%s)" %
(self.old_revno,self.new_revno))
             log.show_log(self.branch, lf, verbose=True,
                          direction='reverse',
-                         start_revision=self.old_revno+1,
+                         start_revision=self.old_revno,
                          end_revision=self.new_revno)
 
             self._body = outf.getvalue().decode(self.encoding)
+            note("Sending post-push message")
 
         return self._body
 
@@ -488,10 +505,10 @@ class PushSender(EmailSender):
 
         vals = dict(tree=self.tree_name_or_url(),
                     user=self.user(),
-                    old_revno=self.old_revno+1,
+                    old_revno=self.old_revno,
                     new_revno=self.new_revno,
                     ref_subject=self.ref_subject())
-        if self.old_revno+1==self.new_revno:
+        if self.old_revno==self.new_revno:
             theSubject = "bzr push into %(tree)s branch (%(user)s:%(old_revno)s)
%(ref_subject)s" % vals
         else:
             theSubject = "bzr push into %(tree)s branch (%(user)s:%(old_revno)s to
%(new_revno)s) %(ref_subject)s" % vals

=== modified file 'hooks.py'
--- a/hooks.py	2008-05-06 01:00:18 +0000
+++ b/hooks.py	2008-06-18 13:10:28 +0000
@@ -38,22 +38,31 @@ def branch_commit_hook(local, master, ol
         emailer.CommitSender(master, old_revno, old_revid, new_revno, 
                             new_revid, PluginBranchConfig("mysql",master),
                             local_branch=local).send_maybe()
-    finally:
-        master.unlock()    
+    except Exception, e:
+        note("WARNING: Problem with post-commit email hook. ")
+        note("\t %s" % str(e))
+        note("Please see .bzr.log for more information")
+    # Can't do finally here - some people have older python 
+    master.unlock()    
 
 
 def branch_push_hook(push_result):
     """Send an email after a push"""
     if push_result.old_revid != push_result.new_revid:
         config = PluginBranchConfig("mysql", push_result.source_branch)
-        emailer.PushSender(push_result.source_branch, 
-                           push_result.old_revno, push_result.old_revid,
-                           push_result.new_revno, push_result.new_revid,
-                           config, 
-                           local_branch=push_result.local_branch,
-                           target_branch=push_result.target_branch,
-                           master_branch=push_result.master_branch,  
-                       ).send_maybe()
+        try:
+            emailer.PushSender(push_result.source_branch, 
+                               push_result.old_revno, push_result.old_revid,
+                               push_result.new_revno, push_result.new_revid,
+                               config, 
+                               local_branch=push_result.local_branch,
+                               target_branch=push_result.target_branch,
+                               master_branch=push_result.master_branch,  
+                           ).send_maybe()
+        except Exception, e:
+            note("WARNING: Problem with post-push email hook.")
+            note("\t %s" % str(e))
+
         if config.get_user_option("buildbot_location", False, None) is not None:
             try:
                 mutter("running buildbot hook")

Thread
bzr commit into mysql_plugins branch (timothy.smith:121) Timothy Smith19 Jun