chiark / gitweb /
f82218176aa9667eb9ff17a7316f79f3eb439af9
[stgit] / stgit / commands / commit.py
1 __copyright__ = """
2 Copyright (C) 2005, Catalin Marinas <catalin.marinas@gmail.com>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License version 2 as
6 published by the Free Software Foundation.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 """
17
18 from stgit.commands import common
19 from stgit.lib import transaction
20 from stgit.out import *
21
22 help = 'permanently store the applied patches into stack base'
23 usage = """%prog [options]
24
25 Merge the applied patches into the base of the current stack and
26 remove them from the series while advancing the base.
27
28 Use this command only if you want to permanently store the applied
29 patches and no longer manage them with StGIT."""
30
31 directory = common.DirectoryHasRepositoryLib()
32 options = []
33
34
35 def func(parser, options, args):
36     """Merge the applied patches into the base of the current stack
37        and remove them from the series while advancing the base
38     """
39     if len(args) != 0:
40         parser.error('incorrect number of arguments')
41
42     stack = directory.repository.current_stack
43     patches = stack.patchorder.applied
44     if not patches:
45         raise CmdException('No patches to commit')
46     out.start('Committing %d patches' % len(patches))
47     trans = transaction.StackTransaction(stack, 'stg commit')
48     for pn in patches:
49         trans.patches[pn] = None
50     trans.applied = []
51     trans.base = stack.head
52     trans.run()
53     out.done()