From b2017c38acfed9c26ec5bbcb2b23784ca0a15cc8 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Tue, 13 Feb 2007 22:26:36 +0000 Subject: [PATCH] Make StGIT aware of the STGIT_DEBUG_LEVEL environment variable Organization: Straylight/Edgeware From: Catalin Marinas For now, setting this environment variable will make StGIT dump the backtrace in case of a failure. Signed-off-by: Catalin Marinas --- stgit/main.py | 13 ++++++++++++- t/test-lib.sh | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/stgit/main.py b/stgit/main.py index 49089e6..933f127 100644 --- a/stgit/main.py +++ b/stgit/main.py @@ -257,6 +257,14 @@ def main(): from stgit.commands.common import CmdException from stgit.gitmergeonefile import GitMergeException + try: + debug_level = int(os.environ['STGIT_DEBUG_LEVEL']) + except KeyError: + debug_level = 0 + except ValueError: + print >> sys.stderr, 'Invalid STGIT_DEBUG_LEVEL environment variable' + sys.exit(1) + try: config_setup() @@ -273,7 +281,10 @@ def main(): except (IOError, ParsingError, NoSectionError, CmdException, StackException, GitException, GitMergeException), err: print >> sys.stderr, '%s %s: %s' % (prog, cmd, err) - sys.exit(2) + if debug_level: + raise + else: + sys.exit(2) except KeyboardInterrupt: sys.exit(1) diff --git a/t/test-lib.sh b/t/test-lib.sh index 3274b84..0ac7e7c 100755 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -63,6 +63,7 @@ do echo "$test_description" exit 0 ;; -v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose) + export STGIT_DEBUG_LEVEL="-1" verbose=t; shift ;; *) break ;; -- [mdw]