{"thread":{"id":"17181","subject":"[StGit PATCH] Add --file option to pick","startedAt":"2009-01-14T22:59:30Z","lastAt":"2009-01-15T08:26:14Z","messageCount":2,"participants":["Catalin Marinas","Karl Hasselström"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"100505","messageId":"20090114225930.11098.2144.stgit@localhost.localdomain","threadId":"17181","inReplyTo":null,"subject":"[StGit PATCH] Add --file option to pick","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2009-01-14T22:59:30Z","receivedAt":"2009-01-14T22:59:30Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"This allows folding of specific files only.\n\nSigned-off-by: Catalin Marinas <catalin.marinas@gmail.com>\n---\n stgit/commands/pick.py |   12 ++++++++++--\n 1 files changed, 10 insertions(+), 2 deletions(-)\n\ndiff --git a/stgit/commands/pick.py b/stgit/commands/pick.py\nindex ee08c01..b0e9114 100644\n--- a/stgit/commands/pick.py\n+++ b/stgit/commands/pick.py\n@@ -52,6 +52,8 @@ options = [\n         short = 'Fold the commit object into the current patch'),\n     opt('--update', action = 'store_true',\n         short = 'Like fold but only update the current patch files'),\n+    opt('-f', '--files', action = 'append',\n+        short = 'Only fold the given files'),\n     opt('--unapplied', action = 'store_true',\n         short = 'Keep the patch unapplied')]\n \n@@ -83,8 +85,11 @@ def __pick_commit(commit_id, patchname, options):\n         out.start('Folding commit %s' % commit_id)\n \n         # try a direct git apply first\n-        if not git.apply_diff(bottom, top):\n-            git.merge_recursive(bottom, git.get_head(), top)\n+        if not git.apply_diff(bottom, top, files = options.files):\n+            if options.files:\n+                raise CmdException, 'Patch folding failed'\n+            else:\n+                git.merge_recursive(bottom, git.get_head(), top)\n \n         out.done()\n     elif options.update:\n@@ -152,6 +157,9 @@ def func(parser, options, args):\n     if not args:\n         parser.error('incorrect number of arguments')\n \n+    if options.files and not options.fold:\n+        parser.error('--file can only be specified with --fold')\n+\n     if not options.unapplied:\n         check_local_changes()\n         check_conflicts()\n"},{"id":"100550","messageId":"20090115082614.GA24890@diana.vm.bytemark.co.uk","threadId":"17181","inReplyTo":"20090114225930.11098.2144.stgit@localhost.localdomain","subject":"Re: [StGit PATCH] Add --file option to pick","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2009-01-15T08:26:14Z","receivedAt":"2009-01-15T08:26:14Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2009-01-14 22:59:30 +0000, Catalin Marinas wrote:\n\n> +    opt('-f', '--files', action = 'append',\n> +        short = 'Only fold the given files'),\n\nThe long form should probably be \"--file\", since you only list one\nfile for every flag (and since you call it \"--file\" in the last hunk).\nAnd the help text could be something like\n\n  Only fold the given file (for multiple files, use -f more than once)\n\n> +                raise CmdException, 'Patch folding failed'\n\nThis is not important, but I believe the recommended syntax for\nraising exceptions nowadays is\n\n  CmdException('Patch folding failed')\n\nsince that's what'll continue to work in Python 3, or something like\nthat. (I see you already use it in the multi-line case in the other\npatch, where this syntax is clearly the better choice.)\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"}]}