Commit | Line | Data |
---|---|---|
fcee87cf CM |
1 | |
2 | __copyright__ = """ | |
3 | Copyright (C) 2005, Catalin Marinas <catalin.marinas@gmail.com> | |
4 | ||
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU General Public License version 2 as | |
7 | published by the Free Software Foundation. | |
8 | ||
9 | This program is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | GNU General Public License for more details. | |
13 | ||
14 | You should have received a copy of the GNU General Public License | |
15 | along with this program; if not, write to the Free Software | |
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
17 | """ | |
18 | ||
19 | import sys, os | |
20 | from optparse import OptionParser, make_option | |
21 | ||
22 | from stgit.commands.common import * | |
23 | from stgit.utils import * | |
24 | from stgit import stack, git | |
25 | ||
26 | ||
27 | help = 'create a new patch and make it the topmost one' | |
9060d420 | 28 | usage = """%prog [options] [name] |
26aab5b0 CM |
29 | |
30 | Create a new, empty patch and make it the topmost one. If the | |
31 | '--message' option is not passed, an editor is invoked with the | |
1f3bb017 CM |
32 | .git/patchdescr.tmpl, ~/.stgit/templates/patchdescr.tmpl or |
33 | /usr/share/stgit/templates/patchdescr.tmpl file used a as template, | |
34 | together with generated lines. By default, the local changes in the | |
35 | working tree are not included in the patch. A 'refresh' command is | |
9060d420 KH |
36 | needed for this. |
37 | ||
38 | If no name is given for the new patch, one is generated from the first | |
39 | line of the commit message.""" | |
fcee87cf CM |
40 | |
41 | options = [make_option('-m', '--message', | |
42 | help = 'use MESSAGE as the patch description'), | |
6ad48e48 PBG |
43 | make_option('-s', '--showpatch', |
44 | help = 'show the patch content in the editor buffer', | |
45 | action = 'store_true'), | |
19cd0a8f CM |
46 | make_option('-a', '--author', metavar = '"NAME <EMAIL>"', |
47 | help = 'use "NAME <EMAIL>" as the author details'), | |
fcee87cf CM |
48 | make_option('--authname', |
49 | help = 'use AUTHNAME as the author name'), | |
50 | make_option('--authemail', | |
51 | help = 'use AUTHEMAIL as the author e-mail'), | |
52 | make_option('--authdate', | |
53 | help = 'use AUTHDATE as the author date'), | |
54 | make_option('--commname', | |
55 | help = 'use COMMNAME as the committer name'), | |
56 | make_option('--commemail', | |
57 | help = 'use COMMEMAIL as the committer e-mail')] | |
58 | ||
59 | ||
60 | def func(parser, options, args): | |
61 | """Creates a new patch | |
62 | """ | |
9060d420 KH |
63 | if len(args) == 0: |
64 | name = None # autogenerate a name | |
65 | elif len(args) == 1: | |
66 | name = args[0] | |
67 | else: | |
fcee87cf CM |
68 | parser.error('incorrect number of arguments') |
69 | ||
3bd6274e CM |
70 | check_conflicts() |
71 | check_head_top_equal() | |
fcee87cf | 72 | |
19cd0a8f CM |
73 | if options.author: |
74 | options.authname, options.authemail = name_email(options.author) | |
75 | ||
9060d420 | 76 | crt_series.new_patch(name, message = options.message, |
6ad48e48 | 77 | show_patch = options.showpatch, |
fcee87cf CM |
78 | author_name = options.authname, |
79 | author_email = options.authemail, | |
80 | author_date = options.authdate, | |
81 | committer_name = options.commname, | |
82 | committer_email = options.commemail) |