* [StGit PATCH] Allow renaming of the top-most branch by just calling stg rename <new-patch-name>
@ 2008-02-17 21:03 Onno Kortmann
2008-02-18 14:00 ` Karl Hasselström
0 siblings, 1 reply; 10+ messages in thread
From: Onno Kortmann @ 2008-02-17 21:03 UTC (permalink / raw)
To: git
instead of stg rename <old> <new>.
This is for example helpful for those people who always have a typo or two in
their
patch names.
---
stgit/commands/rename.py | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/stgit/commands/rename.py b/stgit/commands/rename.py
index e2b0fa4..acdf962 100644
--- a/stgit/commands/rename.py
+++ b/stgit/commands/rename.py
@@ -25,9 +25,10 @@ from stgit import stack, git
help = 'rename a patch in the series'
-usage = """%prog [options] <oldpatch> <newpatch>
+usage = """%prog [options] [oldpatch] <newpatch>
-Rename <oldpatch> into <newpatch> in a series."""
+Rename <oldpatch> into <newpatch> in a series. If <oldpatch> is not given,
the
+top-most patch will be renamed. """
directory = DirectoryHasRepository()
options = [make_option('-b', '--branch',
@@ -37,9 +38,18 @@ options = [make_option('-b', '--branch',
def func(parser, options, args):
"""Rename a patch in the series
"""
- if len(args) != 2:
- parser.error('incorrect number of arguments')
+ crt=crt_series.get_current()
+
+ if len(args) == 2:
+ out.start('Renaming patch "%s" to "%s"' % (args[0], args[1]))
+
+ elif len(args) == 1:
+ if not crt:
+ raise CmdException, "No applied top patch to rename exists."
+ args=[crt]+args
+ out.start('Renaming top-most patch "%s" to "%s"' % (args[0],
args[1]))
+
+ else: parser.error('incorrect number of arguments')
- out.start('Renaming patch "%s" to "%s"' % (args[0], args[1]))
crt_series.rename_patch(args[0], args[1])
out.done()
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [StGit PATCH] Allow renaming of the top-most branch by just calling stg rename <new-patch-name>
2008-02-17 21:03 [StGit PATCH] Allow renaming of the top-most branch by just calling stg rename <new-patch-name> Onno Kortmann
@ 2008-02-18 14:00 ` Karl Hasselström
2008-02-21 21:30 ` Onno Kortmann
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Karl Hasselström @ 2008-02-18 14:00 UTC (permalink / raw)
To: Onno Kortmann; +Cc: git, Catalin Marinas
This is a good idea, I think.
On 2008-02-17 22:03:55 +0100, Onno Kortmann wrote:
> instead of stg rename <old> <new>. This is for example helpful for
> those people who always have a typo or two in their patch names.
Please follow the commit message conventions. That is, first one short
summary line, then a blank line and the rest of the commit message.
And a sign-off.
(Read git's Documentation/SubmittingPatches if you want the details.)
> + args=[crt]+args
> + out.start('Renaming top-most patch "%s" to "%s"' % (args[0],
> args[1]))
Please consider storing the patch names in two suitably named
variables, like this:
if len(args) == 1:
old, [new] = crt, args
elif len(args) == 2:
old, new = args
--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [StGit PATCH] Allow renaming of the top-most branch by just calling stg rename <new-patch-name>
2008-02-18 14:00 ` Karl Hasselström
@ 2008-02-21 21:30 ` Onno Kortmann
2008-02-22 7:38 ` Karl Hasselström
2008-02-21 21:42 ` [PATCH 1/2] Simple rename of top-most patch Onno Kortmann
2008-02-21 21:43 ` [PATCH 2/2] Test the 'stg rename' command Onno Kortmann
2 siblings, 1 reply; 10+ messages in thread
From: Onno Kortmann @ 2008-02-21 21:30 UTC (permalink / raw)
To: Karl Hasselström; +Cc: git
Hi,
> > instead of stg rename <old> <new>. This is for example helpful for
> > those people who always have a typo or two in their patch names.
>
> Please follow the commit message conventions. That is, first one short
> summary line, then a blank line and the rest of the commit message.
> And a sign-off.
Ok, I tried to do this, I'm not used at all to sending patches with (st)git :-)
Thanks for the pointer and the assistance. Hopefully, --refid works as I
understand it and the new patches appear in this thread.
> Please consider storing the patch names in two suitably named
> variables, like this:
I fixed that one, too.
I'll send out another patch, a test case for the stg rename command.
Greetings,
Onno
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [StGit PATCH] Allow renaming of the top-most branch by just calling stg rename <new-patch-name>
2008-02-21 21:30 ` Onno Kortmann
@ 2008-02-22 7:38 ` Karl Hasselström
2008-02-22 22:52 ` Onno Kortmann
0 siblings, 1 reply; 10+ messages in thread
From: Karl Hasselström @ 2008-02-22 7:38 UTC (permalink / raw)
To: Onno Kortmann; +Cc: git
On 2008-02-21 22:30:56 +0100, Onno Kortmann wrote:
> Ok, I tried to do this, I'm not used at all to sending patches with
> (st)git :-) Thanks for the pointer and the assistance.
No problem. Thanks for writing the patches!
> Hopefully, --refid works as I understand it and the new patches
> appear in this thread.
Mailing patches to yourself is a good way to try things out if you're
not sure they're going to work (but you seem to have had no problems
with it).
> I'll send out another patch, a test case for the stg rename command.
Thanks, I'll pick both of them up, probably tomorrow (unless Catalin
does so first).
--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [StGit PATCH] Allow renaming of the top-most branch by just calling stg rename <new-patch-name>
2008-02-22 7:38 ` Karl Hasselström
@ 2008-02-22 22:52 ` Onno Kortmann
2008-02-23 7:45 ` Karl Hasselström
0 siblings, 1 reply; 10+ messages in thread
From: Onno Kortmann @ 2008-02-22 22:52 UTC (permalink / raw)
To: Karl Hasselström; +Cc: git
Hi
> Mailing patches to yourself is a good way to try things out if you're
> not sure they're going to work (but you seem to have had no problems
> with it).
Yes, I did that and it worked so I figured it would be ok to do it in public.. :)
> Thanks, I'll pick both of them up, probably tomorrow (unless Catalin
> does so first).
Ok - to answer both other mails here, of course I'm fine with all the changes
in both patches.
Greetings,
Onno
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [StGit PATCH] Allow renaming of the top-most branch by just calling stg rename <new-patch-name>
2008-02-22 22:52 ` Onno Kortmann
@ 2008-02-23 7:45 ` Karl Hasselström
0 siblings, 0 replies; 10+ messages in thread
From: Karl Hasselström @ 2008-02-23 7:45 UTC (permalink / raw)
To: Onno Kortmann; +Cc: git
On 2008-02-22 23:52:52 +0100, Onno Kortmann wrote:
> Ok - to answer both other mails here, of course I'm fine with all
> the changes in both patches.
Well it never hurts to ask. I've heard that some people feel strongly
about these style issues, complaining about other people's patches and
whatnot. ;-)
--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] Simple rename of top-most patch
2008-02-18 14:00 ` Karl Hasselström
2008-02-21 21:30 ` Onno Kortmann
@ 2008-02-21 21:42 ` Onno Kortmann
2008-02-22 7:44 ` Karl Hasselström
2008-02-21 21:43 ` [PATCH 2/2] Test the 'stg rename' command Onno Kortmann
2 siblings, 1 reply; 10+ messages in thread
From: Onno Kortmann @ 2008-02-21 21:42 UTC (permalink / raw)
To: git
Allow renaming of the top-most patch just by calling stg rename <new-patch-name>,
instead of stg rename <old> <new>. This is for example helpful for those people who
always have a typo or two in their patch names.
Signed-off-by: Onno Kortmann <onno@gmx.net>
---
stgit/commands/rename.py | 23 ++++++++++++++++-------
1 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/stgit/commands/rename.py b/stgit/commands/rename.py
index e2b0fa4..c687455 100644
--- a/stgit/commands/rename.py
+++ b/stgit/commands/rename.py
@@ -25,9 +25,10 @@ from stgit import stack, git
help = 'rename a patch in the series'
-usage = """%prog [options] <oldpatch> <newpatch>
+usage = """%prog [options] [oldpatch] <newpatch>
-Rename <oldpatch> into <newpatch> in a series."""
+Rename <oldpatch> into <newpatch> in a series. If <oldpatch> is not given, the
+top-most patch will be renamed. """
directory = DirectoryHasRepository()
options = [make_option('-b', '--branch',
@@ -37,9 +38,17 @@ options = [make_option('-b', '--branch',
def func(parser, options, args):
"""Rename a patch in the series
"""
- if len(args) != 2:
- parser.error('incorrect number of arguments')
-
- out.start('Renaming patch "%s" to "%s"' % (args[0], args[1]))
- crt_series.rename_patch(args[0], args[1])
+ crt=crt_series.get_current()
+
+ if len(args) == 2:
+ old, new=args
+ elif len(args) == 1:
+ if not crt:
+ raise CmdException, "No applied top patch to rename exists."
+ old, [new]=crt, args
+ else: parser.error('incorrect number of arguments')
+
+ out.start('Renaming patch "%s" to "%s"' % (old, new))
+ crt_series.rename_patch(old, new)
+
out.done()
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] Simple rename of top-most patch
2008-02-21 21:42 ` [PATCH 1/2] Simple rename of top-most patch Onno Kortmann
@ 2008-02-22 7:44 ` Karl Hasselström
0 siblings, 0 replies; 10+ messages in thread
From: Karl Hasselström @ 2008-02-22 7:44 UTC (permalink / raw)
To: Onno Kortmann; +Cc: git
On 2008-02-21 22:42:51 +0100, Onno Kortmann wrote:
> + if len(args) == 2:
> + old, new=args
> + elif len(args) == 1:
> + if not crt:
> + raise CmdException, "No applied top patch to rename exists."
> + old, [new]=crt, args
I think the style throughout StGit is to have spaces arond operators.
No biggie, though -- I'll fix it up.
> + else: parser.error('incorrect number of arguments')
It looks strange without a line break here, especially since there are
line breaks in the if and elif branches. I'll fix this too if you
don't mind.
--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] Test the 'stg rename' command
2008-02-18 14:00 ` Karl Hasselström
2008-02-21 21:30 ` Onno Kortmann
2008-02-21 21:42 ` [PATCH 1/2] Simple rename of top-most patch Onno Kortmann
@ 2008-02-21 21:43 ` Onno Kortmann
2008-02-22 7:48 ` Karl Hasselström
2 siblings, 1 reply; 10+ messages in thread
From: Onno Kortmann @ 2008-02-21 21:43 UTC (permalink / raw)
To: git
This just tests the few basic cases of the stg rename command.
Signed-off-by: Onno Kortmann <onno@gmx.net>
---
t/t2900-rename.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 47 insertions(+), 0 deletions(-)
create mode 100755 t/t2900-rename.sh
diff --git a/t/t2900-rename.sh b/t/t2900-rename.sh
new file mode 100755
index 0000000..a8f8f0b
--- /dev/null
+++ b/t/t2900-rename.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Onno Kortmann
+# Parts taken from the other test scripts
+# in this directory.
+#
+
+test_description='stg rename test
+
+Tests some parts of the stg rename command.'
+
+. ./test-lib.sh
+stg init
+
+test_expect_success 'Rename in empty' '
+ ! stg rename foo
+'
+
+test_expect_success 'Rename single top-most' '
+ stg new -m foo
+ stg rename bar
+'
+# bar
+
+test_expect_success 'Rename non-existing' '
+ ! stg rename neithersuchpatch norsuchpatch
+'
+
+test_expect_success 'Rename with two arguments' '
+ stg new -m baz
+ stg rename bar foo
+'
+# foo,baz
+
+test_expect_success 'Rename to existing name' '
+ ! stg rename foo baz
+'
+
+test_expect_success 'Rename to same name' '
+ ! stg rename foo foo
+'
+
+test_expect_success 'Rename top-most when others exist' '
+ stg rename bar
+'
+
+test_done
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] Test the 'stg rename' command
2008-02-21 21:43 ` [PATCH 2/2] Test the 'stg rename' command Onno Kortmann
@ 2008-02-22 7:48 ` Karl Hasselström
0 siblings, 0 replies; 10+ messages in thread
From: Karl Hasselström @ 2008-02-22 7:48 UTC (permalink / raw)
To: Onno Kortmann; +Cc: git
On 2008-02-21 22:43:18 +0100, Onno Kortmann wrote:
> +test_expect_success 'Rename with two arguments' '
> + stg new -m baz
> + stg rename bar foo
> +'
You want "&&" at the end of every line but the last one, otherwise
errors in any line but the last won't be caught. I'll add that, if you
don't mind.
> +test_expect_success 'Rename to existing name' '
> + ! stg rename foo baz
> +'
You remembered to use test_expect_success and ! instead of
test_expect_failure -- good!
--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2008-02-23 7:46 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-17 21:03 [StGit PATCH] Allow renaming of the top-most branch by just calling stg rename <new-patch-name> Onno Kortmann
2008-02-18 14:00 ` Karl Hasselström
2008-02-21 21:30 ` Onno Kortmann
2008-02-22 7:38 ` Karl Hasselström
2008-02-22 22:52 ` Onno Kortmann
2008-02-23 7:45 ` Karl Hasselström
2008-02-21 21:42 ` [PATCH 1/2] Simple rename of top-most patch Onno Kortmann
2008-02-22 7:44 ` Karl Hasselström
2008-02-21 21:43 ` [PATCH 2/2] Test the 'stg rename' command Onno Kortmann
2008-02-22 7:48 ` Karl Hasselström
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).