From: Onno Kortmann Date: Mon, 24 Mar 2008 18:53:37 +0000 (+0000) Subject: Simple rename of top-most patch X-Git-Tag: v0.14.2~4 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/stgit/commitdiff_plain/8cc1078981faa7b5cf00edca711b3df27a14ad0a?ds=sidebyside Simple rename of top-most patch Allow renaming of the top-most patch just by calling stg rename , instead of stg rename . This is for example helpful for those people who always have a typo or two in their patch names. Signed-off-by: Onno Kortmann Signed-off-by: Karl Hasselström --- diff --git a/stgit/commands/rename.py b/stgit/commands/rename.py index e2b0fa4..1d7c43b 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] +usage = """%prog [options] [oldpatch] -Rename into in a series.""" +Rename into in a series. If 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: + 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"' % (args[0], args[1])) - crt_series.rename_patch(args[0], args[1]) + out.start('Renaming patch "%s" to "%s"' % (old, new)) + crt_series.rename_patch(old, new) + out.done()