~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-04-08 05:16:30 UTC
  • mfrom: (5728.5.10 log-not-in-branch)
  • Revision ID: pqm@pqm.ubuntu.com-20110408051630-wlk2z0cv73walyz0
(spiv) log no longer raises NoSuchRevision against revisions in the
 repository which are not in the current branch (#241998). Such revisions
 have no revno,
 so display the revision-id instead. It is now possible for a LogRevision to
 have a revno of None. (Matt Giuca) (Andrew Bennetts)

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,
110
110
            if len(revision) == 2:
111
111
                base_revision_id = revision[0].as_revision_id(branch)
112
112
        if revision_id is None:
113
 
            if strict is None:
114
 
                strict = branch.get_config(
115
 
                    ).get_user_option_as_bool('send_strict')
116
 
            if strict is None: strict = True # default value
117
 
            if strict and tree is not None:
118
 
                if (tree.has_changes()):
119
 
                    raise errors.UncommittedChanges(
120
 
                        tree, more='Use --no-strict to force the send.')
121
 
                if tree.last_revision() != tree.branch.last_revision():
122
 
                    # The tree has lost sync with its branch, there is little
123
 
                    # chance that the user is aware of it but he can still force
124
 
                    # the send with --no-strict
125
 
                    raise errors.OutOfDateTree(
126
 
                        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.')
127
118
            revision_id = branch.last_revision()
128
119
        if revision_id == NULL_REVISION:
129
120
            raise errors.BzrCommandError('No revisions to submit.')
135
126
            directive.compose_merge_request(mail_client, mail_to, body,
136
127
                                            branch, tree)
137
128
        else:
138
 
            if output == '-':
139
 
                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()
140
142
            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()
 
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()
147
152
    finally:
148
153
        branch.unlock()
149
154
 
150
155
 
151
156
def _send_4(branch, revision_id, submit_branch, public_branch,
152
157
            no_patch, no_bundle, message, base_revision_id):
 
158
    from bzrlib import merge_directive
153
159
    return merge_directive.MergeDirective2.from_objects(
154
160
        branch.repository, revision_id, time.time(),
155
161
        osutils.local_time_offset(), submit_branch,
171
177
            patch_type = 'diff'
172
178
        else:
173
179
            patch_type = None
 
180
    from bzrlib import merge_directive
174
181
    return merge_directive.MergeDirective.from_objects(
175
182
        branch.repository, revision_id, time.time(),
176
183
        osutils.local_time_offset(), submit_branch,