{"thread":{"id":"20979","subject":"[StGit PATCH 4/5] Add the -p option to fold","startedAt":"2009-09-16T21:40:50Z","lastAt":"2009-09-16T21:41:15Z","messageCount":6,"participants":["Catalin Marinas"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"123379","messageId":"20090916214049.6622.44662.stgit@toshiba-laptop","threadId":"20979","inReplyTo":null,"subject":"[StGit PATCH 0/5] More UI clean-up","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2009-09-16T21:40:50Z","receivedAt":"2009-09-16T21:40:50Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"The series adds makes the fold and import options consistent regarding\nthe -p and --reject options. The autosigning of new patches was extended\nto the import command as well.\n\n---\n\nCatalin Marinas (5):\n      Remove the 'fail_dump' argument to git.apply_patch()\n      Add the --reject option to fold\n      Do not create an empty patch if import failed without --reject\n      Add the -p option to fold\n      Autosign imported patches\n\n\n stgit/commands/fold.py  |   15 +++++++++++----\n stgit/commands/imprt.py |   18 +++++++++++++-----\n stgit/git.py            |   11 ++---------\n 3 files changed, 26 insertions(+), 18 deletions(-)\n\n-- \nCatalin\n"},{"id":"123377","messageId":"20090916214055.6622.96912.stgit@toshiba-laptop","threadId":"20979","inReplyTo":"20090916214049.6622.44662.stgit@toshiba-laptop","subject":"[StGit PATCH 1/5] Remove the 'fail_dump' argument to git.apply_patch()","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2009-09-16T21:40:55Z","receivedAt":"2009-09-16T21:40:55Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"Since we have a 'reject' argument, there is no need for the failed diff\nto be dumped.\n\nSigned-off-by: Catalin Marinas <catalin.marinas@gmail.com>\n---\n stgit/git.py |   11 ++---------\n 1 files changed, 2 insertions(+), 9 deletions(-)\n\ndiff --git a/stgit/git.py b/stgit/git.py\nindex 012e282..97b1e96 100644\n--- a/stgit/git.py\n+++ b/stgit/git.py\n@@ -818,7 +818,7 @@ def repack():\n     GRun('repack', '-a', '-d', '-f').run()\n \n def apply_patch(filename = None, diff = None, base = None,\n-                fail_dump = True, reject = False, strip = None):\n+                reject = False, strip = None):\n     \"\"\"Apply a patch onto the current or given index. There must not\n     be any local changes in the tree, otherwise the command fails\n     \"\"\"\n@@ -847,14 +847,7 @@ def apply_patch(filename = None, diff = None, base = None,\n     except GitRunException:\n         if base:\n             switch(orig_head)\n-        if fail_dump:\n-            # write the failed diff to a file\n-            f = file('.stgit-failed.patch', 'w+')\n-            f.write(diff)\n-            f.close()\n-            out.warn('Diff written to the .stgit-failed.patch file')\n-\n-        raise\n+        raise GitException('Diff does not apply cleanly')\n \n     if base:\n         top = commit(message = 'temporary commit used for applying a patch',\n"},{"id":"123380","messageId":"20090916214100.6622.90078.stgit@toshiba-laptop","threadId":"20979","inReplyTo":"20090916214049.6622.44662.stgit@toshiba-laptop","subject":"[StGit PATCH 2/5] Add the --reject option to fold","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2009-09-16T21:41:00Z","receivedAt":"2009-09-16T21:41:00Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>\n---\n stgit/commands/fold.py |   11 +++++++----\n 1 files changed, 7 insertions(+), 4 deletions(-)\n\ndiff --git a/stgit/commands/fold.py b/stgit/commands/fold.py\nindex 66a2dd9..28e824c 100644\n--- a/stgit/commands/fold.py\n+++ b/stgit/commands/fold.py\n@@ -38,7 +38,9 @@ options = [\n     opt('-t', '--threeway', action = 'store_true',\n         short = 'Perform a three-way merge with the current patch'),\n     opt('-b', '--base', args = [argparse.commit],\n-        short = 'Use BASE instead of HEAD applying the patch')]\n+        short = 'Use BASE instead of HEAD when applying the patch'),\n+    opt('--reject', action = 'store_true',\n+        short = 'Leave the rejected hunks in corresponding *.rej files')]\n \n directory = DirectoryHasRepository(log = True)\n \n@@ -72,11 +74,12 @@ def func(parser, options, args):\n     if options.threeway:\n         crt_patch = crt_series.get_patch(current)\n         bottom = crt_patch.get_bottom()\n-        git.apply_patch(filename = filename, base = bottom)\n+        git.apply_patch(filename = filename, base = bottom,\n+                        reject = options.reject)\n     elif options.base:\n-        git.apply_patch(filename = filename,\n+        git.apply_patch(filename = filename, reject = options.reject,\n                         base = git_id(crt_series, options.base))\n     else:\n-        git.apply_patch(filename = filename)\n+        git.apply_patch(filename = filename, reject = options.reject)\n \n     out.done()\n"},{"id":"123376","messageId":"20090916214105.6622.24307.stgit@toshiba-laptop","threadId":"20979","inReplyTo":"20090916214049.6622.44662.stgit@toshiba-laptop","subject":"[StGit PATCH 3/5] Do not create an empty patch if import failed without --reject","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2009-09-16T21:41:05Z","receivedAt":"2009-09-16T21:41:05Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"If the import failed, do not leave an empty patch on the stack. If this\nis required, the --reject option should be passed. The patch also fixes\na lowercase typo in the --reject option description.\n\nSigned-off-by: Catalin Marinas <catalin.marinas@gmail.com>\n---\n stgit/commands/imprt.py |   11 ++++++++---\n 1 files changed, 8 insertions(+), 3 deletions(-)\n\ndiff --git a/stgit/commands/imprt.py b/stgit/commands/imprt.py\nindex aa75065..de77635 100644\n--- a/stgit/commands/imprt.py\n+++ b/stgit/commands/imprt.py\n@@ -68,7 +68,7 @@ options = [\n     opt('-b', '--base', args = [argparse.commit],\n         short = 'Use BASE instead of HEAD for file importing'),\n     opt('--reject', action = 'store_true',\n-        short = 'leave the rejected hunks in corresponding *.rej files'),\n+        short = 'Leave the rejected hunks in corresponding *.rej files'),\n     opt('-e', '--edit', action = 'store_true',\n         short = 'Invoke an editor for the patch description'),\n     opt('-d', '--showdiff', action = 'store_true',\n@@ -154,8 +154,13 @@ def __create_patch(filename, message, author_name, author_email,\n             base = git_id(crt_series, options.base)\n         else:\n             base = None\n-        git.apply_patch(diff = diff, base = base, reject = options.reject,\n-                        strip = options.strip)\n+        try:\n+            git.apply_patch(diff = diff, base = base, reject = options.reject,\n+                            strip = options.strip)\n+        except git.GitException:\n+            if not options.reject:\n+                crt_series.delete_patch(patch)\n+            raise\n         crt_series.refresh_patch(edit = options.edit,\n                                  show_patch = options.showdiff,\n                                  author_date = author_date,\n"},{"id":"123375","messageId":"20090916214110.6622.12748.stgit@toshiba-laptop","threadId":"20979","inReplyTo":"20090916214049.6622.44662.stgit@toshiba-laptop","subject":"[StGit PATCH 4/5] Add the -p option to fold","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2009-09-16T21:41:10Z","receivedAt":"2009-09-16T21:41:10Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"This option was added to import, so it makes sense for fold to have it\nas well.\n\nSigned-off-by: Catalin Marinas <catalin.marinas@gmail.com>\n---\n stgit/commands/fold.py |    8 ++++++--\n 1 files changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/stgit/commands/fold.py b/stgit/commands/fold.py\nindex 28e824c..ce0459e 100644\n--- a/stgit/commands/fold.py\n+++ b/stgit/commands/fold.py\n@@ -39,6 +39,8 @@ options = [\n         short = 'Perform a three-way merge with the current patch'),\n     opt('-b', '--base', args = [argparse.commit],\n         short = 'Use BASE instead of HEAD when applying the patch'),\n+    opt('-p', '--strip', type = 'int', metavar = 'N',\n+        short = 'Remove N leading slashes from diff paths (default 1)'),\n     opt('--reject', action = 'store_true',\n         short = 'Leave the rejected hunks in corresponding *.rej files')]\n \n@@ -75,11 +77,13 @@ def func(parser, options, args):\n         crt_patch = crt_series.get_patch(current)\n         bottom = crt_patch.get_bottom()\n         git.apply_patch(filename = filename, base = bottom,\n-                        reject = options.reject)\n+                        strip = options.strip, reject = options.reject)\n     elif options.base:\n         git.apply_patch(filename = filename, reject = options.reject,\n+                        strip = options.strip,\n                         base = git_id(crt_series, options.base))\n     else:\n-        git.apply_patch(filename = filename, reject = options.reject)\n+        git.apply_patch(filename = filename, strip = options.strip,\n+                        reject = options.reject)\n \n     out.done()\n"},{"id":"123378","messageId":"20090916214115.6622.76531.stgit@toshiba-laptop","threadId":"20979","inReplyTo":"20090916214049.6622.44662.stgit@toshiba-laptop","subject":"[StGit PATCH 5/5] Autosign imported patches","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2009-09-16T21:41:15Z","receivedAt":"2009-09-16T21:41:15Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"If stgit.autosign configuration is set, allow the automatic signing of\nthe imported patches, similar to the 'new' command.\n\nSigned-off-by: Catalin Marinas <catalin.marinas@gmail.com>\n---\n stgit/commands/imprt.py |    7 +++++--\n 1 files changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/stgit/commands/imprt.py b/stgit/commands/imprt.py\nindex de77635..0f78490 100644\n--- a/stgit/commands/imprt.py\n+++ b/stgit/commands/imprt.py\n@@ -141,6 +141,10 @@ def __create_patch(filename, message, author_name, author_email,\n     if options.authdate:\n         author_date = options.authdate\n \n+    sign_str = options.sign_str\n+    if not options.sign_str:\n+        sign_str = config.get('stgit.autosign')\n+\n     crt_series.new_patch(patch, message = message, can_edit = False,\n                          author_name = author_name,\n                          author_email = author_email,\n@@ -164,8 +168,7 @@ def __create_patch(filename, message, author_name, author_email,\n         crt_series.refresh_patch(edit = options.edit,\n                                  show_patch = options.showdiff,\n                                  author_date = author_date,\n-                                 sign_str = options.sign_str,\n-                                 backup = False)\n+                                 sign_str = sign_str, backup = False)\n         out.done()\n \n def __mkpatchname(name, suffix):\n"}]}