~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Aaron Bentley
  • Date: 2009-05-11 18:35:20 UTC
  • mto: This revision was merged to the branch mainline in revision 4351.
  • Revision ID: aaron@aaronbentley.com-20090511183520-xtvepoauy7zjtb7x
Move hook to MergeDirective, implement MergeDirective.compose_merge_request.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4866
4866
    def _run(self, submit_branch, revision, public_branch, remember, format,
4867
4867
             no_bundle, no_patch, output, from_, mail_to, message, body):
4868
4868
        from bzrlib.revision import NULL_REVISION
4869
 
        branch = Branch.open_containing(from_)[0]
4870
 
        if output is None:
4871
 
            outfile = cStringIO.StringIO()
4872
 
        elif output == '-':
4873
 
            outfile = self.outf
4874
 
        else:
4875
 
            outfile = open(output, 'wb')
 
4869
        tree, branch = bzrdir.BzrDir.open_containing_tree_or_branch(from_)[:2]
4876
4870
        # we may need to write data into branch's repository to calculate
4877
4871
        # the data to send.
4878
4872
        branch.lock_write()
4959
4953
                    public_branch=public_branch, patch_type=patch_type,
4960
4954
                    message=message)
4961
4955
 
4962
 
            outfile.writelines(directive.to_lines())
4963
4956
            if output is None:
4964
 
                subject = '[MERGE] '
4965
 
                if message is not None:
4966
 
                    subject += message
 
4957
                directive.compose_merge_request(mail_client, mail_to, body,
 
4958
                                                branch, tree)
 
4959
            else:
 
4960
                if output == '-':
 
4961
                    outfile = self.outf
4967
4962
                else:
4968
 
                    revision = branch.repository.get_revision(revision_id)
4969
 
                    subject += revision.get_summary()
4970
 
                basename = directive.get_disk_name(branch)
4971
 
                mail_client.compose_merge_request(mail_to, subject,
4972
 
                                                  outfile.getvalue(),
4973
 
                                                  basename, body)
 
4963
                    outfile = open(output, 'wb')
 
4964
                try:
 
4965
                    outfile.writelines(directive.to_lines())
 
4966
                finally:
 
4967
                    if outfile is not self.outf:
 
4968
                        outfile.close()
4974
4969
        finally:
4975
 
            if output != '-':
4976
 
                outfile.close()
4977
4970
            branch.unlock()
4978
4971
 
4979
4972