Use the default git colouring scheme rather than specific scripts
[stgit] / stgit / commands / resolved.py
index 011db91..eba778d 100644 (file)
@@ -17,32 +17,31 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 """
 
 import sys, os
-from optparse import OptionParser, make_option
-
+from stgit.argparse import opt
 from stgit.commands.common import *
 from stgit.utils import *
-from stgit import stack, git, basedir
+from stgit import argparse, stack, git, basedir
 from stgit.config import config, file_extensions
-from stgit.gitmergeonefile import interactive_merge
-
-
-help = 'mark a file conflict as solved'
-usage = """%prog [options] [<files...>]
 
+help = 'Mark a file conflict as solved'
+kind = 'wc'
+usage = ['[options] [<files...>]']
+description = """
 Mark a merge conflict as resolved. The conflicts can be seen with the
 'status' command, the corresponding files being prefixed with a
-'C'. This command also removes any <file>.{ancestor,current,patched}
-files."""
-
-directory = DirectoryHasRepository(needs_current_series = False)
-options = [make_option('-a', '--all',
-                       help = 'mark all conflicts as solved',
-                       action = 'store_true'),
-           make_option('-r', '--reset', metavar = '(ancestor|current|patched)',
-                       help = 'reset the file(s) to the given state'),
-           make_option('-i', '--interactive',
-                       help = 'run the interactive merging tool',
-                       action = 'store_true')]
+'C'."""
+
+args = [argparse.conflicting_files]
+options = [
+    opt('-a', '--all', action = 'store_true',
+        short = 'Mark all conflicts as solved'),
+    opt('-r', '--reset', metavar = '(ancestor|current|patched)',
+        args = [argparse.strings('ancestor', 'current', 'patched')],
+        short = 'Reset the file(s) to the given state'),
+    opt('-i', '--interactive', action = 'store_true',
+        short = 'Run the interactive merging tool')]
+
+directory = DirectoryHasRepository(needs_current_series = False, log = False)
 
 def func(parser, options, args):
     """Mark the conflict as resolved
@@ -77,18 +76,7 @@ def func(parser, options, args):
                 raise CmdException, 'No conflicts for "%s"' % filename
 
     # resolved
-    try:
-        for filename in files:
-            if options.interactive:
-                interactive_merge(filename)
-            resolved(filename, options.reset)
-            del conflicts[conflicts.index(filename)]
-    finally:
-        # save or remove the conflicts file. Needs a finally clause to
-        # ensure that already solved conflicts are marked
-        if conflicts == []:
-            os.remove(os.path.join(basedir.get(), 'conflicts'))
-        else:
-            f = file(os.path.join(basedir.get(), 'conflicts'), 'w+')
-            f.writelines([line + '\n' for line in conflicts])
-            f.close()
+    if options.interactive:
+        git.mergetool(files)
+    else:
+        git.resolved(files, options.reset)