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