/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to send_changeset.py

  • Committer: John Arbash Meinel
  • Date: 2005-06-28 22:19:00 UTC
  • mto: (0.5.85) (1185.82.1 bzr-w-changeset)
  • mto: This revision was merged to the branch mainline in revision 1738.
  • Revision ID: john@arbash-meinel.com-20050628221900-2ecec40914076c21
Some cleanup to the send_changeset work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
from email.MIMEText import MIMEText
14
14
 
15
15
 
16
 
def send_changeset(b, revno, to_address, message, file, diff_options):
 
16
def send_changeset(branch, revisions, to_address, message, file):
17
17
    from bzrlib import find_branch
18
18
    from bzrlib.commands import BzrCommandError
19
19
    import gen_changeset
20
20
    import send_changeset
21
 
    import StringIO
 
21
    from cStringIO import StringIO
22
22
 
23
 
    revision = b.get_revision(b.lookup_revision(revno))
 
23
    base_rev_id, target_rev_id = gen_changeset._canonicalize_revision(branch, revisions)
 
24
    rev = branch.get_revision(target_rev_id)
24
25
    if not message:
25
 
        message = revision.message.split('\n')[0]
 
26
        message = rev.message.split('\n')[0]
26
27
 
27
28
    from_address = bzrlib.osutils._get_user_id()
28
29
 
34
35
    # Either read the mail body from the specified file, or spawn
35
36
    # an editor and let the user type a description.
36
37
    if file:
37
 
        mail_body = open(file, "rt").read()
 
38
        mail_body = open(file, "U").read()
38
39
    else:
39
 
        info = "Changset for revision %d by %s\n" % (revno,
40
 
                                                     revision.committer)
 
40
        info = "Changeset by %s\n" % rev.committer
 
41
        info += "From %s\n" % base_rev_id
41
42
        info += "with the following message:\n"
42
 
        for line in revision.message.split('\n'):
 
43
        for line in rev.message.split('\n'):
43
44
            info += "  " + line + "\n"
44
45
 
45
46
        mail_body = bzrlib.osutils.get_text_message(info)
47
48
            raise BzrCommandError("aborted")
48
49
    outer.attach(MIMEText(mail_body))
49
50
    
50
 
    changeset_fp = StringIO.StringIO()
51
 
    gen_changeset.show_changeset(b, revno,
52
 
                                 external_diff_options=diff_options,
53
 
                                 to_file=changeset_fp)
 
51
    changeset_fp = StringIO()
 
52
    gen_changeset.show_changeset(branch, revisions, to_file=changeset_fp)
54
53
    outer.attach(MIMEText(changeset_fp.getvalue()))
55
54
 
56
55
    try:
57
 
        fp = open(os.path.join(bzrlib.osutils.config_dir(), 'smtp-host'), 'rt')
 
56
        fp = open(os.path.join(bzrlib.osutils.config_dir(), 'smtp-host'), 'U')
58
57
        smtpconn = smtplib.SMTP(fp.readline().strip('\n'))
59
58
    except:
60
59
        smtpconn = smtplib.SMTP()