summaryrefslogtreecommitdiff
path: root/inittags
blob: 45ddb380ab600c9e4b0205bde10ca29887c33c64 (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
72
73
74
75
76
77
78
79
#!/usr/bin/pypy
# -*- python -*-
#
# Generate a database of commits and major versions they went into.
#
# A brute-force quickish way of mapping commits to major versions
#
# This code is part of the LWN git data miner.
#
# Copyright 2007-13 Eklektix, Inc.
# Copyright 2007-13 Jonathan Corbet <corbet@lwn.net>
#
# This file may be distributed under the terms of the GNU General
# Public License, version 2.
#
import sys
import re
import os
import pickle
import argparse

#
# Arg parsing stuff.
#
def setupargs():
    p = argparse.ArgumentParser()
    #
    # -d for the database
    # -l to load it before running
    #
    p.add_argument('-d', '--database', help = 'Database name',
                   required = False, default = 'committags.db')
    p.add_argument('-l', '--load', help = 'Load database at startup',
                   default = False, action = 'store_true')
    #
    # Where's the repo?
    #
    p.add_argument('-r', '--repository', help = 'Repository location',
                   default = '')
    p.add_argument('-v', '--version', help = 'Current dev version',
                   required = True, type = int)
    return p


p = setupargs()
args = p.parse_args()

#
# Pull in an existing database if requested.
#
if args.load:
    DB = pickle.load(open(args.database, 'r'))
else:
    DB = { }
out = open(args.database, 'w')
if args.repository:
    os.chdir(args.repository)

def GetCommits(range, tag):
    git = 'git log --pretty=format:%H ' + range
    input = os.popen(git, 'r')
    for line in input.readlines():
        DB[line.strip()] = tag
    input.close()

initial = '1da177e4c3f41524e886b7f1b8a0c1fc7321cac2'
DB[initial] = 'v2.6.12'
GetCommits('1da177e4c3f41524e886b7f1b8a0c1fc7321cac2..v2.6.12', 'v2.6.12')
for v in range(13, 40):
    GetCommits('v2.6.%d..v2.6.%d' % (v - 1, v), 'v2.6.%d' % (v))
GetCommits('v2.6.39..v3.0', 'v3.0')
final = args.version
for v in range(1, final):
    GetCommits('v3.%d..v3.%d' % (v - 1, v), 'v3.%d' % (v))
GetCommits('v3.%d..' % (final - 1), 'v3.%d' % (final))

print '\nFound %d commits' % (len(DB.keys()))
pickle.dump(DB, out)
out.close()