List:Commits« Previous MessageNext Message »
From:Monty Taylor Date:June 18 2008 12:42pm
Subject:bzr commit into mysql_plugins branch (mordred:128)
View as plain text  
#At file:///home/mtaylor/.bazaar/plugins/mysql/

  128 Monty Taylor	2008-06-18
      Added optimized case so that we aren't always completely slow.
modified:
  emailer.py

=== modified file 'emailer.py'
--- a/emailer.py	2008-06-18 11:15:11 +0000
+++ b/emailer.py	2008-06-18 12:42:26 +0000
@@ -437,17 +437,22 @@ class PushSender(EmailSender):
         if self._body is None:
             # We need the revno of the old revision in-the-new-tree
             note("Generating post-push message")
-            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)
+            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()
 

Thread
bzr commit into mysql_plugins branch (mordred:128) Monty Taylor18 Jun