~jelmer/brz/zsh-completion

« back to all changes in this revision

Viewing changes to bzrlib/send.py

  • Committer: Robert Collins
  • Date: 2010-04-08 04:34:03 UTC
  • mfrom: (5138 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5139.
  • Revision ID: robertc@robertcollins.net-20100408043403-56z0d07vdqrx7f3t
Update bugfix for 528114 to trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009 Canonical Ltd
 
1
# Copyright (C) 2009, 2010 Canonical Ltd
2
2
#
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
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
 
18
import os
18
19
import time
19
20
 
20
21
from bzrlib import (
21
22
    bzrdir,
22
23
    errors,
23
 
    merge_directive,
24
24
    osutils,
25
25
    registry,
26
26
    trace,
135
135
            directive.compose_merge_request(mail_client, mail_to, body,
136
136
                                            branch, tree)
137
137
        else:
138
 
            if output == '-':
139
 
                outfile = to_file
 
138
            if directive.multiple_output_files:
 
139
                if output == '-':
 
140
                    raise errors.BzrCommandError('- not supported for '
 
141
                        'merge directives that use more than one output file.')
 
142
                if not os.path.exists(output):
 
143
                    os.mkdir(output, 0755)
 
144
                for (filename, lines) in directive.to_files():
 
145
                    path = os.path.join(output, filename)
 
146
                    outfile = open(path, 'wb')
 
147
                    try:
 
148
                        outfile.writelines(lines)
 
149
                    finally:
 
150
                        outfile.close()
140
151
            else:
141
 
                outfile = open(output, 'wb')
142
 
            try:
143
 
                outfile.writelines(directive.to_lines())
144
 
            finally:
145
 
                if outfile is not to_file:
146
 
                    outfile.close()
 
152
                if output == '-':
 
153
                    outfile = to_file
 
154
                else:
 
155
                    outfile = open(output, 'wb')
 
156
                try:
 
157
                    outfile.writelines(directive.to_lines())
 
158
                finally:
 
159
                    if outfile is not to_file:
 
160
                        outfile.close()
147
161
    finally:
148
162
        branch.unlock()
149
163
 
150
164
 
151
165
def _send_4(branch, revision_id, submit_branch, public_branch,
152
166
            no_patch, no_bundle, message, base_revision_id):
 
167
    from bzrlib import merge_directive
153
168
    return merge_directive.MergeDirective2.from_objects(
154
169
        branch.repository, revision_id, time.time(),
155
170
        osutils.local_time_offset(), submit_branch,
171
186
            patch_type = 'diff'
172
187
        else:
173
188
            patch_type = None
 
189
    from bzrlib import merge_directive
174
190
    return merge_directive.MergeDirective.from_objects(
175
191
        branch.repository, revision_id, time.time(),
176
192
        osutils.local_time_offset(), submit_branch,