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 | from stgit.config import config | |
26 | ||
27 | ||
28 | help = 'generate a new commit for the current patch' | |
26aab5b0 CM |
29 | usage = """%prog [options] |
30 | ||
31 | Include the latest tree changes in the current patch. This command | |
32 | generates a new GIT commit object with the patch details, the previous | |
33 | one no longer being visible. The patch attributes like author, | |
34 | committer and description can be changed with the command line | |
35 | options. The '--force' option is useful when a commit object was | |
36 | created with a different tool but the changes need to be included in | |
37 | the current patch.""" | |
fcee87cf CM |
38 | |
39 | options = [make_option('-f', '--force', | |
40 | help = 'force the refresh even if HEAD and '\ | |
41 | 'top differ', | |
42 | action = 'store_true'), | |
43 | make_option('-e', '--edit', | |
44 | help = 'invoke an editor for the patch '\ | |
45 | 'description', | |
46 | action = 'store_true'), | |
47 | make_option('-m', '--message', | |
48 | help = 'use MESSAGE as the patch ' \ | |
49 | 'description'), | |
19cd0a8f CM |
50 | make_option('-a', '--author', metavar = '"NAME <EMAIL>"', |
51 | help = 'use "NAME <EMAIL>" as the author details'), | |
fcee87cf CM |
52 | make_option('--authname', |
53 | help = 'use AUTHNAME as the author name'), | |
54 | make_option('--authemail', | |
55 | help = 'use AUTHEMAIL as the author e-mail'), | |
56 | make_option('--authdate', | |
57 | help = 'use AUTHDATE as the author date'), | |
58 | make_option('--commname', | |
59 | help = 'use COMMNAME as the committer name'), | |
60 | make_option('--commemail', | |
61 | help = 'use COMMEMAIL as the committer ' \ | |
62 | 'e-mail')] | |
63 | ||
64 | ||
65 | def func(parser, options, args): | |
66 | if len(args) != 0: | |
67 | parser.error('incorrect number of arguments') | |
68 | ||
69 | if config.has_option('stgit', 'autoresolved'): | |
70 | autoresolved = config.get('stgit', 'autoresolved') | |
71 | else: | |
72 | autoresolved = 'no' | |
73 | ||
74 | if autoresolved != 'yes': | |
75 | check_conflicts() | |
76 | ||
77 | patch = crt_series.get_current() | |
78 | if not patch: | |
79 | raise CmdException, 'No patches applied' | |
80 | ||
81 | if not options.force: | |
82 | check_head_top_equal() | |
83 | ||
19cd0a8f CM |
84 | if options.author: |
85 | options.authname, options.authemail = name_email(options.author) | |
86 | ||
fcee87cf CM |
87 | if git.local_changes() \ |
88 | or not crt_series.head_top_equal() \ | |
89 | or options.edit or options.message \ | |
90 | or options.authname or options.authemail or options.authdate \ | |
91 | or options.commname or options.commemail: | |
92 | print 'Refreshing patch "%s"...' % patch, | |
93 | sys.stdout.flush() | |
94 | ||
95 | if autoresolved == 'yes': | |
96 | resolved_all() | |
97 | crt_series.refresh_patch(message = options.message, | |
98 | edit = options.edit, | |
99 | author_name = options.authname, | |
100 | author_email = options.authemail, | |
101 | author_date = options.authdate, | |
102 | committer_name = options.commname, | |
103 | committer_email = options.commemail) | |
104 | ||
105 | print 'done' | |
106 | else: | |
107 | print 'Patch "%s" is already up to date' % patch |