chiark / gitweb /
Add --reject option to import
authorCatalin Marinas <catalin.marinas@arm.com>
Fri, 10 Jul 2009 09:28:53 +0000 (10:28 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Fri, 10 Jul 2009 09:28:53 +0000 (10:28 +0100)
This allows a failed import to leave .rej files in the working
directory.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
stgit/commands/imprt.py
stgit/git.py

index 97a6a09d78d55bad5a22867602efc00055427c4a..7a806cce60fd7382848953db6b432fcf7e307100 100644 (file)
@@ -65,6 +65,8 @@ options = [
         short = 'Replace the unapplied patches in the series'),
     opt('-b', '--base', args = [argparse.commit],
         short = 'Use BASE instead of HEAD for file importing'),
+    opt('--reject', action = 'store_true',
+        short = 'leave the rejected hunks in corresponding *.rej files'),
     opt('-e', '--edit', action = 'store_true',
         short = 'Invoke an editor for the patch description'),
     opt('-p', '--showpatch', action = 'store_true',
@@ -147,10 +149,10 @@ def __create_patch(filename, message, author_name, author_email,
     else:
         out.start('Importing patch "%s"' % patch)
         if options.base:
-            git.apply_patch(diff = diff,
-                            base = git_id(crt_series, options.base))
+            base = git_id(crt_series, options.base)
         else:
-            git.apply_patch(diff = diff)
+            base = None
+        git.apply_patch(diff = diff, base = base, reject = options.reject)
         crt_series.refresh_patch(edit = options.edit,
                                  show_patch = options.showpatch,
                                  sign_str = options.sign_str,
index cbdefe8b27a6ac57537b70afa15de591223b1291..268c44b37be012acf76108fff7f909f981068da3 100644 (file)
@@ -818,7 +818,7 @@ def repack():
     GRun('repack', '-a', '-d', '-f').run()
 
 def apply_patch(filename = None, diff = None, base = None,
-                fail_dump = True):
+                fail_dump = True, reject = False):
     """Apply a patch onto the current or given index. There must not
     be any local changes in the tree, otherwise the command fails
     """
@@ -837,8 +837,11 @@ def apply_patch(filename = None, diff = None, base = None,
     else:
         refresh_index()
 
+    cmd = ['apply', '--index']
+    if reject:
+        cmd += ['--reject']
     try:
-        GRun('apply', '--index').raw_input(diff).no_output()
+        GRun(*cmd).raw_input(diff).no_output()
     except GitRunException:
         if base:
             switch(orig_head)