annotate python/repostats.py2 @ 148:e5263f74b287

Added c3 language frontend initial parser
author Windel Bouwman
date Fri, 01 Mar 2013 10:24:01 +0100
parents aaa4939a7942
children
rev   line source
120
bb08633510bf Added repostat script
Windel Bouwman
parents:
diff changeset
1 #!/usr/bin/python2
bb08633510bf Added repostat script
Windel Bouwman
parents:
diff changeset
2
122
aaa4939a7942 Improved repostats
Windel Bouwman
parents: 121
diff changeset
3 import sys
aaa4939a7942 Improved repostats
Windel Bouwman
parents: 121
diff changeset
4 # Use python 2 since mercurial does not support python 3 yet?
aaa4939a7942 Improved repostats
Windel Bouwman
parents: 121
diff changeset
5 assert sys.version_info.major == 2
aaa4939a7942 Improved repostats
Windel Bouwman
parents: 121
diff changeset
6
120
bb08633510bf Added repostat script
Windel Bouwman
parents:
diff changeset
7 from mercurial import ui, hg
121
347d7d8b96c0 Cleanup
Windel Bouwman
parents: 120
diff changeset
8 import numpy
347d7d8b96c0 Cleanup
Windel Bouwman
parents: 120
diff changeset
9 import matplotlib.pyplot as plt
120
bb08633510bf Added repostat script
Windel Bouwman
parents:
diff changeset
10 import datetime
bb08633510bf Added repostat script
Windel Bouwman
parents:
diff changeset
11
bb08633510bf Added repostat script
Windel Bouwman
parents:
diff changeset
12 u = ui.ui()
bb08633510bf Added repostat script
Windel Bouwman
parents:
diff changeset
13 repo = hg.repository(u, '..')
bb08633510bf Added repostat script
Windel Bouwman
parents:
diff changeset
14
bb08633510bf Added repostat script
Windel Bouwman
parents:
diff changeset
15 stamps = []
122
aaa4939a7942 Improved repostats
Windel Bouwman
parents: 121
diff changeset
16 nds = repo.changelog.nodesbetween()[0]
aaa4939a7942 Improved repostats
Windel Bouwman
parents: 121
diff changeset
17 for hexid in nds:
120
bb08633510bf Added repostat script
Windel Bouwman
parents:
diff changeset
18 cset = repo.changelog.read(hexid)
121
347d7d8b96c0 Cleanup
Windel Bouwman
parents: 120
diff changeset
19 stamps.append(cset[2][0])
120
bb08633510bf Added repostat script
Windel Bouwman
parents:
diff changeset
20
bb08633510bf Added repostat script
Windel Bouwman
parents:
diff changeset
21 dts = [datetime.datetime.fromtimestamp(st) for st in stamps]
bb08633510bf Added repostat script
Windel Bouwman
parents:
diff changeset
22
122
aaa4939a7942 Improved repostats
Windel Bouwman
parents: 121
diff changeset
23 x = [dt.weekday() for dt in dts]
aaa4939a7942 Improved repostats
Windel Bouwman
parents: 121
diff changeset
24 y = [dt.hour for dt in dts]
121
347d7d8b96c0 Cleanup
Windel Bouwman
parents: 120
diff changeset
25
122
aaa4939a7942 Improved repostats
Windel Bouwman
parents: 121
diff changeset
26 # plot it:
aaa4939a7942 Improved repostats
Windel Bouwman
parents: 121
diff changeset
27 f = plt.figure()
aaa4939a7942 Improved repostats
Windel Bouwman
parents: 121
diff changeset
28 #plt.hexbin(x, y)
aaa4939a7942 Improved repostats
Windel Bouwman
parents: 121
diff changeset
29 plt.scatter(x, y)
aaa4939a7942 Improved repostats
Windel Bouwman
parents: 121
diff changeset
30 ax = plt.gca()
aaa4939a7942 Improved repostats
Windel Bouwman
parents: 121
diff changeset
31 ax.set_ylim([0, 24])
aaa4939a7942 Improved repostats
Windel Bouwman
parents: 121
diff changeset
32 ax.set_ylabel('hour of day')
aaa4939a7942 Improved repostats
Windel Bouwman
parents: 121
diff changeset
33 ax.set_xlim([0, 7])
aaa4939a7942 Improved repostats
Windel Bouwman
parents: 121
diff changeset
34 ax.set_xlabel('day of week')
aaa4939a7942 Improved repostats
Windel Bouwman
parents: 121
diff changeset
35 ax.grid()
121
347d7d8b96c0 Cleanup
Windel Bouwman
parents: 120
diff changeset
36 plt.show()
347d7d8b96c0 Cleanup
Windel Bouwman
parents: 120
diff changeset
37