Mercurial > public > mercurial-scm > python-hglib
comparison examples/stats.py @ 78:031cbb8d4f65
examples: add simple stat-gathering example
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 09 Nov 2011 14:07:29 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
77:4282391dd693 | 78:031cbb8d4f65 |
---|---|
1 # stats - get stats on the given repo | |
2 | |
3 import sys | |
4 import hglib | |
5 | |
6 # figure out what repo path to use | |
7 repo = '.' | |
8 if len(sys.argv) > 1: | |
9 repo = sys.argv[1] | |
10 | |
11 # connect to hg | |
12 client = hglib.open(repo) | |
13 | |
14 # gather some stats | |
15 revs = int(client.tip().rev) | |
16 files = len(list(client.manifest())) | |
17 heads = len(client.heads()) | |
18 branches = len(client.branches()) | |
19 tags = len(client.tags()) - 1 # don't count tip | |
20 | |
21 authors = {} | |
22 for e in client.log(): | |
23 authors[e.author] = True | |
24 | |
25 merges = 0 | |
26 for e in client.log(onlymerges=True): | |
27 merges += 1 | |
28 | |
29 print "%d revisions" % revs | |
30 print "%d merges" % merges | |
31 print "%d files" % files | |
32 print "%d heads" % heads | |
33 print "%d branches" % branches | |
34 print "%d tags" % tags | |
35 print "%d authors" % len(authors) |