Created
January 9, 2012 06:52
-
-
Save karronoli/1581558 to your computer and use it in GitHub Desktop.
Google bugspots for Mercurial + python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mercurial import ui, hg | |
import re | |
import time | |
import math | |
import sys | |
DEBUG = 0 | |
repo = hg.repository(ui.ui(), sys.argv[1]) | |
message_matchers = re.compile('fix(es|ed)?|close(s|d)?', re.IGNORECASE) | |
fixes = [ | |
{'message': ctx.description(), | |
'date': ctx.date()[0], | |
'files':ctx.files()} | |
for ctx in [repo.changectx(c) for c in repo.changelog] \ | |
if message_matchers.match(ctx.description()) | |
] | |
if DEBUG: | |
print fixes | |
hotspots = {} | |
first_commit_date = min([fix['date'] for fix in fixes]) | |
for fix in fixes: | |
t = 1 - ((time.time() - fix['date']) / (time.time() - first_commit_date)) | |
for filename in fix['files']: | |
if DEBUG: | |
print 'tmp:', t, 'now:', time.time(),\ | |
'date:', fix['date'],\ | |
'fixes.last.date:', fixes[0]['date'],\ | |
'1st commit date:', first_commit_date,\ | |
'file:', filename, 'desc:', fix['message'] | |
hotspots[filename] = hotspots.get(filename, 0) \ | |
+ 1.0 / (1.0 + math.exp((-12.0 * t) + 12.0)) | |
print ['%s: %.6f' % (k, hotspots[k]) for k in hotspots] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
no work on mercurial 2.5 ...