Commit | Line | Data |
---|---|---|
26e3ed6d HE |
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.argparse import opt | |
19 | from stgit.commands import common | |
20 | from stgit.out import out | |
21 | from stgit import argparse | |
22 | ||
23 | help = 'Print the name of the previous patch' | |
24 | kind = 'stack' | |
25 | usage = [''] | |
26 | description = """ | |
27 | Print the name of the previous patch.""" | |
28 | ||
29 | args = [] | |
30 | options = [ | |
31 | opt('-b', '--branch', args = [argparse.stg_branches], | |
32 | short = 'Use BRANCH instead of the default branch')] | |
33 | ||
34 | directory = common.DirectoryHasRepositoryLib() | |
35 | ||
36 | def func(parser, options, args): | |
37 | """Show the name of the previous patch | |
38 | """ | |
39 | if len(args) != 0: | |
40 | parser.error('incorrect number of arguments') | |
41 | ||
42 | stack = directory.repository.get_stack(options.branch) | |
43 | applied = stack.patchorder.applied | |
44 | ||
45 | if applied and len(applied) >= 2: | |
46 | out.stdout(applied[-2]) | |
47 | else: | |
48 | raise common.CmdException, 'Not enough applied patches' |