~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/send.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-08-17 08:40:16 UTC
  • mfrom: (5642.4.6 712474-module-available)
  • Revision ID: pqm@pqm.ubuntu.com-20110817084016-600z65qzqmmt44w7
(vila) ModuleAvailableFeature don't try to imported already imported
 modules. (Vincent Ladeuil)

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 (
62
63
            submit_branch = stored_submit_branch
63
64
            remembered_submit_branch = "submit"
64
65
        else:
65
 
            if stored_submit_branch is None or remember:
 
66
            # Remembers if asked explicitly or no previous location is set
 
67
            if remember or (remember is None and stored_submit_branch is None):
66
68
                branch.set_submit_branch(submit_branch)
67
69
        if submit_branch is None:
68
70
            submit_branch = branch.get_parent()
94
96
        stored_public_branch = branch.get_public_branch()
95
97
        if public_branch is None:
96
98
            public_branch = stored_public_branch
97
 
        elif stored_public_branch is None or remember:
 
99
        # Remembers if asked explicitly or no previous location is set
 
100
        elif (remember
 
101
              or (remember is None and stored_public_branch is None)):
98
102
            branch.set_public_branch(public_branch)
99
103
        if no_bundle and public_branch is None:
100
104
            raise errors.BzrCommandError('No public branch specified or'
109
113
            if len(revision) == 2:
110
114
                base_revision_id = revision[0].as_revision_id(branch)
111
115
        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.')
 
116
            if tree is not None:
 
117
                tree.check_changed_or_out_of_date(
 
118
                    strict, 'send_strict',
 
119
                    more_error='Use --no-strict to force the send.',
 
120
                    more_warning='Uncommitted changes will not be sent.')
126
121
            revision_id = branch.last_revision()
127
122
        if revision_id == NULL_REVISION:
128
123
            raise errors.BzrCommandError('No revisions to submit.')
134
129
            directive.compose_merge_request(mail_client, mail_to, body,
135
130
                                            branch, tree)
136
131
        else:
137
 
            if output == '-':
138
 
                outfile = to_file
 
132
            if directive.multiple_output_files:
 
133
                if output == '-':
 
134
                    raise errors.BzrCommandError('- not supported for '
 
135
                        'merge directives that use more than one output file.')
 
136
                if not os.path.exists(output):
 
137
                    os.mkdir(output, 0755)
 
138
                for (filename, lines) in directive.to_files():
 
139
                    path = os.path.join(output, filename)
 
140
                    outfile = open(path, 'wb')
 
141
                    try:
 
142
                        outfile.writelines(lines)
 
143
                    finally:
 
144
                        outfile.close()
139
145
            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()
 
146
                if output == '-':
 
147
                    outfile = to_file
 
148
                else:
 
149
                    outfile = open(output, 'wb')
 
150
                try:
 
151
                    outfile.writelines(directive.to_lines())
 
152
                finally:
 
153
                    if outfile is not to_file:
 
154
                        outfile.close()
146
155
    finally:
147
156
        branch.unlock()
148
157