Allow only certain gitk exit codes as valid
[stgit] / stgit / commands / series.py
index 402356c..3c0816e 100644 (file)
@@ -22,6 +22,7 @@ from optparse import OptionParser, make_option
 import stgit.commands.common
 from stgit.commands.common import *
 from stgit.utils import *
+from stgit.out import *
 from stgit import stack, git
 
 
@@ -33,6 +34,7 @@ range. The applied patches are prefixed with a '+', the unapplied ones
 with a '-' and the hidden ones with a '!'. The current patch is
 prefixed with a '>'. Empty patches are prefixed with a '0'."""
 
+directory = DirectoryHasRepository()
 options = [make_option('-b', '--branch',
                        help = 'use BRANCH instead of the default one'),
            make_option('-a', '--all',
@@ -109,6 +111,9 @@ def func(parser, options, args):
     """
     global crt_series
 
+    if options.all and options.short:
+        raise CmdException, 'combining --all and --short is meaningless'
+    
     # current series patches
     if options.invisible:
         applied = unapplied = []
@@ -181,7 +186,7 @@ def func(parser, options, args):
         return
 
     if options.showbranch:
-        branch_str = '@' + crt_series.get_branch()
+        branch_str = '@' + crt_series.get_name()
     else:
         branch_str = ''
 
@@ -189,17 +194,17 @@ def func(parser, options, args):
         if options.missing:
             raise CmdException, '--graphical not supported with --missing'
 
+        gitk_args = []
         if applied:
-            gitk_args = ' %s^..%s' % (git_id(applied[0]), git_id(applied[-1]))
-        else:
-            gitk_args = ''
-
+            gitk_args.append('%s^..%s'
+                             % (git_id(crt_series, applied[0]),
+                                git_id(crt_series, applied[-1])))
         for p in unapplied:
-            patch_id = git_id(p)
-            gitk_args += ' %s^..%s' % (patch_id, patch_id)
+            patch_id = git_id(crt_series, p)
+            gitk_args.append('%s^..%s' % (patch_id, patch_id))
 
-        if os.system('gitk%s' % gitk_args) != 0:
-            raise CmdException, 'gitk execution failed'
+        # discard the exit codes generated by SIGINT, SIGKILL, SIGTERM
+        Run('gitk', *gitk_args).returns([0, -2, -9, -15]).run()
     else:
         max_len = 0
         if len(patches) > 0:
@@ -215,4 +220,4 @@ def func(parser, options, args):
             __print_patch(p, branch_str, '- ', '0 ', max_len, options)
 
         for p in hidden:
-            __print_patch(p, branch_str, '! ', '0 ', max_len, options)
+            __print_patch(p, branch_str, '! ', '! ', max_len, options)