3150
3150
'(use --file "%(f)s" to take commit message from that file)'
3151
3151
% { 'f': message })
3152
3152
ui.ui_factory.show_warning(warning_msg)
3154
message = message.replace('\r\n', '\n')
3155
message = message.replace('\r', '\n')
3157
raise errors.BzrCommandError(
3158
"please specify either --message or --file")
3154
3160
def get_message(commit_obj):
3155
3161
"""Callback to get commit message"""
3156
my_message = message
3157
if my_message is not None and '\r' in my_message:
3158
my_message = my_message.replace('\r\n', '\n')
3159
my_message = my_message.replace('\r', '\n')
3160
if my_message is None and not file:
3161
# t is the status of the tree
3162
t = make_commit_message_template_encoded(tree,
3163
my_message = codecs.open(
3164
file, 'rt', osutils.get_user_encoding()).read()
3165
elif message is not None:
3166
my_message = message
3168
# No message supplied: make one up.
3169
# text is the status of the tree
3170
text = make_commit_message_template_encoded(tree,
3163
3171
selected_list, diff=show_diff,
3164
3172
output_encoding=osutils.get_user_encoding())
3165
3173
# start_message is the template generated from hooks
3174
# XXX: Warning - looks like hooks return unicode,
3175
# make_commit_message_template_encoded returns user encoding.
3176
# We probably want to be using edit_commit_message instead to
3166
3178
start_message = generate_commit_message_template(commit_obj)
3167
my_message = edit_commit_message_encoded(t,
3179
my_message = edit_commit_message_encoded(text,
3168
3180
start_message=start_message)
3169
3181
if my_message is None:
3170
3182
raise errors.BzrCommandError("please specify a commit"
3171
3183
" message with either --message or --file")
3172
elif my_message and file:
3173
raise errors.BzrCommandError(
3174
"please specify either --message or --file")
3176
my_message = codecs.open(file, 'rt',
3177
osutils.get_user_encoding()).read()
3178
3184
if my_message == "":
3179
3185
raise errors.BzrCommandError("empty commit message specified")
3180
3186
return my_message
3192
3198
timezone=offset,
3193
3199
exclude=safe_relpath_files(tree, exclude))
3194
3200
except PointlessCommit:
3195
# FIXME: This should really happen before the file is read in;
3196
# perhaps prepare the commit; get the message; then actually commit
3197
3201
raise errors.BzrCommandError("No changes to commit."
3198
3202
" Use --unchanged to commit anyhow.")
3199
3203
except ConflictsInTree: