public
Last active

simple hg extension to aggregate commit history by week

  • Download Gist
summary.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
import time
 
def summary(ui, repo, fs='', **opts):
"""display commit summay
 
"""
buckets = []
init_date = repo[0].date()[0]
now = time.time()
 
c = now
while True:
buckets.append(0)
c = c - 7*24*60*60
if c <= init_date:
break
for rev in repo:
ctx = repo[rev]
timestamp = ctx.date()[0]
 
changes = 0
for diff in ctx.diff():
cs = len(diff.split("\n"))
changes = changes + cs
 
d = now - timestamp
bucket = int(d / (7*24*60*60))
buckets[bucket] = buckets[bucket]+changes
 
buckets.reverse()
ui.write(','.join(map(str, buckets)))
ui.write('\n')
 
 
cmdtable = {
"summary":
(summary, [], "")
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.