Rev 5451: Parse authors too (1116 bugs seen, we miss 24, the others are false positives). in file:///home/vila/src/bzr/experimental/fixed-in/

Vincent Ladeuil v.ladeuil+lp at free.fr
Tue Sep 28 01:18:21 BST 2010


At file:///home/vila/src/bzr/experimental/fixed-in/

------------------------------------------------------------
revno: 5451
revision-id: v.ladeuil+lp at free.fr-20100928001820-675kun7uvifk8kjs
parent: v.ladeuil+lp at free.fr-20100927222133-52tted8xgkt1h80i
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: fixed-in
timestamp: Tue 2010-09-28 02:18:20 +0200
message:
  Parse authors too (1116 bugs seen, we miss 24, the others are false positives).
-------------- next part --------------
=== modified file 'tools/fixed-in.py'
--- a/tools/fixed-in.py	2010-09-27 22:21:33 +0000
+++ b/tools/fixed-in.py	2010-09-28 00:18:20 +0000
@@ -18,9 +18,10 @@
 
 class NewsParser(object):
 
+    paren_exp_re = re.compile('\(([^)]+)\)')
     release_re = re.compile("bzr[ -]")
     release_prefix_length = len('bzr ')
-    bug_pattern = re.compile("(#(?:[0-9]+)(?:,\s)?)+?")
+    bugs_re = re.compile('#([0-9]+)')
 
     def __init__(self, news):
         self.news = news
@@ -63,9 +64,19 @@
         # Not all entries will contain bugs and some entries are even garbage
         # that is not parsed (yet).
         # FIXME: Malone entries are different
-        for bug_number in self.bug_pattern.findall(self.entry):
-#            import pdb; pdb.set_trace()
-            yield (bug_number, self.release, self.entry)
+        # FIXME: instead of authors, #bugs we used to use #bugs, authors
+        # Allow multiple line matches without the need to tweak regexps
+        flat_entry = ' '.join(self.entry.splitlines())
+        # Fixed bugs are always inside parens
+        for par in self.paren_exp_re.findall(flat_entry):
+            sharp = par.find('#')
+            if sharp:
+                bugs = self.bugs_re.findall(par[sharp:])
+                authors = par[:sharp].rstrip(', ')
+                for bug_number in bugs:
+                    if bug_number:
+                        print 'bug_number: [%r]' % (bug_number,)
+                        yield (bug_number, authors, self.release, self.entry)
         # We've consumed the entry
         self.entry = ''
 
@@ -97,12 +108,13 @@
         seen = 0
         for b in parser.parse_bugs():
             #(number, release, date, author, entry) = b
-            (number, release, entry,) = b
-            (date, author) = ('2010-01-01', 'joe',)
+            (number, authors, release, entry,) = b
+            (date,) = ('2010-01-01',)
             # indent entry
             entry = '\n'.join(['    ' + l for l in entry.splitlines()])
 #            if number == bug[1:]: # Strip the leading '#'
-            print 'Bug %s was fixed in bzr-%s:' % (number, release)
+            print 'Bug %s was fixed in bzr-%s by %s:' % (
+                number, release, authors)
             print entry
             seen += 1
     finally:



More information about the bazaar-commits mailing list