Commit | Line | Data |
---|---|---|
6a093bbb CM |
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 | import sys, os | |
19 | from optparse import OptionParser, make_option | |
20 | ||
21 | from stgit.commands.common import * | |
22 | from stgit.utils import * | |
5e888f30 | 23 | from stgit.out import * |
6a093bbb CM |
24 | from stgit import stack, git |
25 | ||
26 | help = 'permanently store the applied patches into stack base' | |
27 | usage = """%prog [options] | |
28 | ||
29 | Merge the applied patches into the base of the current stack and | |
30 | remove them from the series while advancing the base. | |
31 | ||
32 | Use this command only if you want to permanently store the applied | |
33 | patches and no longer manage them with StGIT.""" | |
34 | ||
6dd8fafa | 35 | directory = DirectoryHasRepository() |
6a093bbb CM |
36 | options = [] |
37 | ||
38 | ||
39 | def func(parser, options, args): | |
40 | """Merge the applied patches into the base of the current stack | |
41 | and remove them from the series while advancing the base | |
42 | """ | |
43 | if len(args) != 0: | |
44 | parser.error('incorrect number of arguments') | |
45 | ||
46 | check_local_changes() | |
47 | check_conflicts() | |
48 | check_head_top_equal() | |
49 | ||
50 | applied = crt_series.get_applied() | |
51 | if not applied: | |
52 | raise CmdException, 'No patches applied' | |
53 | ||
0b4b9499 CL |
54 | if crt_series.get_protected(): |
55 | raise CmdException, 'This branch is protected. Commit is not permitted' | |
56 | ||
6a093bbb CM |
57 | crt_head = git.get_head() |
58 | ||
27ac2b7e | 59 | out.start('Committing %d patches' % len(applied)) |
6a093bbb CM |
60 | |
61 | crt_series.pop_patch(applied[0]) | |
62 | git.switch(crt_head) | |
63 | ||
64 | for patch in applied: | |
65 | crt_series.delete_patch(patch) | |
66 | ||
27ac2b7e | 67 | out.done() |