Rev 4727: (mbp) Bazaar can now send mail through Apple OS X Mail.app in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Oct 6 03:38:46 BST 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4727 [merge]
revision-id: pqm at pqm.ubuntu.com-20091006023844-6ir77wbskeru8m3z
parent: pqm at pqm.ubuntu.com-20091005154135-k407ea8ssyhayv10
parent: mbp at sourcefrog.net-20090925013051-7tg33c0zdych2cp1
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2009-10-06 03:38:44 +0100
message:
(mbp) Bazaar can now send mail through Apple OS X Mail.app
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/mail_client.py mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
=== modified file 'NEWS'
--- a/NEWS 2009-10-05 12:50:34 +0000
+++ b/NEWS 2009-10-06 02:38:44 +0000
@@ -15,6 +15,9 @@
New Features
************
+* Bazaar can now send mail through Apple OS X Mail.app.
+ (Brian de Alwis)
+
* ``bzr+ssh`` and ``bzr`` paths can now be relative to home directories
specified in the URL. Paths starting with a path segment of ``~`` are
relative to the home directory of the user running the server, and paths
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2009-09-16 02:52:14 +0000
+++ b/bzrlib/builtins.py 2009-09-24 19:51:37 +0000
@@ -4969,9 +4969,10 @@
To use a specific mail program, set the mail_client configuration option.
(For Thunderbird 1.5, this works around some bugs.) Supported values for
- specific clients are "claws", "evolution", "kmail", "mutt", and
- "thunderbird"; generic options are "default", "editor", "emacsclient",
- "mapi", and "xdg-email". Plugins may also add supported clients.
+ specific clients are "claws", "evolution", "kmail", "mail.app" (MacOS X's
+ Mail.app), "mutt", and "thunderbird"; generic options are "default",
+ "editor", "emacsclient", "mapi", and "xdg-email". Plugins may also add
+ supported clients.
If mail is being sent, a to address is required. This can be supplied
either on the commandline, by setting the submit_to configuration
=== modified file 'bzrlib/mail_client.py'
--- a/bzrlib/mail_client.py 2009-09-02 08:26:27 +0000
+++ b/bzrlib/mail_client.py 2009-09-24 19:51:37 +0000
@@ -539,6 +539,65 @@
help=MAPIClient.__doc__)
+class MailApp(BodyExternalMailClient):
+ """Use MacOS X's Mail.app for sending email messages.
+
+ Although it would be nice to use appscript, it's not installed
+ with the shipped Python installations. We instead build an
+ AppleScript and invoke the script using osascript(1). We don't
+ use the _encode_safe() routines as it's not clear what encoding
+ osascript expects the script to be in.
+ """
+
+ _client_commands = ['osascript']
+
+ def _get_compose_commandline(self, to, subject, attach_path, body=None,
+ from_=None):
+ """See ExternalMailClient._get_compose_commandline"""
+
+ fd, self.temp_file = tempfile.mkstemp(prefix="bzr-send-",
+ suffix=".scpt")
+ try:
+ os.write(fd, 'tell application "Mail"\n')
+ os.write(fd, 'set newMessage to make new outgoing message\n')
+ os.write(fd, 'tell newMessage\n')
+ if to is not None:
+ os.write(fd, 'make new to recipient with properties'
+ ' {address:"%s"}\n' % to)
+ if from_ is not None:
+ # though from_ doesn't actually seem to be used
+ os.write(fd, 'set sender to "%s"\n'
+ % sender.replace('"', '\\"'))
+ if subject is not None:
+ os.write(fd, 'set subject to "%s"\n'
+ % subject.replace('"', '\\"'))
+ if body is not None:
+ # FIXME: would be nice to prepend the body to the
+ # existing content (e.g., preserve signature), but
+ # can't seem to figure out the right applescript
+ # incantation.
+ os.write(fd, 'set content to "%s\\n\n"\n' %
+ body.replace('"', '\\"').replace('\n', '\\n'))
+
+ if attach_path is not None:
+ # FIXME: would be nice to first append a newline to
+ # ensure the attachment is on a new paragraph, but
+ # can't seem to figure out the right applescript
+ # incantation.
+ os.write(fd, 'tell content to make new attachment'
+ ' with properties {file name:"%s"}'
+ ' at after the last paragraph\n'
+ % self._encode_path(attach_path, 'attachment'))
+ os.write(fd, 'set visible to true\n')
+ os.write(fd, 'end tell\n')
+ os.write(fd, 'end tell\n')
+ finally:
+ os.close(fd) # Just close the handle but do not remove the file.
+ return [self.temp_file]
+mail_client_registry.register('mail.app', MailApp,
+ help=MailApp.__doc__)
+
+
class DefaultMail(MailClient):
"""Default mail handling. Tries XDGEmail (or MAPIClient on Windows),
falls back to Editor"""
@@ -575,3 +634,5 @@
mail_client_registry.register('default', DefaultMail,
help=DefaultMail.__doc__)
mail_client_registry.default_key = 'default'
+
+
More information about the bazaar-commits
mailing list