~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/send.py

  • Committer: Jelmer Vernooij
  • Date: 2010-03-13 02:49:14 UTC
  • mto: This revision was merged to the branch mainline in revision 5089.
  • Revision ID: jelmer@samba.org-20100313024914-rpuoguinoxpxt05b
Allow merge directives to output multiple patch files. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 (
134
135
            directive.compose_merge_request(mail_client, mail_to, body,
135
136
                                            branch, tree)
136
137
        else:
137
 
            if output == '-':
138
 
                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()
139
151
            else:
140
 
                outfile = open(output, 'wb')
141
 
            try:
142
 
                outfile.writelines(directive.to_lines())
143
 
            finally:
144
 
                if outfile is not to_file:
145
 
                    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()
146
161
    finally:
147
162
        branch.unlock()
148
163