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