Mercurial > kallithea
annotate scripts/shortlog.py @ 7586:30e3d0a14f09
scripts/shortlog: new script
Useful for release announcements, shortlog.py presents a list of committers
corresponding to the specified revision set, along with their count of
commits in that set.
Example usage:
scripts/shortlog.py "only('.', branch('stable') & tagged() & public() & not '.')"
author | Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> |
---|---|
date | Fri, 15 Mar 2019 21:25:49 +0100 |
parents | |
children | 0a277465fddf |
rev | line source |
---|---|
7586
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python2 |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
3 |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
4 """ |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
5 Kallithea script for generating a quick overview of contributors and their |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
6 commit counts in a given revision set. |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
7 """ |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
8 import argparse |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
9 import os |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
10 from collections import Counter |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
11 import contributor_data |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
12 |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
13 def main(): |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
14 |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
15 parser = argparse.ArgumentParser(description='Generate a list of committers and commit counts.') |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
16 parser.add_argument('revset', |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
17 help='revision set specifying the commits to count') |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
18 args = parser.parse_args() |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
19 |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
20 repo_entries = [ |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
21 (contributor_data.name_fixes.get(name) or contributor_data.name_fixes.get(name.rsplit('<', 1)[0].strip()) or name).rsplit('<', 1)[0].strip() |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
22 for name in (line.strip() |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
23 for line in os.popen("""hg log -r '%s' -T '{author}\n'""" % args.revset).readlines()) |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
24 ] |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
25 |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
26 counter = Counter(repo_entries) |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
27 for name, count in counter.most_common(): |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
28 if name == '': |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
29 continue |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
30 print('%4s %s' % (count, name)) |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
31 |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
32 |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
33 if __name__ == '__main__': |
30e3d0a14f09
scripts/shortlog: new script
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
parents:
diff
changeset
|
34 main() |