Welcome, guest | Sign In | My Account | Store | Cart

Who's the most prolific committer in town? Use this script to find out!

This script uses pysvn, http://pysvn.tigris.org

Python, 40 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#! /usr/bin/env python
import pysvn, re

def repos(work_path):
    "Get the svn repository url"
    info = pysvn.Client().info(work_path)

    if info.repos:
        return info.repos

    # special case - checked out the trunk
    if info.url.endswith("/trunk"):
        return re.sub(r"/trunk$", "", info.url)

    # default to the current dir's url
    return info.url

def authors(repos):
    "Get the authors who have commited to the repository, one name per commit"
    return [log["author"] for log in pysvn.Client().log(repos)]

def histogram(seq):
    result = {}
    for x in seq:
        result.setdefault(x, 0)
        result[x] += 1
    return result

def format2cols(items):
    max_width = max(len(str(x)) for (x,y) in items)
    template = "%%%ds %%s" % max_width
    return "\n".join(template % (x, y) for (x, y) in items)

def sort_uniq_c(seq):
    "Duplicate unix's 'sort | uniq -c | sort -nr'"
    count_first = ((y,x) for (x,y) in histogram(seq).items())
    return format2cols(sorted(count_first, reverse=True))

if __name__ == "__main__":
    print sort_uniq_c(authors(repos(work_path = '.')))

I've had a unix shell one-liner lying around, that does almost the same thing: <pre>svn log svn info|grep '^Repository Root'|awk '{print $3}' | grep '^r[0-9].*lines\?'|cut -d'|' -f2|sort|uniq -c|sort -nr</pre> I'm learning pysvn, and felt like reimplementing it with more readable, if longer, code.

What's the use of this? Mostly fun, since these stats have no deep meaning. We sometimes use them to encourage our Young Programmers to commit often :-)

For curiosity's sake, here are Python's own statistics: <pre> 7898 guido 6236 fdrake 2601 gvanrossum 2336 tim_one 1763 bwarsaw 1706 jack 1621 rhettinger 1526 jackjansen 1354 loewis 1175 jhylton 1156 akuchling 878 gward 764 nnorwitz 724 neal.norwitz 543 montanaro 513 mwh 485 georg.brandl 452 439 martin.v.loewis 395 tim.peters 357 kbk 330 andrew.kuchling 317 nascheme 313 bcannon 291 theller 286 anthonybaxter 280 lemburg 269 doerwalter 266 jvr 241 birkenfeld 207 effbot 195 twouters 179 thomas.wouters 172 thomas.heller 163 brett.cannon 151 sjoerd 132 aimacintyre 124 mhammond 118 anthony.baxter 115 elguavas 109 greg 107 fredrik.lundh 97 guido.van.rossum 96 perky 93 esr 88 ping 87 moshez 87 jlgijsbers 87 fred.drake 83 just 79 rmasse 73 reinhold.birkenfeld 69 vsajip 65 walter.doerwald 63 barry.warsaw 62 ronald.oussoren 62 arigo 55 armin.rigo 54 niemeyer 54 george.yoshida 53 edloper 47 skip.montanaro 47 nowonder 46 phillip.eby 45 akuchlin 44 richard.jones 44 nick.coghlan 42 vinay.sajip 42 bob.ippolito 37 jlt63 36 hyeshik.chang 36 gregory.p.smith 36 dcjim 34 pierslauder 31 larsga 29 gstein 28 mondragon 28 jeremy.hylton 28 jackilyn.hoxworth 28 aleax 26 kurt.kaiser 26 andrewmcnamara 25 astrand 24 tmick 24 martin.blais 22 marangoz 20 prescod 19 doko 19 amk 18 tonylownds 18 purcell 18 andrew.dalke 17 bckfnn 17 andrew.macintyre 15 marc-andre.lemburg 14 sean.reifschneider 12 raymond.hettinger 11 pje 10 teyc 10 gerhard.haering 9 trent.mick 8 steve.holden 8 rwpython 8 pedronis 8 jack.jansen 8 holdenweb 8 greg.ward 8 alex.martelli 7 kristjan.jonsson 7 klm 6 jafo 6 davecole 5 tismer 5 peter.astrand 5 michael.hudson 5 ka-ping.yee 5 jack.diederich 5 goodger 5 facundobatista 4 neil.schemenauer 4 etrepum 3 warsaw 3 uid33605 3 matthias.klose 3 matt.fleming 3 jim.fulton 2 uid35364 2 nriley 2 david_ascher 2 david.goodger 1 uid56795 1 uid34174 1 uid28957 1 uid26747 1 runar.petursson 1 richard.tew 1 gustavo.niemeyer 1 facundo.batista 1 dscherer 1 cgw 1 anoncvs_avitools 1 andrew.mcnamara </pre>