1
# Copyright (C) 2009, 2010 Canonical Ltd
1
# Copyright (C) 2009 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
63
63
submit_branch = stored_submit_branch
64
64
remembered_submit_branch = "submit"
66
# Remembers if asked explicitly or no previous location is set
67
if remember or (remember is None and stored_submit_branch is None):
66
if stored_submit_branch is None or remember:
68
67
branch.set_submit_branch(submit_branch)
69
68
if submit_branch is None:
70
69
submit_branch = branch.get_parent()
96
95
stored_public_branch = branch.get_public_branch()
97
96
if public_branch is None:
98
97
public_branch = stored_public_branch
99
# Remembers if asked explicitly or no previous location is set
101
or (remember is None and stored_public_branch is None)):
98
elif stored_public_branch is None or remember:
102
99
branch.set_public_branch(public_branch)
103
100
if no_bundle and public_branch is None:
104
101
raise errors.BzrCommandError('No public branch specified or'
113
110
if len(revision) == 2:
114
111
base_revision_id = revision[0].as_revision_id(branch)
115
112
if revision_id is None:
117
tree.check_changed_or_out_of_date(
118
strict, 'send_strict',
119
more_error='Use --no-strict to force the send.',
120
more_warning='Uncommitted changes will not be sent.')
114
strict = branch.get_config(
115
).get_user_option_as_bool('send_strict')
116
if strict is None: strict = True # default value
117
if strict and tree is not None:
118
if (tree.has_changes()):
119
raise errors.UncommittedChanges(
120
tree, more='Use --no-strict to force the send.')
121
if tree.last_revision() != tree.branch.last_revision():
122
# The tree has lost sync with its branch, there is little
123
# chance that the user is aware of it but he can still force
124
# the send with --no-strict
125
raise errors.OutOfDateTree(
126
tree, more='Use --no-strict to force the send.')
121
127
revision_id = branch.last_revision()
122
128
if revision_id == NULL_REVISION:
123
129
raise errors.BzrCommandError('No revisions to submit.')
129
135
directive.compose_merge_request(mail_client, mail_to, body,
132
if directive.multiple_output_files:
134
raise errors.BzrCommandError('- not supported for '
135
'merge directives that use more than one output file.')
136
if not os.path.exists(output):
137
os.mkdir(output, 0755)
138
for (filename, lines) in directive.to_files():
139
path = os.path.join(output, filename)
140
outfile = open(path, 'wb')
142
outfile.writelines(lines)
149
outfile = open(output, 'wb')
151
outfile.writelines(directive.to_lines())
153
if outfile is not to_file:
141
outfile = open(output, 'wb')
143
outfile.writelines(directive.to_lines())
145
if outfile is not to_file:
159
151
def _send_4(branch, revision_id, submit_branch, public_branch,
160
152
no_patch, no_bundle, message, base_revision_id):
161
from bzrlib import merge_directive
162
153
return merge_directive.MergeDirective2.from_objects(
163
154
branch.repository, revision_id, time.time(),
164
155
osutils.local_time_offset(), submit_branch,
180
171
patch_type = 'diff'
182
173
patch_type = None
183
from bzrlib import merge_directive
184
174
return merge_directive.MergeDirective.from_objects(
185
175
branch.repository, revision_id, time.time(),
186
176
osutils.local_time_offset(), submit_branch,