~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: 2009-07-01 19:06:14 UTC
  • mfrom: (4498.2.2 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090701190614-ypbryxq02zxbf5kv
Add a --strict option to send

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
 
38
38
 
39
39
def send(submit_branch, revision, public_branch, remember, format,
40
 
         no_bundle, no_patch, output, from_, mail_to, message, body, 
41
 
         to_file):
 
40
         no_bundle, no_patch, output, from_, mail_to, message, body,
 
41
         to_file, strict=None):
42
42
    tree, branch = bzrdir.BzrDir.open_containing_tree_or_branch(from_)[:2]
43
43
    # we may need to write data into branch's repository to calculate
44
44
    # the data to send.
107
107
            if len(revision) == 2:
108
108
                base_revision_id = revision[0].as_revision_id(branch)
109
109
        if revision_id is None:
 
110
            if strict is None:
 
111
                strict = branch.get_config().get_user_option('send_strict')
 
112
                if strict is not None:
 
113
                    # FIXME: This should be better supported by config
 
114
                    # -- vila 20090626
 
115
                    bools = dict(yes=True, no=False, on=True, off=False,
 
116
                                 true=True, false=False)
 
117
                    try:
 
118
                        strict = bools[strict.lower()]
 
119
                    except KeyError:
 
120
                        strict = None
 
121
            if tree is not None and (strict is None or strict):
 
122
                changes = tree.changes_from(tree.basis_tree())
 
123
                if changes.has_changed() or len(tree.get_parent_ids()) > 1:
 
124
                    raise errors.UncommittedChanges(
 
125
                        tree, more='Use --no-strict to force the send.')
 
126
                if tree.last_revision() != tree.branch.last_revision():
 
127
                    # The tree has lost sync with its branch, there is little
 
128
                    # chance that the user is aware of it but he can still force
 
129
                    # the push with --no-strict
 
130
                    raise errors.OutOfDateTree(
 
131
                        tree, more='Use --no-strict to force the send.')
110
132
            revision_id = branch.last_revision()
111
133
        if revision_id == NULL_REVISION:
112
134
            raise errors.BzrCommandError('No revisions to submit.')
113
135
        if format is None:
114
136
            # TODO: Query submit branch for its preferred format
115
137
            format = format_registry.get()
116
 
        directive = format(branch, revision_id, submit_branch, 
 
138
        directive = format(branch, revision_id, submit_branch,
117
139
            public_branch, no_patch, no_bundle, message, base_revision_id)
118
140
        if output is None:
119
141
            directive.compose_merge_request(mail_client, mail_to, body,