chiark / gitweb /
Merge branch 'stable'
[stgit] / stgit / commands / patches.py
index b3defb6cc05debdfa080d0b831f8cf67fe84a192..54fac21306d7dfaef6bd630058588421f3fb7648 100644 (file)
@@ -16,28 +16,30 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 """
 
 import sys, os
 """
 
 import sys, os
-from optparse import OptionParser, make_option
 from pydoc import pager
 from pydoc import pager
-
+from stgit.argparse import opt
 from stgit.commands.common import *
 from stgit.utils import *
 from stgit.out import *
 from stgit.commands.common import *
 from stgit.utils import *
 from stgit.out import *
-from stgit import stack, git
-
-
-help = 'show the applied patches modifying a file'
-usage = """%prog [options] [<files...>]
+from stgit import argparse, stack, git
 
 
+help = 'Show the applied patches modifying a file'
+kind = 'stack'
+usage = ['[options] [<files or dirs>]']
+description = """
 Show the applied patches modifying the given files. Without arguments,
 it shows the patches affected by the local tree modifications. The
 '--diff' option also lists the patch log and the diff for the given
 files."""
 
 Show the applied patches modifying the given files. Without arguments,
 it shows the patches affected by the local tree modifications. The
 '--diff' option also lists the patch log and the diff for the given
 files."""
 
-options = [make_option('-d', '--diff',
-                       help = 'show the diff for the given files',
-                       action = 'store_true'),
-           make_option('-b', '--branch',
-                       help = 'use BRANCH instead of the default one')]
+args = [argparse.known_files]
+options = [
+    opt('-d', '--diff', action = 'store_true',
+        short = 'Show the diff for the given files'),
+    opt('-b', '--branch', args = [argparse.stg_branches],
+        short = 'Use BRANCH instead of the default branch')]
+
+directory = DirectoryHasRepository(log = False)
 
 diff_tmpl = \
           '-------------------------------------------------------------------------------\n' \
 
 diff_tmpl = \
           '-------------------------------------------------------------------------------\n' \
@@ -51,9 +53,11 @@ def func(parser, options, args):
     """Show the patches modifying a file
     """
     if not args:
     """Show the patches modifying a file
     """
     if not args:
-        files = [stat[1] for stat in git.tree_status(verbose = True)]
+        files = [path for (stat,path) in git.tree_status(verbose = True)]
+        # git.tree_status returns absolute paths
     else:
     else:
-        files = args
+        files = git.ls_files(args)
+    directory.cd_to_topdir()
 
     if not files:
         raise CmdException, 'No files specified or no local changes'
 
     if not files:
         raise CmdException, 'No files specified or no local changes'