Rev 3049: Mailto address now optional for send with interactive clients (Lalinsky) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Nov 29 14:22:02 GMT 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3049
revision-id:pqm at pqm.ubuntu.com-20071129142155-4yb05lbhm0eiyczd
parent: pqm at pqm.ubuntu.com-20071129084851-xoj1c3u42mxzy5bq
parent: lalinsky at gmail.com-20071129064100-mertwcjmous33fdt
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2007-11-29 14:21:55 +0000
message:
  Mailto address now optional for send with interactive clients (Lalinsky)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
  bzrlib/mail_client.py          mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
  bzrlib/tests/blackbox/test_send.py test_bundle.py-20060616222707-c21c8b7ea5ef57b1
  bzrlib/tests/test_mail_client.py test_mail_client.py-20070809192806-vuxt3t19srtpjpdn-2
    ------------------------------------------------------------
    revno: 3042.1.2
    revision-id:lalinsky at gmail.com-20071129064100-mertwcjmous33fdt
    parent: lalinsky at gmail.com-20071128172710-eaf9o9y8vw2z5joa
    committer: Lukáš Lalinský <lalinsky at gmail.com>
    branch nick: send-optional-address
    timestamp: Thu 2007-11-29 07:41:00 +0100
    message:
      Don't use None as address in TestXDGEmail and add a test to check if it raises NoMailAddressSpecified with None.
    modified:
      bzrlib/tests/test_mail_client.py test_mail_client.py-20070809192806-vuxt3t19srtpjpdn-2
    ------------------------------------------------------------
    revno: 3042.1.1
    revision-id:lalinsky at gmail.com-20071128172710-eaf9o9y8vw2z5joa
    parent: pqm at pqm.ubuntu.com-20071128053506-it05wgucjiw2chfq
    committer: Lukáš Lalinský <lalinsky at gmail.com>
    branch nick: send-optional-address
    timestamp: Wed 2007-11-28 18:27:10 +0100
    message:
      Make mail-to address in ``bzr send`` optional for interactive mail clients.
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
      bzrlib/mail_client.py          mail_client.py-20070809192806-vuxt3t19srtpjpdn-1
      bzrlib/tests/blackbox/test_send.py test_bundle.py-20060616222707-c21c8b7ea5ef57b1
=== modified file 'NEWS'
--- a/NEWS	2007-11-29 00:22:51 +0000
+++ b/NEWS	2007-11-29 14:21:55 +0000
@@ -59,6 +59,10 @@
 
   IMPROVEMENTS:
 
+   * ``bzr send`` now doesn't require the target e-mail address to be
+     specified on the command line if an interactive e-mail client is used.
+     (Lukáš Lalinský)
+
    * ``bzr tags`` now prints the revision number for each tag, instead of
      the revision id, unless --show-ids is passed. In addition, tags can be
      sorted chronologically instead of lexicographically with --sort=time.

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2007-11-27 22:18:18 +0000
+++ b/bzrlib/builtins.py	2007-11-28 17:27:10 +0000
@@ -4015,9 +4015,6 @@
                 config = branch.get_config()
                 if mail_to is None:
                     mail_to = config.get_user_option('submit_to')
-                if mail_to is None:
-                    raise errors.BzrCommandError('No mail-to address'
-                                                 ' specified')
                 mail_client = config.get_mail_client()
             if remember and submit_branch is None:
                 raise errors.BzrCommandError(

=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py	2007-11-27 14:38:38 +0000
+++ b/bzrlib/errors.py	2007-11-28 17:27:10 +0000
@@ -2381,6 +2381,11 @@
     _fmt = "No message supplied."
 
 
+class NoMailAddressSpecified(BzrError):
+
+    _fmt = "No mail-to address specified."
+
+
 class UnknownMailClient(BzrError):
 
     _fmt = "Unknown mail client: %(mail_client)s"

=== modified file 'bzrlib/mail_client.py'
--- a/bzrlib/mail_client.py	2007-09-03 23:54:22 +0000
+++ b/bzrlib/mail_client.py	2007-11-28 17:27:10 +0000
@@ -92,6 +92,8 @@
     def compose(self, prompt, to, subject, attachment, mime_subtype,
                 extension):
         """See MailClient.compose"""
+        if not to:
+            raise errors.NoMailAddressSpecified()
         body = msgeditor.edit_commit_message(prompt)
         if body == '':
             raise errors.NoMessageSupplied()
@@ -253,6 +255,8 @@
 
     def _get_compose_commandline(self, to, subject, attach_path):
         """See ExternalMailClient._get_compose_commandline"""
+        if not to:
+            raise errors.NoMailAddressSpecified()
         commandline = [to]
         if subject is not None:
             commandline.extend(['--subject', subject])

=== modified file 'bzrlib/tests/blackbox/test_send.py'
--- a/bzrlib/tests/blackbox/test_send.py	2007-08-24 20:32:51 +0000
+++ b/bzrlib/tests/blackbox/test_send.py	2007-11-28 17:27:10 +0000
@@ -192,8 +192,9 @@
     def test_mailto_option(self):
         self.make_trees()
         branch = _mod_branch.Branch.open('branch')
+        branch.get_config().set_user_option('mail_client', 'editor')
+        self.run_bzr_error(('No mail-to address specified',), 'send -f branch')
         branch.get_config().set_user_option('mail_client', 'bogus')
-        self.run_bzr_error(('No mail-to address specified',), 'send -f branch')
         self.run_bzr('send -f branch -o-')
         self.run_bzr_error(('Unknown mail client: bogus',),
                            'send -f branch --mail-to jrandom at example.org')

=== modified file 'bzrlib/tests/test_mail_client.py'
--- a/bzrlib/tests/test_mail_client.py	2007-09-03 23:54:22 +0000
+++ b/bzrlib/tests/test_mail_client.py	2007-11-29 06:41:00 +0000
@@ -15,6 +15,7 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 from bzrlib import (
+    errors,
     mail_client,
     tests,
     urlutils,
@@ -50,9 +51,13 @@
 
     def test_commandline(self):
         xdg_email = mail_client.XDGEmail(None)
-        commandline = xdg_email._get_compose_commandline(None, None,
-                                                         'file%')
-        self.assertEqual([None, '--attach', 'file%'], commandline)
+        self.assertRaises(errors.NoMailAddressSpecified,
+                          xdg_email._get_compose_commandline,
+                          None, None, 'file%')
+        commandline = xdg_email._get_compose_commandline(
+            'jrandom at example.org', None, 'file%')
+        self.assertEqual(['jrandom at example.org', '--attach', 'file%'],
+                         commandline)
         commandline = xdg_email._get_compose_commandline(
             'jrandom at example.org', 'Hi there!', None)
         self.assertEqual(['jrandom at example.org', '--subject', 'Hi there!'],




More information about the bazaar-commits mailing list