summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2013-08-15 17:04:39 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-08-16 10:44:17 (GMT)
commit2a9d9b6a99253a80d6c5471b6cb99915a2fff887 (patch)
treec148ea7b1f8fbc70c515b27d87950185dbdeab40 /scripts
parentc5d2e9caca2827a6b763b51913e46f2b2c1df129 (diff)
downloadpoky-2a9d9b6a99253a80d6c5471b6cb99915a2fff887.tar.gz
buildhistory-diff: improve command-line handling
Improve command-line argument handling of buildhistory-diff to make it easier to use. * Default buildhistory directory to buildhistory/ under the current directory and require an option to set it (since most users will likely run buildhistory-diff from the build directory and keep BUILDHISTORY_DIR at its default location) * Default from-revision to "build-minus-1" to get the difference from the previous build with no arguments * Allow from/to revisions to be specified by from..to (since git accepts this form). (From OE-Core rev: 5e2be70e89820ffc74208d225fe4414fe5182050) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/buildhistory-diff54
1 files changed, 39 insertions, 15 deletions
diff --git a/scripts/buildhistory-diff b/scripts/buildhistory-diff
index 30c2c08..b82240d 100755
--- a/scripts/buildhistory-diff
+++ b/scripts/buildhistory-diff
@@ -7,6 +7,7 @@
7 7
8import sys 8import sys
9import os 9import os
10import optparse
10from distutils.version import LooseVersion 11from distutils.version import LooseVersion
11 12
12# Ensure PythonGit is installed (buildhistory_analysis needs it) 13# Ensure PythonGit is installed (buildhistory_analysis needs it)
@@ -17,14 +18,30 @@ except ImportError:
17 sys.exit(1) 18 sys.exit(1)
18 19
19def main(): 20def main():
21 parser = optparse.OptionParser(
22 description = "Reports significant differences in the buildhistory repository.",
23 usage = """
24 %prog [options] [from-revision [to-revision]]
25(if not specified, from-revision defaults to build-minus-1, and to-revision defaults to HEAD)""")
26
27 parser.add_option("-p", "--buildhistory-dir",
28 help = "Specify path to buildhistory directory (defaults to buildhistory/ under cwd)",
29 action="store", dest="buildhistory_dir", default='buildhistory/')
30
31 options, args = parser.parse_args(sys.argv)
32
33 if len(args) > 3:
34 sys.stderr.write('Invalid argument(s) specified: %s\n\n' % ' '.join(args[3:]))
35 parser.print_help()
36 sys.exit(1)
37
20 if LooseVersion(git.__version__) < '0.3.1': 38 if LooseVersion(git.__version__) < '0.3.1':
21 sys.stderr.write("Version of GitPython is too old, please install GitPython (python-git) 0.3.1 or later in order to use this script\n") 39 sys.stderr.write("Version of GitPython is too old, please install GitPython (python-git) 0.3.1 or later in order to use this script\n")
22 sys.exit(1) 40 sys.exit(1)
23 41
24 if len(sys.argv) < 3 or '--help' in sys.argv: 42 if not os.path.exists(options.buildhistory_dir):
25 print("Report significant differences in the buildhistory repository") 43 sys.stderr.write('Buildhistory directory "%s" does not exist\n\n' % options.buildhistory_dir)
26 print("Syntax: %s <buildhistory-path> <since-revision> [to-revision]" % os.path.basename(sys.argv[0])) 44 parser.print_help()
27 print("If to-revision is not specified, it defaults to HEAD")
28 sys.exit(1) 45 sys.exit(1)
29 46
30 # Set path to OE lib dir so we can import the buildhistory_analysis module 47 # Set path to OE lib dir so we can import the buildhistory_analysis module
@@ -47,21 +64,28 @@ def main():
47 sys.path[0:0] = [newpath, bitbakepath + '/lib'] 64 sys.path[0:0] = [newpath, bitbakepath + '/lib']
48 import oe.buildhistory_analysis 65 import oe.buildhistory_analysis
49 66
50 buildhistory_dir = sys.argv[1] 67 fromrev = 'build-minus-1'
51 if not os.path.exists(buildhistory_dir): 68 torev = 'HEAD'
52 sys.stderr.write('Specified buildhistory directory "%s" does not exist\n' % buildhistory_dir) 69 if len(args) > 1:
53 sys.exit(1) 70 if len(args) == 2 and '..' in args[1]:
54 71 revs = args[1].split('..')
55 if len(sys.argv) > 3: 72 fromrev = revs[0]
56 torev = sys.argv[3] 73 if revs[1]:
57 else: 74 torev = revs[1]
58 torev = 'HEAD' 75 else:
76 fromrev = args[1]
77 if len(args) > 2:
78 torev = args[2]
59 79
60 import gitdb 80 import gitdb
61 try: 81 try:
62 changes = oe.buildhistory_analysis.process_changes(buildhistory_dir, sys.argv[2], torev) 82 changes = oe.buildhistory_analysis.process_changes(options.buildhistory_dir, fromrev, torev)
63 except gitdb.exc.BadObject as e: 83 except gitdb.exc.BadObject as e:
64 sys.stderr.write('Specified git revision "%s" is not valid\n' % e.args[0]) 84 if len(args) == 1:
85 sys.stderr.write("Unable to find previous build revision in buildhistory repository\n\n")
86 parser.print_help()
87 else:
88 sys.stderr.write('Specified git revision "%s" is not valid\n' % e.args[0])
65 sys.exit(1) 89 sys.exit(1)
66 90
67 for chg in changes: 91 for chg in changes: