~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/send.py

  • Committer: Marius Kruger
  • Date: 2010-07-10 21:28:56 UTC
  • mto: (5384.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5385.
  • Revision ID: marius.kruger@enerweb.co.za-20100710212856-uq4ji3go0u5se7hx
* Update documentation
* add NEWS

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 (
109
110
            if len(revision) == 2:
110
111
                base_revision_id = revision[0].as_revision_id(branch)
111
112
        if revision_id is None:
112
 
            if strict is None:
113
 
                strict = branch.get_config(
114
 
                    ).get_user_option_as_bool('send_strict')
115
 
            if strict is None: strict = True # default value
116
 
            if strict and tree is not None:
117
 
                if (tree.has_changes()):
118
 
                    raise errors.UncommittedChanges(
119
 
                        tree, more='Use --no-strict to force the send.')
120
 
                if tree.last_revision() != tree.branch.last_revision():
121
 
                    # The tree has lost sync with its branch, there is little
122
 
                    # chance that the user is aware of it but he can still force
123
 
                    # the send with --no-strict
124
 
                    raise errors.OutOfDateTree(
125
 
                        tree, more='Use --no-strict to force the send.')
 
113
            if tree is not 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.')
126
118
            revision_id = branch.last_revision()
127
119
        if revision_id == NULL_REVISION:
128
120
            raise errors.BzrCommandError('No revisions to submit.')
134
126
            directive.compose_merge_request(mail_client, mail_to, body,
135
127
                                            branch, tree)
136
128
        else:
137
 
            if output == '-':
138
 
                outfile = to_file
 
129
            if directive.multiple_output_files:
 
130
                if output == '-':
 
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')
 
138
                    try:
 
139
                        outfile.writelines(lines)
 
140
                    finally:
 
141
                        outfile.close()
139
142
            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()
 
143
                if output == '-':
 
144
                    outfile = to_file
 
145
                else:
 
146
                    outfile = open(output, 'wb')
 
147
                try:
 
148
                    outfile.writelines(directive.to_lines())
 
149
                finally:
 
150
                    if outfile is not to_file:
 
151
                        outfile.close()
146
152
    finally:
147
153
        branch.unlock()
148
154