summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2013-08-15 12:48:11 -0600
committerJonathan Corbet <corbet@lwn.net>2013-08-15 12:48:11 -0600
commit0702fb7b56e55d99b9c5d7daeaf1ba475bfab83e (patch)
tree7241720fa0921c1981535b84620a37b21c61e42e
parent5552e8a66d40120793095adb74961a9a49da7e7d (diff)
A hacky utility for making the committags.db database
-rwxr-xr-xinittags79
1 files changed, 79 insertions, 0 deletions
diff --git a/inittags b/inittags
new file mode 100755
index 0000000..4e66b3e
--- /dev/null
+++ b/inittags
@@ -0,0 +1,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', '2.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()