summaryrefslogtreecommitdiffstats
path: root/scripts/buildhistory-diff
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2013-05-09 15:57:47 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-05-10 10:37:16 (GMT)
commit68f441e303f9a1aa37f6d4606a9fe5a94998880f (patch)
treecd64c836d44672a5b414ab39d6b3f96bf945ac2a /scripts/buildhistory-diff
parent843e422879eb963afb0aa646ef656e94d6aa484f (diff)
downloadpoky-68f441e303f9a1aa37f6d4606a9fe5a94998880f.tar.gz
buildhistory-diff: improve bad command-line argument handling
* Check for existence of specified buildhistory directory and show a proper error message if it doesn't * Show an error message instead of a traceback with a mangled revision if one of the specified git revisions is invalid * Show usage information if --help is specified * Write error messages to stderr Fixes [YOCTO #4313]. (From OE-Core rev: 329edb52e9c23c0956b849a660accf39d44f9d9f) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/buildhistory-diff')
-rwxr-xr-xscripts/buildhistory-diff22
1 files changed, 17 insertions, 5 deletions
diff --git a/scripts/buildhistory-diff b/scripts/buildhistory-diff
index 8493da4..30c2c08 100755
--- a/scripts/buildhistory-diff
+++ b/scripts/buildhistory-diff
@@ -2,7 +2,7 @@
2 2
3# Report significant differences in the buildhistory repository since a specific revision 3# Report significant differences in the buildhistory repository since a specific revision
4# 4#
5# Copyright (C) 2012 Intel Corporation 5# Copyright (C) 2013 Intel Corporation
6# Author: Paul Eggleton <paul.eggleton@linux.intel.com> 6# Author: Paul Eggleton <paul.eggleton@linux.intel.com>
7 7
8import sys 8import sys
@@ -18,10 +18,10 @@ except ImportError:
18 18
19def main(): 19def main():
20 if LooseVersion(git.__version__) < '0.3.1': 20 if LooseVersion(git.__version__) < '0.3.1':
21 print("Version of GitPython is too old, please install GitPython (python-git) 0.3.1 or later in order to use this script") 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")
22 sys.exit(1) 22 sys.exit(1)
23 23
24 if (len(sys.argv) < 3): 24 if len(sys.argv) < 3 or '--help' in sys.argv:
25 print("Report significant differences in the buildhistory repository") 25 print("Report significant differences in the buildhistory repository")
26 print("Syntax: %s <buildhistory-path> <since-revision> [to-revision]" % os.path.basename(sys.argv[0])) 26 print("Syntax: %s <buildhistory-path> <since-revision> [to-revision]" % os.path.basename(sys.argv[0]))
27 print("If to-revision is not specified, it defaults to HEAD") 27 print("If to-revision is not specified, it defaults to HEAD")
@@ -41,17 +41,29 @@ def main():
41 bitbakepath = os.path.abspath(os.path.join(pth, '..')) 41 bitbakepath = os.path.abspath(os.path.join(pth, '..'))
42 break 42 break
43 if not bitbakepath: 43 if not bitbakepath:
44 print("Unable to find bitbake by searching parent directory of this script or PATH") 44 sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n")
45 sys.exit(1) 45 sys.exit(1)
46 46
47 sys.path[0:0] = [newpath, bitbakepath + '/lib'] 47 sys.path[0:0] = [newpath, bitbakepath + '/lib']
48 import oe.buildhistory_analysis 48 import oe.buildhistory_analysis
49 49
50 buildhistory_dir = sys.argv[1]
51 if not os.path.exists(buildhistory_dir):
52 sys.stderr.write('Specified buildhistory directory "%s" does not exist\n' % buildhistory_dir)
53 sys.exit(1)
54
50 if len(sys.argv) > 3: 55 if len(sys.argv) > 3:
51 torev = sys.argv[3] 56 torev = sys.argv[3]
52 else: 57 else:
53 torev = 'HEAD' 58 torev = 'HEAD'
54 changes = oe.buildhistory_analysis.process_changes(sys.argv[1], sys.argv[2], torev) 59
60 import gitdb
61 try:
62 changes = oe.buildhistory_analysis.process_changes(buildhistory_dir, sys.argv[2], torev)
63 except gitdb.exc.BadObject as e:
64 sys.stderr.write('Specified git revision "%s" is not valid\n' % e.args[0])
65 sys.exit(1)
66
55 for chg in changes: 67 for chg in changes:
56 print('%s' % chg) 68 print('%s' % chg)
57 69