39
39
def send(submit_branch, revision, public_branch, remember, format,
40
no_bundle, no_patch, output, from_, mail_to, message, body,
41
to_file, strict=None):
40
no_bundle, no_patch, output, from_, mail_to, message, body,
42
42
tree, branch = bzrdir.BzrDir.open_containing_tree_or_branch(from_)[:2]
43
43
# we may need to write data into branch's repository to calculate
44
44
# the data to send.
79
79
if mail_to is None or format is None:
80
# TODO: jam 20090716 we open the submit_branch here, but we *don't*
81
# pass it down into the format creation, so it will have to
83
80
submit_br = Branch.open(submit_branch)
84
81
submit_config = submit_br.get_config()
85
82
if mail_to is None:
110
107
if len(revision) == 2:
111
108
base_revision_id = revision[0].as_revision_id(branch)
112
109
if revision_id is None:
114
tree.check_changed_or_out_of_date(
115
strict, 'send_strict',
116
more_error='Use --no-strict to force the send.',
117
more_warning='Uncommitted changes will not be sent.')
118
110
revision_id = branch.last_revision()
119
111
if revision_id == NULL_REVISION:
120
112
raise errors.BzrCommandError('No revisions to submit.')
121
113
if format is None:
114
# TODO: Query submit branch for its preferred format
122
115
format = format_registry.get()
123
directive = format(branch, revision_id, submit_branch,
116
directive = format(branch, revision_id, submit_branch,
124
117
public_branch, no_patch, no_bundle, message, base_revision_id)
125
118
if output is None:
126
119
directive.compose_merge_request(mail_client, mail_to, body,
129
if directive.multiple_output_files:
131
raise errors.BzrCommandError('- not supported for '
132
'merge directives that use more than one output file.')
133
if not os.path.exists(output):
134
os.mkdir(output, 0755)
135
for (filename, lines) in directive.to_files():
136
path = os.path.join(output, filename)
137
outfile = open(path, 'wb')
139
outfile.writelines(lines)
146
outfile = open(output, 'wb')
148
outfile.writelines(directive.to_lines())
150
if outfile is not to_file:
125
outfile = open(output, 'wb')
127
outfile.writelines(directive.to_lines())
129
if outfile is not to_file:
156
135
def _send_4(branch, revision_id, submit_branch, public_branch,
157
136
no_patch, no_bundle, message, base_revision_id):
158
from bzrlib import merge_directive
159
137
return merge_directive.MergeDirective2.from_objects(
160
138
branch.repository, revision_id, time.time(),
161
139
osutils.local_time_offset(), submit_branch,
177
155
patch_type = 'diff'
179
157
patch_type = None
180
from bzrlib import merge_directive
181
158
return merge_directive.MergeDirective.from_objects(
182
159
branch.repository, revision_id, time.time(),
183
160
osutils.local_time_offset(), submit_branch,