/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/send.py

Merge test-run support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
        from_, possible_transports=possible_transports)[:2]
47
47
    # we may need to write data into branch's repository to calculate
48
48
    # the data to send.
49
 
    with branch.lock_write():
 
49
    branch.lock_write()
 
50
    try:
50
51
        if output is None:
51
52
            config_stack = branch.get_config_stack()
52
53
            if mail_to is None:
53
54
                mail_to = config_stack.get('submit_to')
54
55
            mail_client = config_stack.get('mail_client')(config_stack)
55
56
            if (not getattr(mail_client, 'supports_body', False)
56
 
                    and body is not None):
 
57
                and body is not None):
57
58
                raise errors.BzrCommandError(gettext(
58
59
                    'Mail client "%s" does not support specifying body') %
59
60
                    mail_client.__class__.__name__)
75
76
            remembered_target_branch = "parent"
76
77
        if target_branch is None:
77
78
            raise errors.BzrCommandError(gettext('No submit branch known or'
78
 
                                                 ' specified'))
 
79
                                         ' specified'))
79
80
        if remembered_target_branch is not None:
80
81
            trace.note(gettext('Using saved {0} location "{1}" to determine '
81
 
                               'what changes to submit.').format(
82
 
                remembered_target_branch,
83
 
                target_branch))
 
82
                       'what changes to submit.').format(
 
83
                                    remembered_target_branch,
 
84
                                    target_branch))
84
85
 
85
86
        submit_branch = Branch.open(target_branch,
86
 
                                    possible_transports=possible_transports)
 
87
            possible_transports=possible_transports)
87
88
        possible_transports.append(submit_branch.controldir.root_transport)
88
89
        if mail_to is None or format is None:
89
90
            if mail_to is None:
106
107
            branch.set_public_branch(public_branch)
107
108
        if no_bundle and public_branch is None:
108
109
            raise errors.BzrCommandError(gettext('No public branch specified or'
109
 
                                                 ' known'))
 
110
                                         ' known'))
110
111
        base_revision_id = None
111
112
        revision_id = None
112
113
        if revision is not None:
113
114
            if len(revision) > 2:
114
115
                raise errors.BzrCommandError(gettext('bzr send takes '
115
 
                                                     'at most two one revision identifiers'))
 
116
                    'at most two one revision identifiers'))
116
117
            revision_id = revision[-1].as_revision_id(branch)
117
118
            if len(revision) == 2:
118
119
                base_revision_id = revision[0].as_revision_id(branch)
128
129
        if format is None:
129
130
            format = format_registry.get()
130
131
        directive = format(branch, revision_id, target_branch,
131
 
                           public_branch, no_patch, no_bundle, message, base_revision_id,
132
 
                           submit_branch)
 
132
            public_branch, no_patch, no_bundle, message, base_revision_id,
 
133
            submit_branch)
133
134
        if output is None:
134
135
            directive.compose_merge_request(mail_client, mail_to, body,
135
136
                                            branch, tree)
137
138
            if directive.multiple_output_files:
138
139
                if output == '-':
139
140
                    raise errors.BzrCommandError(gettext('- not supported for '
140
 
                                                         'merge directives that use more than one output file.'))
 
141
                        'merge directives that use more than one output file.'))
141
142
                if not os.path.exists(output):
142
143
                    os.mkdir(output, 0o755)
143
144
                for (filename, lines) in directive.to_files():
144
145
                    path = os.path.join(output, filename)
145
 
                    with open(path, 'wb') as outfile:
 
146
                    outfile = open(path, 'wb')
 
147
                    try:
146
148
                        outfile.writelines(lines)
 
149
                    finally:
 
150
                        outfile.close()
147
151
            else:
148
152
                if output == '-':
149
153
                    outfile = to_file
154
158
                finally:
155
159
                    if outfile is not to_file:
156
160
                        outfile.close()
 
161
    finally:
 
162
        branch.unlock()
157
163
 
158
164
 
159
165
def _send_4(branch, revision_id, target_branch, public_branch,
178
184
            patch_type = 'bundle'
179
185
        else:
180
186
            raise errors.BzrCommandError(gettext('Format 0.9 does not'
181
 
                                                 ' permit bundle with no patch'))
 
187
                ' permit bundle with no patch'))
182
188
    else:
183
189
        if not no_patch:
184
190
            patch_type = 'diff'
193
199
 
194
200
 
195
201
format_registry.register('4',
196
 
                         _send_4, 'Bundle format 4, Merge Directive 2 (default)')
 
202
    _send_4, 'Bundle format 4, Merge Directive 2 (default)')
197
203
format_registry.register('0.9',
198
 
                         _send_0_9, 'Bundle format 0.9, Merge Directive 1')
 
204
    _send_0_9, 'Bundle format 0.9, Merge Directive 1')
199
205
format_registry.default_key = '4'