Skip to content

Commit 1ff9206

Browse files
committed
contributors.py: Add script to find out contributors
1 parent 1ed0e25 commit 1ff9206

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

scripts/contributors.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
"""
2+
Get Mercurial history data and output list of contributors with years.
3+
4+
Public domain work by:
5+
6+
anatoly techtonik <[email protected]>
7+
8+
"""
9+
10+
from subprocess import check_output
11+
12+
# --- output settings
13+
contributors_by_year = True
14+
years_for_contributors = True
15+
verbose = True
16+
# /--
17+
18+
19+
if verbose:
20+
print("Getting HG log...")
21+
authorship = check_output('hg log --template "{date(date,\\"%Y\\")},{author}\n"')
22+
# authorship are strings like
23+
# 2003,Richard Jones <[email protected]>
24+
# ...
25+
26+
if verbose:
27+
print("Splitting...")
28+
# transform to a list of tuples
29+
authorship = [line.split(',', 1) for line in authorship.splitlines()]
30+
31+
if verbose:
32+
print("Sorting...")
33+
years = {} # year -> set(author1, author2, ...)
34+
names = {} # author -> set(years)
35+
for year,author in authorship:
36+
# years
37+
if not year in years:
38+
years[year] = set()
39+
years[year].add(author)
40+
# names
41+
if not author in names:
42+
names[author] = set()
43+
names[author].add(int(year))
44+
45+
46+
if contributors_by_year:
47+
if verbose:
48+
print("Contributors by year...")
49+
print('')
50+
for year in sorted(years, reverse=True):
51+
print(year)
52+
for author in sorted(years[year]):
53+
print(" " + author)
54+
print('')
55+
56+
if years_for_contributors:
57+
if verbose:
58+
print("Years for each contributor...")
59+
print('')
60+
for author in sorted(names):
61+
years = sorted(names[author])
62+
print(years, author)
63+
print('')

0 commit comments

Comments
 (0)