comparison scripts/contributors.py @ 4822:e162fb7353df

contributors.py: Add script to find out contributors
author anatoly techtonik <techtonik@gmail.com>
date Sun, 25 Aug 2013 11:35:10 +0300
parents
children dfef44485418
comparison
equal deleted inserted replaced
4821:c84dbc205b57 4822:e162fb7353df
1 """
2 Get Mercurial history data and output list of contributors with years.
3
4 Public domain work by:
5
6 anatoly techtonik <techtonik@gmail.com>
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 <richard@users.sourceforge.net>
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('')

Roundup Issue Tracker: http://roundup-tracker.org/