1 from stgit
.argparse
import opt
2 from stgit
.commands
.common
import CmdException
, DirectoryHasRepository
3 from stgit
.lib
.log
import log_stack_state
4 from stgit
.out
import out
7 Copyright (C) 2005, Catalin Marinas <catalin.marinas@gmail.com>
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License version 2 as
11 published by the Free Software Foundation.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, see http://www.gnu.org/licenses/.
22 help = 'Rename a patch'
24 usage
= ['[options] [--] [oldpatch] <newpatch>']
26 Rename <oldpatch> into <newpatch> in a series. If <oldpatch> is not
27 given, the top-most patch will be renamed."""
29 args
= ['applied_patches', 'unapplied_patches', 'hidden_patches']
34 args
=['stg_branches'],
35 short
='use BRANCH instead of the default one',
39 directory
= DirectoryHasRepository()
42 def func(parser
, options
, args
):
43 """Rename a patch in the series"""
44 stack
= directory
.repository
.get_stack(options
.branch
)
49 if not stack
.patchorder
.applied
:
50 raise CmdException("No applied top patch to rename exists.")
51 old
= stack
.patchorder
.applied
[-1]
54 parser
.error('incorrect number of arguments')
56 out
.start('Renaming patch "%s" to "%s"' % (old
, new
))
57 stack
.rename_patch(old
, new
)
58 log_stack_state(stack
, 'rename %s to %s' % (old
, new
))