view python/repostats.py2 @ 126:bbf4c9b138d4

Changes to elf reading
author Windel Bouwman
date Sun, 13 Jan 2013 12:14:27 +0100
parents aaa4939a7942
children
line wrap: on
line source

#!/usr/bin/python2

import sys
# Use python 2 since mercurial does not support python 3 yet?
assert sys.version_info.major == 2

from mercurial import ui, hg
import numpy
import matplotlib.pyplot as plt
import datetime

u = ui.ui()
repo = hg.repository(u, '..')

stamps = []
nds = repo.changelog.nodesbetween()[0]
for hexid in nds:
   cset = repo.changelog.read(hexid)
   stamps.append(cset[2][0])

dts = [datetime.datetime.fromtimestamp(st) for st in stamps]

x = [dt.weekday() for dt in dts]
y = [dt.hour for dt in dts]

# plot it:
f = plt.figure()
#plt.hexbin(x, y)
plt.scatter(x, y)
ax = plt.gca()
ax.set_ylim([0, 24])
ax.set_ylabel('hour of day')
ax.set_xlim([0, 7])
ax.set_xlabel('day of week')
ax.grid()
plt.show()