4 # Generate a database of commits and major versions they went into.
6 # A brute-force quickish way of mapping commits to major versions
8 # This code is part of the LWN git data miner.
10 # Copyright 2007-13 Eklektix, Inc.
11 # Copyright 2007-13 Jonathan Corbet <corbet@lwn.net>
13 # This file may be distributed under the terms of the GNU General
14 # Public License, version 2.
26 p
= argparse
.ArgumentParser()
29 # -l to load it before running
31 p
.add_argument('-d', '--database', help = 'Database name',
32 required
= False, default
= 'committags.db')
33 p
.add_argument('-l', '--load', help = 'Load database at startup',
34 default
= False, action
= 'store_true')
38 p
.add_argument('-r', '--repository', help = 'Repository location',
40 p
.add_argument('-v', '--version', help = 'Current dev version',
41 required
= True, type = int)
49 # Pull in an existing database if requested.
52 DB
= pickle
.load(open(args
.database
, 'r'))
55 out
= open(args
.database
, 'wb')
57 os
.chdir(args
.repository
)
59 def GetCommits(range, tag
):
60 git
= 'git log --pretty=format:%H ' + range
61 input = os
.popen(git
, 'r')
62 for line
in input.readlines():
63 DB
[line
.strip()] = tag
66 initial
= '1da177e4c3f41524e886b7f1b8a0c1fc7321cac2'
67 DB
[initial
] = 'v2.6.12'
68 GetCommits('1da177e4c3f41524e886b7f1b8a0c1fc7321cac2..v2.6.12', 'v2.6.12')
69 for v
in range(13, 40):
70 GetCommits('v2.6.%d..v2.6.%d' % (v
- 1, v
), 'v2.6.%d' % (v
))
71 GetCommits('v2.6.39..v3.0', 'v3.0')
72 for v
in range(1, 20):
73 GetCommits('v3.%d..v3.%d' % (v
- 1, v
), 'v3.%d' % (v
))
74 GetCommits('v3.19..v4.0', 'v4.0')
75 for v
in range(1, 21):
76 GetCommits('v4.%d..v4.%d' % (v
- 1, v
), 'v4.%d' % (v
))
77 GetCommits('v4.20..v5.0', 'v5.0')
78 for v
in range(1, 20):
79 GetCommits('v5.%d..v5.%d' % (v
- 1, v
), 'v5.%d' % (v
))
80 GetCommits('v5.19..v6.0', 'v6.0')
82 for v
in range(1, int(final
)):
83 GetCommits('v6.%d..v6.%d' % (v
- 1, v
), 'v6.%d' % (v
))
84 GetCommits('v6.%d..' % (final
- 1), 'v6.%d' % (final
))
86 print('\nFound %d commits' % (len(DB
.keys())))