{"thread":{"id":"12160","subject":"[StGit PATCH] Allow renaming of the top-most branch by just calling stg rename <new-patch-name>","startedAt":"2008-02-17T21:03:55Z","lastAt":"2008-02-23T07:45:52Z","messageCount":10,"participants":["Onno Kortmann","Karl Hasselström"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"69040","messageId":"200802172203.55533.onno@gmx.net","threadId":"12160","inReplyTo":null,"subject":"[StGit PATCH] Allow renaming of the top-most branch by just calling stg rename <new-patch-name>","fromName":"Onno Kortmann","fromEmail":"onno@gmx.net","sentAt":"2008-02-17T21:03:55Z","receivedAt":"2008-02-17T21:03:55Z","isPatch":true,"sender":{"key":"onno@gmx.net","avatar":"https://avatars.githubusercontent.com/u/91150?v=4"},"body":"instead of stg rename <old> <new>.\nThis is for example helpful for those people who always have a typo or two in \ntheir\npatch names.\n---\n\n stgit/commands/rename.py |   20 +++++++++++++++-----\n 1 files changed, 15 insertions(+), 5 deletions(-)\n\ndiff --git a/stgit/commands/rename.py b/stgit/commands/rename.py\nindex e2b0fa4..acdf962 100644\n--- a/stgit/commands/rename.py\n+++ b/stgit/commands/rename.py\n@@ -25,9 +25,10 @@ from stgit import stack, git\n \n \n help = 'rename a patch in the series'\n-usage = \"\"\"%prog [options] <oldpatch> <newpatch>\n+usage = \"\"\"%prog [options] [oldpatch] <newpatch>\n \n-Rename <oldpatch> into <newpatch> in a series.\"\"\"\n+Rename <oldpatch> into <newpatch> in a series. If <oldpatch> is not given, \nthe\n+top-most patch will be renamed. \"\"\"\n \n directory = DirectoryHasRepository()\n options = [make_option('-b', '--branch',\n@@ -37,9 +38,18 @@ options = [make_option('-b', '--branch',\n def func(parser, options, args):\n     \"\"\"Rename a patch in the series\n     \"\"\"\n-    if len(args) != 2:\n-        parser.error('incorrect number of arguments')\n+    crt=crt_series.get_current()\n+\n+    if len(args) == 2:\n+        out.start('Renaming patch \"%s\" to \"%s\"' % (args[0], args[1]))\n+\n+    elif len(args) == 1:\n+        if not crt:\n+            raise CmdException, \"No applied top patch to rename exists.\"\n+        args=[crt]+args\n+        out.start('Renaming top-most patch \"%s\" to \"%s\"' % (args[0], \nargs[1]))\n+    \n+    else: parser.error('incorrect number of arguments')\n \n-    out.start('Renaming patch \"%s\" to \"%s\"' % (args[0], args[1]))\n     crt_series.rename_patch(args[0], args[1])\n     out.done()\n"},{"id":"69147","messageId":"20080218140005.GA18668@diana.vm.bytemark.co.uk","threadId":"12160","inReplyTo":"200802172203.55533.onno@gmx.net","subject":"Re: [StGit PATCH] Allow renaming of the top-most branch by just calling stg rename <new-patch-name>","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2008-02-18T14:00:05Z","receivedAt":"2008-02-18T14:00:05Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"This is a good idea, I think.\n\nOn 2008-02-17 22:03:55 +0100, Onno Kortmann wrote:\n\n> instead of stg rename <old> <new>. This is for example helpful for\n> those people who always have a typo or two in their patch names.\n\nPlease follow the commit message conventions. That is, first one short\nsummary line, then a blank line and the rest of the commit message.\nAnd a sign-off.\n\n(Read git's Documentation/SubmittingPatches if you want the details.)\n\n> +        args=[crt]+args\n> +        out.start('Renaming top-most patch \"%s\" to \"%s\"' % (args[0], \n> args[1]))\n\nPlease consider storing the patch names in two suitably named\nvariables, like this:\n\n  if len(args) == 1:\n     old, [new] = crt, args\n  elif len(args) == 2:\n     old, new = args\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"69517","messageId":"200802212230.56646.onno@gmx.net","threadId":"12160","inReplyTo":"20080218140005.GA18668@diana.vm.bytemark.co.uk","subject":"Re: [StGit PATCH] Allow renaming of the top-most branch by just calling stg rename <new-patch-name>","fromName":"Onno Kortmann","fromEmail":"onno@gmx.net","sentAt":"2008-02-21T21:30:56Z","receivedAt":"2008-02-21T21:30:56Z","isPatch":true,"sender":{"key":"onno@gmx.net","avatar":"https://avatars.githubusercontent.com/u/91150?v=4"},"body":"Hi,\n> > instead of stg rename <old> <new>. This is for example helpful for\n> > those people who always have a typo or two in their patch names.\n> \n> Please follow the commit message conventions. That is, first one short\n> summary line, then a blank line and the rest of the commit message.\n> And a sign-off.\n\nOk, I tried to do this, I'm not used at all to sending patches with (st)git :-)\nThanks for the pointer and the assistance. Hopefully, --refid works as I \nunderstand it and the new patches appear in this thread.\n \n> Please consider storing the patch names in two suitably named\n> variables, like this:\nI fixed that one, too.\n\nI'll send out another patch, a test case for the stg rename command.\n\nGreetings,\n\nOnno\n"},{"id":"69521","messageId":"200802212242.51866.onno@gmx.net","threadId":"12160","inReplyTo":"20080218140005.GA18668@diana.vm.bytemark.co.uk","subject":"[PATCH 1/2] Simple rename of top-most patch","fromName":"Onno Kortmann","fromEmail":"onno@gmx.net","sentAt":"2008-02-21T21:42:51Z","receivedAt":"2008-02-21T21:42:51Z","isPatch":true,"sender":{"key":"onno@gmx.net","avatar":"https://avatars.githubusercontent.com/u/91150?v=4"},"body":"Allow renaming of the top-most patch just by calling stg rename <new-patch-name>,\ninstead of stg rename <old> <new>. This is for example helpful for those people who\nalways have a typo or two in their patch names.\n\nSigned-off-by: Onno Kortmann <onno@gmx.net>\n---\n\n stgit/commands/rename.py |   23 ++++++++++++++++-------\n 1 files changed, 16 insertions(+), 7 deletions(-)\n\ndiff --git a/stgit/commands/rename.py b/stgit/commands/rename.py\nindex e2b0fa4..c687455 100644\n--- a/stgit/commands/rename.py\n+++ b/stgit/commands/rename.py\n@@ -25,9 +25,10 @@ from stgit import stack, git\n \n \n help = 'rename a patch in the series'\n-usage = \"\"\"%prog [options] <oldpatch> <newpatch>\n+usage = \"\"\"%prog [options] [oldpatch] <newpatch>\n \n-Rename <oldpatch> into <newpatch> in a series.\"\"\"\n+Rename <oldpatch> into <newpatch> in a series. If <oldpatch> is not given, the\n+top-most patch will be renamed. \"\"\"\n \n directory = DirectoryHasRepository()\n options = [make_option('-b', '--branch',\n@@ -37,9 +38,17 @@ options = [make_option('-b', '--branch',\n def func(parser, options, args):\n     \"\"\"Rename a patch in the series\n     \"\"\"\n-    if len(args) != 2:\n-        parser.error('incorrect number of arguments')\n-\n-    out.start('Renaming patch \"%s\" to \"%s\"' % (args[0], args[1]))\n-    crt_series.rename_patch(args[0], args[1])\n+    crt=crt_series.get_current()\n+\n+    if len(args) == 2:\n+        old, new=args\n+    elif len(args) == 1:\n+        if not crt:\n+            raise CmdException, \"No applied top patch to rename exists.\"\n+        old, [new]=crt, args\n+    else: parser.error('incorrect number of arguments')\n+\n+    out.start('Renaming patch \"%s\" to \"%s\"' % (old, new))\n+    crt_series.rename_patch(old, new)\n+    \n     out.done()\n"},{"id":"69522","messageId":"200802212243.18922.onno@gmx.net","threadId":"12160","inReplyTo":"20080218140005.GA18668@diana.vm.bytemark.co.uk","subject":"[PATCH 2/2] Test the 'stg rename' command","fromName":"Onno Kortmann","fromEmail":"onno@gmx.net","sentAt":"2008-02-21T21:43:18Z","receivedAt":"2008-02-21T21:43:18Z","isPatch":true,"sender":{"key":"onno@gmx.net","avatar":"https://avatars.githubusercontent.com/u/91150?v=4"},"body":"This just tests the few basic cases of the stg rename command.\n\nSigned-off-by: Onno Kortmann <onno@gmx.net>\n---\n\n t/t2900-rename.sh |   47 +++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 47 insertions(+), 0 deletions(-)\n create mode 100755 t/t2900-rename.sh\n\ndiff --git a/t/t2900-rename.sh b/t/t2900-rename.sh\nnew file mode 100755\nindex 0000000..a8f8f0b\n--- /dev/null\n+++ b/t/t2900-rename.sh\n@@ -0,0 +1,47 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2008 Onno Kortmann\n+# Parts taken from the other test scripts\n+# in this directory.\n+#\n+\n+test_description='stg rename test\n+\n+Tests some parts of the stg rename command.'\n+\n+. ./test-lib.sh\n+stg init\n+\n+test_expect_success 'Rename in empty' '\n+   ! stg rename foo\n+'\n+\n+test_expect_success 'Rename single top-most' '\n+   stg new -m foo\n+   stg rename bar\n+'\n+# bar\n+\n+test_expect_success 'Rename non-existing' '\n+   ! stg rename neithersuchpatch norsuchpatch\n+'\n+\n+test_expect_success 'Rename with two arguments' '\n+   stg new -m baz\n+   stg rename bar foo\n+'\n+# foo,baz\n+\n+test_expect_success 'Rename to existing name' '\n+   ! stg rename foo baz\n+'\n+\n+test_expect_success 'Rename to same name' '\n+   ! stg rename foo foo\n+'\n+\n+test_expect_success 'Rename top-most when others exist' '\n+   stg rename bar\n+'\n+\n+test_done\n"},{"id":"69557","messageId":"20080222073811.GB6630@diana.vm.bytemark.co.uk","threadId":"12160","inReplyTo":"200802212230.56646.onno@gmx.net","subject":"Re: [StGit PATCH] Allow renaming of the top-most branch by just calling stg rename <new-patch-name>","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2008-02-22T07:38:11Z","receivedAt":"2008-02-22T07:38:11Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2008-02-21 22:30:56 +0100, Onno Kortmann wrote:\n\n> Ok, I tried to do this, I'm not used at all to sending patches with\n> (st)git :-) Thanks for the pointer and the assistance.\n\nNo problem. Thanks for writing the patches!\n\n> Hopefully, --refid works as I understand it and the new patches\n> appear in this thread.\n\nMailing patches to yourself is a good way to try things out if you're\nnot sure they're going to work (but you seem to have had no problems\nwith it).\n\n> I'll send out another patch, a test case for the stg rename command.\n\nThanks, I'll pick both of them up, probably tomorrow (unless Catalin\ndoes so first).\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"69560","messageId":"20080222074455.GC6630@diana.vm.bytemark.co.uk","threadId":"12160","inReplyTo":"200802212242.51866.onno@gmx.net","subject":"Re: [PATCH 1/2] Simple rename of top-most patch","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2008-02-22T07:44:55Z","receivedAt":"2008-02-22T07:44:55Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2008-02-21 22:42:51 +0100, Onno Kortmann wrote:\n\n> +    if len(args) == 2:\n> +        old, new=args\n> +    elif len(args) == 1:\n> +        if not crt:\n> +            raise CmdException, \"No applied top patch to rename exists.\"\n> +        old, [new]=crt, args\n\nI think the style throughout StGit is to have spaces arond operators.\nNo biggie, though -- I'll fix it up.\n\n> +    else: parser.error('incorrect number of arguments')\n\nIt looks strange without a line break here, especially since there are\nline breaks in the if and elif branches. I'll fix this too if you\ndon't mind.\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"69559","messageId":"20080222074854.GD6630@diana.vm.bytemark.co.uk","threadId":"12160","inReplyTo":"200802212243.18922.onno@gmx.net","subject":"Re: [PATCH 2/2] Test the 'stg rename' command","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2008-02-22T07:48:54Z","receivedAt":"2008-02-22T07:48:54Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2008-02-21 22:43:18 +0100, Onno Kortmann wrote:\n\n> +test_expect_success 'Rename with two arguments' '\n> +   stg new -m baz\n> +   stg rename bar foo\n> +'\n\nYou want \"&&\" at the end of every line but the last one, otherwise\nerrors in any line but the last won't be caught. I'll add that, if you\ndon't mind.\n\n> +test_expect_success 'Rename to existing name' '\n> +   ! stg rename foo baz\n> +'\n\nYou remembered to use test_expect_success and ! instead of\ntest_expect_failure -- good!\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"69622","messageId":"200802222352.52319.onno@gmx.net","threadId":"12160","inReplyTo":"20080222073811.GB6630@diana.vm.bytemark.co.uk","subject":"Re: [StGit PATCH] Allow renaming of the top-most branch by just calling stg rename <new-patch-name>","fromName":"Onno Kortmann","fromEmail":"onno@gmx.net","sentAt":"2008-02-22T22:52:52Z","receivedAt":"2008-02-22T22:52:52Z","isPatch":true,"sender":{"key":"onno@gmx.net","avatar":"https://avatars.githubusercontent.com/u/91150?v=4"},"body":"Hi \n> Mailing patches to yourself is a good way to try things out if you're\n> not sure they're going to work (but you seem to have had no problems\n> with it).\nYes, I did that and it worked so I figured it would be ok to do it in public.. :)\n\n> Thanks, I'll pick both of them up, probably tomorrow (unless Catalin\n> does so first).\nOk - to answer both other mails here, of course I'm fine with all the changes \nin both patches. \n\nGreetings,\n\nOnno\n"},{"id":"69660","messageId":"20080223074552.GA32461@diana.vm.bytemark.co.uk","threadId":"12160","inReplyTo":"200802222352.52319.onno@gmx.net","subject":"Re: [StGit PATCH] Allow renaming of the top-most branch by just calling stg rename <new-patch-name>","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2008-02-23T07:45:52Z","receivedAt":"2008-02-23T07:45:52Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2008-02-22 23:52:52 +0100, Onno Kortmann wrote:\n\n> Ok - to answer both other mails here, of course I'm fine with all\n> the changes in both patches.\n\nWell it never hurts to ask. I've heard that some people feel strongly\nabout these style issues, complaining about other people's patches and\nwhatnot. ;-)\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"}]}