Created
November 15, 2011 09:58
-
-
Save sunng87/1366606 to your computer and use it in GitHub Desktop.
simple hg extension to aggregate commit history by week
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Display commit summary by week.""" | |
import time | |
def summary(ui, repo, fs='', **opts): | |
"""Display commit summary by week""" | |
buckets = [] | |
init_date = repo[0].date()[0] | |
now = time.time() | |
bucket_size = 7*24*60*60 | |
c = now | |
while True: | |
buckets.append(0) | |
c = c - bucket_size | |
if c <= init_date: | |
break | |
for rev in repo: | |
ctx = repo[rev] | |
timestamp = ctx.date()[0] | |
changes = 0 | |
if opts['diffs']: | |
for diff in ctx.diff(): | |
cs = len(diff.split("\n")) | |
changes = changes + cs | |
else: | |
changes = len(ctx.files()) | |
d = now - timestamp | |
bucket = int(d / bucket_size) | |
buckets[bucket] = buckets[bucket]+changes | |
buckets.reverse() | |
ui.write(','.join(map(str, buckets))) | |
ui.write('\n') | |
cmdtable = { | |
"summary": | |
(summary, | |
[('f', 'files', None, 'count by changed files (fast, default)'), | |
('d', 'diffs', None, 'count by diffs (slow but more accurate)')], "[options]") | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment