Reduce number of backslashes by using raw strings
[stgit] / stgit / commands / show.py
index a270efd..72d1be3 100644 (file)
@@ -30,36 +30,45 @@ Show the commit log and the diff corresponding to the given
 patches. The output is similar to that generated by the 'git show'
 command."""
 
-options = [make_option('-a', '--applied',
+directory = DirectoryHasRepository()
+options = [make_option('-b', '--branch',
+                       help = 'use BRANCH instead of the default one'),
+           make_option('-a', '--applied',
                        help = 'show the applied patches',
                        action = 'store_true'),
            make_option('-u', '--unapplied',
                        help = 'show the unapplied patches',
-                       action = 'store_true')]
+                       action = 'store_true'),
+           make_option('-O', '--show-opts',
+                       help = 'options to pass to "git show"')]
 
 
 def func(parser, options, args):
     """Show commit log and diff
     """
-    applied = crt_series.get_applied()
-    unapplied = crt_series.get_unapplied()
-
     if options.applied:
-        patches = applied
+        patches = crt_series.get_applied()
     elif options.unapplied:
-        patches = unapplied
+        patches = crt_series.get_unapplied()
     elif len(args) == 0:
         patches = ['HEAD']
     else:
-        if len(args) == 1 and args[0].find('..') == -1 \
-               and not crt_series.patch_exists(args[0]):
-            # it might be just a commit id
+        if len(args) == 1 and args[0].find('..') == -1:
+            # single patch or commit id
             patches = args
         else:
-            patches = parse_patches(args, applied + unapplied, len(applied))
+            applied = crt_series.get_applied()
+            unapplied = crt_series.get_unapplied()
+            patches = parse_patches(args, applied + unapplied + \
+                                    crt_series.get_hidden(), len(applied))
+
+    if options.show_opts:
+        show_flags = options.show_opts.split()
+    else:
+        show_flags = []
 
-    commit_ids = [git_id(patch) for patch in patches]
-    commit_str = '\n'.join([git.pretty_commit(commit_id)
+    commit_ids = [git_id(crt_series, patch) for patch in patches]
+    commit_str = '\n'.join([git.pretty_commit(commit_id, flags = show_flags)
                             for commit_id in commit_ids])
     if commit_str:
         pager(commit_str)