120
|
1 #!/usr/bin/python2
|
|
2
|
122
|
3 import sys
|
|
4 # Use python 2 since mercurial does not support python 3 yet?
|
|
5 assert sys.version_info.major == 2
|
|
6
|
120
|
7 from mercurial import ui, hg
|
121
|
8 import numpy
|
|
9 import matplotlib.pyplot as plt
|
120
|
10 import datetime
|
|
11
|
|
12 u = ui.ui()
|
|
13 repo = hg.repository(u, '..')
|
|
14
|
|
15 stamps = []
|
122
|
16 nds = repo.changelog.nodesbetween()[0]
|
|
17 for hexid in nds:
|
120
|
18 cset = repo.changelog.read(hexid)
|
121
|
19 stamps.append(cset[2][0])
|
120
|
20
|
|
21 dts = [datetime.datetime.fromtimestamp(st) for st in stamps]
|
|
22
|
122
|
23 x = [dt.weekday() for dt in dts]
|
|
24 y = [dt.hour for dt in dts]
|
121
|
25
|
122
|
26 # plot it:
|
|
27 f = plt.figure()
|
|
28 #plt.hexbin(x, y)
|
|
29 plt.scatter(x, y)
|
|
30 ax = plt.gca()
|
|
31 ax.set_ylim([0, 24])
|
|
32 ax.set_ylabel('hour of day')
|
|
33 ax.set_xlim([0, 7])
|
|
34 ax.set_xlabel('day of week')
|
|
35 ax.grid()
|
121
|
36 plt.show()
|
|
37
|