Add the --replace option to import
authorCatalin Marinas <catalin.marinas@gmail.com>
Tue, 6 Jun 2006 18:15:13 +0000 (19:15 +0100)
committerCatalin Marinas <catalin.marinas@gmail.com>
Tue, 6 Jun 2006 18:15:13 +0000 (19:15 +0100)
By default, import fails if an existing patch is found with the same name.
With this option, import replaces the existing patch if it is unapplied.

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

index fcbe9d3..cfbf0de 100644 (file)
@@ -50,6 +50,9 @@ options = [make_option('-m', '--mail',
            make_option('-i', '--ignore',
                        help = 'ignore the applied patches in the series',
                        action = 'store_true'),
+           make_option('--replace',
+                       help = 'replace the unapplied patches in the series',
+                       action = 'store_true'),
            make_option('-b', '--base',
                        help = 'use BASE instead of HEAD for file importing'),
            make_option('-e', '--edit',
@@ -248,6 +251,9 @@ def __import_patch(patch, filename, options):
     if options.commemail:
         committer_email = options.commemail
 
+    if options.replace and patch in crt_series.get_unapplied():
+        crt_series.delete_patch(patch)
+
     crt_series.new_patch(patch, message = message, can_edit = False,
                          author_name = author_name,
                          author_email = author_email,