Skip to content

Commit ab4cf68

Browse files
committed
contributors.py: Exclude robots and change sorting so that
among most recent contributors people with earlier entry date appear at the top. Add description to scripts/README.txt
1 parent 680d720 commit ab4cf68

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

scripts/README.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ imapServer.py
3131
This IMAP server script that runs in the background and checks for new
3232
email from a variety of mailboxes.
3333

34+
contributors.py
35+
Analyzes Mercurial log, filters and compiles list of committers with years
36+
of contribution. Can be useful for updating COPYING.txt

scripts/contributors.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
'John P. Rouillard <[email protected]>':
3131
['rouilj'],
3232
}
33+
ROBOTS = ['No Author <[email protected]>']
3334
# /--
3435

3536

@@ -93,11 +94,15 @@ def compress(years):
9394
years = {} # year -> set(author1, author2, ...)
9495
names = {} # author -> set(years)
9596
for year, author in authorship:
97+
if author in ROBOTS:
98+
continue
9699
# process aliases
97100
for name, aliases in ALIASES.items():
98101
if author in aliases:
99102
author = name
100103
break
104+
author = author.replace('<', '(')
105+
author = author.replace('>', ')')
101106
# years
102107
if not year in years:
103108
years[year] = set()
@@ -134,19 +139,21 @@ def first_year(name):
134139
def year_cmp(name1, name2):
135140
"""
136141
Year comparison function. First sort by latest contribution year (desc).
137-
If it matches, compare first contribution year (desc).
142+
If it matches, compare first contribution year (asc). This ensures that
143+
the most recent and long-term contributors are at the top.
138144
"""
139145
if last_year(name1) != last_year(name2):
140146
return last_year(name1) - last_year(name2)
141147
else:
142-
return first_year(name1) - first_year(name2)
148+
return first_year(name2) - first_year(name1)
143149

150+
print("Copyright (c)")
144151
for author in sorted(list(names), cmp=year_cmp, reverse=True):
145152
years = list(names[author])
146153
yearstr = compress(years)
147154

148155
if 0: #DEBUG
149156
print(years, yearstr, author)
150157
else:
151-
print("Copyright (c) %s %s" % (yearstr, author))
158+
print(" %s %s" % (yearstr, author))
152159
print('')

0 commit comments

Comments
 (0)