aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCatalin Marinas <catalin.marinas@gmail.com>2009-09-16 14:04:26 +0100
committerCatalin Marinas <catalin.marinas@gmail.com>2009-09-16 14:04:26 +0100
commit46cc10370c2dc63640fbd5dbefd9fdf921488098 (patch)
tree70d3271a92269772e5a0860de7867e126d9ed8a1
parentb0bff9328fcd6215093995b93673873016a4bf38 (diff)
downloadstgit-46cc10370c2dc63640fbd5dbefd9fdf921488098.tar.gz
Do not create an empty patch if import failed without --reject
If the import failed, do not leave an empty patch on the stack. If this is required, the --reject option should be passed. The patch also fixes a lowercase typo in the --reject option description. Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
-rw-r--r--stgit/commands/imprt.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/stgit/commands/imprt.py b/stgit/commands/imprt.py
index aa75065..de77635 100644
--- a/stgit/commands/imprt.py
+++ b/stgit/commands/imprt.py
@@ -68,7 +68,7 @@ options = [
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'),
+ short = 'Leave the rejected hunks in corresponding *.rej files'),
opt('-e', '--edit', action = 'store_true',
short = 'Invoke an editor for the patch description'),
opt('-d', '--showdiff', action = 'store_true',
@@ -154,8 +154,13 @@ def __create_patch(filename, message, author_name, author_email,
base = git_id(crt_series, options.base)
else:
base = None
- git.apply_patch(diff = diff, base = base, reject = options.reject,
- strip = options.strip)
+ try:
+ git.apply_patch(diff = diff, base = base, reject = options.reject,
+ strip = options.strip)
+ except git.GitException:
+ if not options.reject:
+ crt_series.delete_patch(patch)
+ raise
crt_series.refresh_patch(edit = options.edit,
show_patch = options.showdiff,
author_date = author_date,