Guest User

Untitled

a guest
Aug 21st, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. """Display commit summary by week."""
  2.  
  3. import time
  4.  
  5. def summary(ui, repo, fs='', **opts):
  6. """Display commit summary by week"""
  7. buckets = []
  8. init_date = repo[0].date()[0]
  9. now = time.time()
  10.  
  11. bucket_size = 7*24*60*60
  12.  
  13. c = now
  14. while True:
  15. buckets.append(0)
  16. c = c - bucket_size
  17. if c <= init_date:
  18. break
  19.  
  20. for rev in repo:
  21. ctx = repo[rev]
  22. timestamp = ctx.date()[0]
  23.  
  24. changes = 0
  25. if opts['diffs']:
  26. for diff in ctx.diff():
  27. cs = len(diff.split("\n"))
  28. changes = changes + cs
  29. else:
  30. changes = len(ctx.files())
  31.  
  32. d = now - timestamp
  33. bucket = int(d / bucket_size)
  34.  
  35. buckets[bucket] = buckets[bucket]+changes
  36.  
  37. buckets.reverse()
  38. ui.write(','.join(map(str, buckets)))
  39. ui.write('\n')
  40.  
  41.  
  42.  
  43. cmdtable = {
  44. "summary":
  45. (summary,
  46. [('f', 'files', None, 'count by changed files (fast, default)'),
  47. ('d', 'diffs', None, 'count by diffs (slow but more accurate)')], "[options]")
  48. }
Add Comment
Please, Sign In to add comment