summaryrefslogtreecommitdiff
path: root/firstlast
blob: 3cdd23ad7b659c6098baf241a81e7897d23d2c47 (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/pypy
# -*- python -*-
#
# Crank through the log looking at when developers did their first and
# last patches.
#
# git log | firstlast -v versiondb
#
import argparse, pickle
import sys
import gitlog
import database
import ConfigFile

#
# Arg processing
#
def SetupArgs():
    p = argparse.ArgumentParser()
    p.add_argument('-v', '--versiondb', help = 'Version database file',
                   required = False, default = 'committags.db')
    p.add_argument('-c', '--config', help = 'Configuration file',
                   required = True)
    p.add_argument('-d', '--dbdir', help = 'Where to find the config database files',
                   required = False, default = '')
    return p.parse_args()

args = SetupArgs()
VDB = pickle.load(open(args.versiondb, 'r'))
ConfigFile.ConfigFile(args.config, args.dbdir)

Firsts = { }
Lasts = { }

patch = gitlog.grabpatch(sys.stdin)
while patch:
    try:
        v = VDB[patch.commit]
    except KeyError:
        print 'Funky commit', patch.commit
        continue
    try:
        x = patch.author.patches
    except AttributeError:
        print 'Attr err', patch.commit
        continue
    #
    # The first patch we see is the last they committed, since git
    # lists things in backwards order.
    #
    if len(patch.author.patches) == 0:
        patch.author.lastvers = v
        try:
            Lasts[v].append(patch.author)
        except KeyError:
            Lasts[v] = [patch.author]
    patch.author.firstvers = v
    patch.author.addpatch(patch)
    patch = gitlog.grabpatch(sys.stdin)

for h in database.AllHackers():
    if len(h.patches) > 0:
        try:
            Firsts[h.firstvers].append(h)
        except KeyError:
            Firsts[h.firstvers] = [h]

for v in Lasts.keys():
    print v, len(Firsts[v]), len(Lasts[v])

database.DumpDB()