chiark / gitweb /
Make StGIT aware of the STGIT_DEBUG_LEVEL environment variable
authorCatalin Marinas <catalin.marinas@gmail.com>
Tue, 13 Feb 2007 22:26:36 +0000 (22:26 +0000)
committerCatalin Marinas <catalin.marinas@gmail.com>
Tue, 13 Feb 2007 22:26:36 +0000 (22:26 +0000)
For now, setting this environment variable will make StGIT dump the
backtrace in case of a failure.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
stgit/main.py
t/test-lib.sh

index 49089e6e61193c0713614fb0dd507c20243b20f5..933f12717cb61e0ba7bfbd762a0faa537a069bb8 100644 (file)
@@ -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)
 
index 3274b84f08d7eb1808fd5f9229a07c55838c9316..0ac7e7c4c80cd579eb3ecd23a851e109ba8abe01 100755 (executable)
@@ -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 ;;