Skip to content

Instantly share code, notes, and snippets.

@sunng87
Created November 15, 2011 09:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sunng87/1366606 to your computer and use it in GitHub Desktop.
Save sunng87/1366606 to your computer and use it in GitHub Desktop.
simple hg extension to aggregate commit history by week
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, [], "")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment