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