{"thread":{"id":"21815","subject":"[StGit PATCH v2 1/6] stg mail: Refactor __send_message and friends","startedAt":"2009-12-02T00:46:00Z","lastAt":"2009-12-07T07:09:02Z","messageCount":19,"participants":["Alex Chiang","Karl Wiberg","Catalin Marinas"],"isPatch":true,"patchVersion":2,"patchTotal":6},"messages":[{"id":"128941","messageId":"20091202003503.7737.51579.stgit@bob.kio","threadId":"21815","inReplyTo":null,"subject":"[StGit PATCH v2 0/6] add support for git send-email","fromName":"Alex Chiang","fromEmail":"achiang@hp.com","sentAt":"2009-12-02T00:46:00Z","receivedAt":"2009-12-02T00:46:00Z","isPatch":true,"sender":{"key":"achiang@hp.com","avatar":null},"body":"This is v2 of the series that starts teaching stg mail how to\ncall git send-email.\n\nI made all the changes that Karl recommended, and made sure to\nrun the t1900-mail.sh test at every point in the series (passes\nsuccessfully).\n\nI also experimented with adding another test case for --git\nmode, basically duplicating t1900-mail.sh, and then adding the\n--git argument wherever it made sense.\n\nHowever, that resulted in failure of the last 3 test cases,\nwhich is due to the fact that we no longer parse To/Cc/Bcc\ncommand line args in --git mode, and the resulting mbox file was\nmissing the expected recipient addresses.\n\nI played around with that for a while, thinking that I could use\ngit send-email --dry-run to do something equivalent, but then\nrealized that git send-email's run-run mode is definitely not\nanalogous to stg mail's --mbox mode.\n\nThe upshot is that in stg mail, --git and --mbox don't interact\nwell, and the resulting mbox file will lack the recipients. This\nmight be fixed in the future if we teach git send-email how to\ngenerate mbox files, but then we introduce a versioning problem.\n\nSo let's just accept this wart for now, and say, if you want an\nmbox file generated, don't use --git. That seems reasonable to\nme.\n\nThis mail was sent with the following command line:\n\n\t./stg mail --git -a -e --auto -v v2 --prefix=StGit\n\t--to=catalin.marinas@gmail.com --cc=git\n\nNote that the --cc= contains an alias for the git mailing list\nthat I defined in my ~/.mutt.aliases file (and specified in\n.gitconfig -> sendemail.aliasesfile and sendemail.aliasfiletype.\n\nThanks,\n/ac\n\n---\n\nAlex Chiang (6):\n      stg mail: Refactor __send_message and friends\n      stg mail: reorder __build_[message|cover] parameters\n      stg mail: make __send_message do more\n      stg mail: factor out __update_header\n      stg mail: add basic support for git send-email\n      stg mail: don't parse To/Cc/Bcc in --git mode\n\n\n stgit/commands/mail.py |  196 +++++++++++++++++++++++++++---------------------\n 1 files changed, 112 insertions(+), 84 deletions(-)\n"},{"id":"128940","messageId":"20091202004605.7737.2077.stgit@bob.kio","threadId":"21815","inReplyTo":"20091202003503.7737.51579.stgit@bob.kio","subject":"[StGit PATCH v2 1/6] stg mail: Refactor __send_message and friends","fromName":"Alex Chiang","fromEmail":"achiang@hp.com","sentAt":"2009-12-02T00:46:06Z","receivedAt":"2009-12-02T00:46:06Z","isPatch":true,"sender":{"key":"achiang@hp.com","avatar":null},"body":"Instead of passing all the various smtp* args to __send_message\nindividually, let's just pass the options list instead.\n\nThe main motivation is for future patches. The end goal is to\nthin out stg mail's implementation and make it a minimal wrapper\naround git send-email. By passing the options list to __send_message\nwe prepare to pass options directly to git send-email.\n\nAs a bonus, this change results in a cleaner internal API.\n\nFinally, it also pushes the smtp logic where it belongs, viz. into\n__send_message_smtp, instead of cluttering up the main body of\nmail.func().\n\nCc: Karl Wiberg <kha@treskal.com>\nSigned-off-by: Alex Chiang <achiang@hp.com>\n---\n\n stgit/commands/mail.py |   43 +++++++++++++++++++------------------------\n 1 files changed, 19 insertions(+), 24 deletions(-)\n\ndiff --git a/stgit/commands/mail.py b/stgit/commands/mail.py\nindex abd42e4..a38e3e6 100644\n--- a/stgit/commands/mail.py\n+++ b/stgit/commands/mail.py\n@@ -190,10 +190,20 @@ def __send_message_sendmail(sendmail, msg):\n     cmd = sendmail.split()\n     Run(*cmd).raw_input(msg).discard_output()\n \n-def __send_message_smtp(smtpserver, from_addr, to_addr_list, msg,\n-                        smtpuser, smtppassword, use_tls):\n+def __send_message_smtp(smtpserver, from_addr, to_addr_list, msg, options):\n     \"\"\"Send the message using the given SMTP server\n     \"\"\"\n+    smtppassword = options.smtp_password or config.get('stgit.smtppassword')\n+    smtpuser = options.smtp_user or config.get('stgit.smtpuser')\n+    smtpusetls = options.smtp_tls or config.get('stgit.smtptls') == 'yes'\n+\n+    if (smtppassword and not smtpuser):\n+        raise Exception('SMTP password supplied, username needed')\n+    if (smtpusetls and not smtpuser):\n+        raise Exception('SMTP over TLS requested, username needed')\n+    if (smtpuser and not smtppassword):\n+        smtppassword = getpass.getpass(\"Please enter SMTP password: \")\n+\n     try:\n         s = smtplib.SMTP(smtpserver)\n     except Exception, err:\n@@ -203,7 +213,7 @@ def __send_message_smtp(smtpserver, from_addr, to_addr_list, msg,\n     try:\n         if smtpuser and smtppassword:\n             s.ehlo()\n-            if use_tls:\n+            if smtpusetls:\n                 if not hasattr(socket, 'ssl'):\n                     raise CmdException,  \"cannot use TLS - no SSL support in Python\"\n                 s.starttls()\n@@ -218,17 +228,17 @@ def __send_message_smtp(smtpserver, from_addr, to_addr_list, msg,\n \n     s.quit()\n \n-def __send_message(smtpserver, from_addr, to_addr_list, msg,\n-                   smtpuser, smtppassword, use_tls):\n+def __send_message(from_addr, to_addr_list, msg, options):\n     \"\"\"Message sending dispatcher.\n     \"\"\"\n+    smtpserver = options.smtp_server or config.get('stgit.smtpserver')\n+\n     if smtpserver.startswith('/'):\n         # Use the sendmail tool\n         __send_message_sendmail(smtpserver, msg)\n     else:\n         # Use the SMTP server (we have host and port information)\n-        __send_message_smtp(smtpserver, from_addr, to_addr_list, msg,\n-                            smtpuser, smtppassword, use_tls)\n+        __send_message_smtp(smtpserver, from_addr, to_addr_list, msg, options)\n \n def __build_address_headers(msg, options, extra_cc = []):\n     \"\"\"Build the address headers and check existing headers in the\n@@ -543,8 +553,6 @@ def func(parser, options, args):\n     \"\"\"Send the patches by e-mail using the patchmail.tmpl file as\n     a template\n     \"\"\"\n-    smtpserver = options.smtp_server or config.get('stgit.smtpserver')\n-\n     applied = crt_series.get_applied()\n \n     if options.all:\n@@ -564,17 +572,6 @@ def func(parser, options, args):\n             raise CmdException, 'Cannot send empty patch \"%s\"' % p\n     out.done()\n \n-    smtppassword = options.smtp_password or config.get('stgit.smtppassword')\n-    smtpuser = options.smtp_user or config.get('stgit.smtpuser')\n-    smtpusetls = options.smtp_tls or config.get('stgit.smtptls') == 'yes'\n-\n-    if (smtppassword and not smtpuser):\n-        raise CmdException, 'SMTP password supplied, username needed'\n-    if (smtpusetls and not smtpuser):\n-        raise CmdException, 'SMTP over TLS requested, username needed'\n-    if (smtpuser and not smtppassword):\n-        smtppassword = getpass.getpass(\"Please enter SMTP password: \")\n-\n     total_nr = len(patches)\n     if total_nr == 0:\n         raise CmdException, 'No patches to send'\n@@ -616,8 +613,7 @@ def func(parser, options, args):\n             out.stdout_raw(msg_string + '\\n')\n         else:\n             out.start('Sending the cover message')\n-            __send_message(smtpserver, from_addr, to_addr_list, msg_string,\n-                           smtpuser, smtppassword, smtpusetls)\n+            __send_message(from_addr, to_addr_list, msg_string, options)\n             time.sleep(sleep)\n             out.done()\n \n@@ -648,8 +644,7 @@ def func(parser, options, args):\n             out.stdout_raw(msg_string + '\\n')\n         else:\n             out.start('Sending patch \"%s\"' % p)\n-            __send_message(smtpserver, from_addr, to_addr_list, msg_string,\n-                           smtpuser, smtppassword, smtpusetls)\n+            __send_message(from_addr, to_addr_list, msg_string, options)\n             # give recipients a chance of receiving related patches in the\n             # correct order.\n             if patch_nr < total_nr:\n"},{"id":"128943","messageId":"20091202004611.7737.85922.stgit@bob.kio","threadId":"21815","inReplyTo":"20091202003503.7737.51579.stgit@bob.kio","subject":"[StGit PATCH v2 2/6] stg mail: reorder __build_[message|cover] parameters","fromName":"Alex Chiang","fromEmail":"achiang@hp.com","sentAt":"2009-12-02T00:46:11Z","receivedAt":"2009-12-02T00:46:11Z","isPatch":true,"sender":{"key":"achiang@hp.com","avatar":null},"body":"Reorder the argument lists for both __build_cover and __build_message.\n\nThis change will aid readability of a subsequent refactoring patch.\n\nCc: Karl Wiberg <kha@treskal.com>\nSigned-off-by: Alex Chiang <achiang@hp.com>\n---\n\n stgit/commands/mail.py |   10 +++++-----\n 1 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/stgit/commands/mail.py b/stgit/commands/mail.py\nindex a38e3e6..35194a8 100644\n--- a/stgit/commands/mail.py\n+++ b/stgit/commands/mail.py\n@@ -370,7 +370,7 @@ def __edit_message(msg):\n \n     return msg\n \n-def __build_cover(tmpl, patches, msg_id, options):\n+def __build_cover(tmpl, msg_id, options, patches):\n     \"\"\"Build the cover message (series description) to be sent via SMTP\n     \"\"\"\n     sender = __get_sender()\n@@ -439,7 +439,7 @@ def __build_cover(tmpl, patches, msg_id, options):\n \n     return msg\n \n-def __build_message(tmpl, patch, patch_nr, total_nr, msg_id, ref_id, options):\n+def __build_message(tmpl, msg_id, options, patch, patch_nr, total_nr, ref_id):\n     \"\"\"Build the message to be sent via SMTP\n     \"\"\"\n     p = crt_series.get_patch(patch)\n@@ -600,7 +600,7 @@ def func(parser, options, args):\n                 raise CmdException, 'No cover message template file found'\n \n         msg_id = email.Utils.make_msgid('stgit')\n-        msg = __build_cover(tmpl, patches, msg_id, options)\n+        msg = __build_cover(tmpl, msg_id, options, patches)\n         from_addr, to_addr_list = __parse_addresses(msg)\n \n         msg_string = msg.as_string(options.mbox)\n@@ -630,8 +630,8 @@ def func(parser, options, args):\n \n     for (p, patch_nr) in zip(patches, range(1, total_nr + 1)):\n         msg_id = email.Utils.make_msgid('stgit')\n-        msg = __build_message(tmpl, p, patch_nr, total_nr, msg_id, ref_id,\n-                              options)\n+        msg = __build_message(tmpl, msg_id, options, p, patch_nr, total_nr,\n+                              ref_id)\n         from_addr, to_addr_list = __parse_addresses(msg)\n \n         msg_string = msg.as_string(options.mbox)\n"},{"id":"128945","messageId":"20091202004616.7737.60382.stgit@bob.kio","threadId":"21815","inReplyTo":"20091202003503.7737.51579.stgit@bob.kio","subject":"[StGit PATCH v2 3/6] stg mail: make __send_message do more","fromName":"Alex Chiang","fromEmail":"achiang@hp.com","sentAt":"2009-12-02T00:46:16Z","receivedAt":"2009-12-02T00:46:16Z","isPatch":true,"sender":{"key":"achiang@hp.com","avatar":null},"body":"Factor out the common code required to send either a cover mail\nor patch, and implement it in __send_message.\n\nWRY? DRY.\n\nCc: Karl Wiberg <kha@treskal.com>\nSigned-off-by: Alex Chiang <achiang@hp.com>\n---\n\n stgit/commands/mail.py |   65 +++++++++++++++++++++---------------------------\n 1 files changed, 29 insertions(+), 36 deletions(-)\n\ndiff --git a/stgit/commands/mail.py b/stgit/commands/mail.py\nindex 35194a8..edff878 100644\n--- a/stgit/commands/mail.py\n+++ b/stgit/commands/mail.py\n@@ -228,17 +228,39 @@ def __send_message_smtp(smtpserver, from_addr, to_addr_list, msg, options):\n \n     s.quit()\n \n-def __send_message(from_addr, to_addr_list, msg, options):\n+def __send_message(type, tmpl, options, *args):\n     \"\"\"Message sending dispatcher.\n     \"\"\"\n-    smtpserver = options.smtp_server or config.get('stgit.smtpserver')\n+    (build, outstr) = {'cover': (__build_cover, 'the cover message'),\n+                       'patch': (__build_message, 'patch \"%s\"' % args[0])}[type]\n+    if type == 'patch':\n+        (patch_nr, total_nr) = (args[1], args[2])\n+\n+    msg_id = email.Utils.make_msgid('stgit')\n+    msg = build(tmpl, msg_id, options, *args)\n+\n+    from_addr, to_addrs = __parse_addresses(msg)\n+    msg_str = msg.as_string(options.mbox)\n+    if options.mbox:\n+        out.stdout_raw(msg_str + '\\n')\n+        return msg_id\n+\n+    out.start('Sending ' + outstr)\n \n+    smtpserver = options.smtp_server or config.get('stgit.smtpserver')\n     if smtpserver.startswith('/'):\n         # Use the sendmail tool\n-        __send_message_sendmail(smtpserver, msg)\n+        __send_message_sendmail(smtpserver, msg_str)\n     else:\n         # Use the SMTP server (we have host and port information)\n-        __send_message_smtp(smtpserver, from_addr, to_addr_list, msg, options)\n+        __send_message_smtp(smtpserver, from_addr, to_addrs, msg_str, options)\n+\n+    # give recipients a chance of receiving related patches in correct order\n+    if type == 'cover' or (type == 'patch' and patch_nr < total_nr):\n+        sleep = options.sleep or config.getint('stgit.smtpdelay')\n+        time.sleep(sleep)\n+    out.done()\n+    return msg_id\n \n def __build_address_headers(msg, options, extra_cc = []):\n     \"\"\"Build the address headers and check existing headers in the\n@@ -584,7 +606,6 @@ def func(parser, options, args):\n     else:\n         ref_id = None\n \n-    sleep = options.sleep or config.getint('stgit.smtpdelay')\n \n     # send the cover message (if any)\n     if options.cover or options.edit_cover:\n@@ -599,24 +620,12 @@ def func(parser, options, args):\n             if not tmpl:\n                 raise CmdException, 'No cover message template file found'\n \n-        msg_id = email.Utils.make_msgid('stgit')\n-        msg = __build_cover(tmpl, msg_id, options, patches)\n-        from_addr, to_addr_list = __parse_addresses(msg)\n-\n-        msg_string = msg.as_string(options.mbox)\n+        msg_id = __send_message('cover', tmpl, options, patches)\n \n         # subsequent e-mails are seen as replies to the first one\n         if not options.noreply:\n             ref_id = msg_id\n \n-        if options.mbox:\n-            out.stdout_raw(msg_string + '\\n')\n-        else:\n-            out.start('Sending the cover message')\n-            __send_message(from_addr, to_addr_list, msg_string, options)\n-            time.sleep(sleep)\n-            out.done()\n-\n     # send the patches\n     if options.template:\n         tmpl = file(options.template).read()\n@@ -628,25 +637,9 @@ def func(parser, options, args):\n         if not tmpl:\n             raise CmdException, 'No e-mail template file found'\n \n-    for (p, patch_nr) in zip(patches, range(1, total_nr + 1)):\n-        msg_id = email.Utils.make_msgid('stgit')\n-        msg = __build_message(tmpl, msg_id, options, p, patch_nr, total_nr,\n-                              ref_id)\n-        from_addr, to_addr_list = __parse_addresses(msg)\n-\n-        msg_string = msg.as_string(options.mbox)\n+    for (p, n) in zip(patches, range(1, total_nr + 1)):\n+        msg_id = __send_message('patch', tmpl, options, p, n, total_nr, ref_id)\n \n         # subsequent e-mails are seen as replies to the first one\n         if not options.noreply and not options.unrelated and not ref_id:\n             ref_id = msg_id\n-\n-        if options.mbox:\n-            out.stdout_raw(msg_string + '\\n')\n-        else:\n-            out.start('Sending patch \"%s\"' % p)\n-            __send_message(from_addr, to_addr_list, msg_string, options)\n-            # give recipients a chance of receiving related patches in the\n-            # correct order.\n-            if patch_nr < total_nr:\n-                time.sleep(sleep)\n-            out.done()\n"},{"id":"128942","messageId":"20091202004622.7737.78332.stgit@bob.kio","threadId":"21815","inReplyTo":"20091202003503.7737.51579.stgit@bob.kio","subject":"[StGit PATCH v2 4/6] stg mail: factor out __update_header","fromName":"Alex Chiang","fromEmail":"achiang@hp.com","sentAt":"2009-12-02T00:46:22Z","receivedAt":"2009-12-02T00:46:22Z","isPatch":true,"sender":{"key":"achiang@hp.com","avatar":null},"body":"Factor __update_header out of __build_address_headers.\n\nHeaders like Reply-To, Mail-Reply-To, and Mail-Followup-To are now\nhandled in __build_extra_headers.\n\nWe make this change because in the future, we do not want to call\n__build_address_headers if using git send-email but we will always\nwant to call __build_extra_headers.\n\nCc: Karl Wiberg <kha@treskal.com>\nSigned-off-by: Alex Chiang <achiang@hp.com>\n---\n\n stgit/commands/mail.py |   48 +++++++++++++++++++++++++-----------------------\n 1 files changed, 25 insertions(+), 23 deletions(-)\n\ndiff --git a/stgit/commands/mail.py b/stgit/commands/mail.py\nindex edff878..f430a13 100644\n--- a/stgit/commands/mail.py\n+++ b/stgit/commands/mail.py\n@@ -262,25 +262,25 @@ def __send_message(type, tmpl, options, *args):\n     out.done()\n     return msg_id\n \n-def __build_address_headers(msg, options, extra_cc = []):\n-    \"\"\"Build the address headers and check existing headers in the\n-    template.\n-    \"\"\"\n+def __update_header(msg, header, addr = '', ignore = ()):\n     def __addr_pairs(msg, header, extra):\n         pairs = email.Utils.getaddresses(msg.get_all(header, []) + extra)\n         # remove pairs without an address and resolve the aliases\n         return [address_or_alias(p) for p in pairs if p[1]]\n \n-    def __update_header(header, addr = '', ignore = ()):\n-        addr_pairs = __addr_pairs(msg, header, [addr])\n-        del msg[header]\n-        # remove the duplicates and filter the addresses\n-        addr_dict = dict((addr, email.Utils.formataddr((name, addr)))\n-                         for name, addr in addr_pairs if addr not in ignore)\n-        if addr_dict:\n-            msg[header] = ', '.join(addr_dict.itervalues())\n-        return set(addr_dict.iterkeys())\n+    addr_pairs = __addr_pairs(msg, header, [addr])\n+    del msg[header]\n+    # remove the duplicates and filter the addresses\n+    addr_dict = dict((addr, email.Utils.formataddr((name, addr)))\n+                     for name, addr in addr_pairs if addr not in ignore)\n+    if addr_dict:\n+        msg[header] = ', '.join(addr_dict.itervalues())\n+    return set(addr_dict.iterkeys())\n \n+def __build_address_headers(msg, options, extra_cc = []):\n+    \"\"\"Build the address headers and check existing headers in the\n+    template.\n+    \"\"\"\n     to_addr = ''\n     cc_addr = ''\n     extra_cc_addr = ''\n@@ -300,18 +300,14 @@ def __build_address_headers(msg, options, extra_cc = []):\n         bcc_addr = autobcc\n \n     # if an address is on a header, ignore it from the rest\n-    to_set = __update_header('To', to_addr)\n-    cc_set = __update_header('Cc', cc_addr, to_set)\n-    bcc_set = __update_header('Bcc', bcc_addr, to_set.union(cc_set))\n+    to_set = __update_header(msg, 'To', to_addr)\n+    cc_set = __update_header(msg, 'Cc', cc_addr, to_set)\n+    bcc_set = __update_header(msg, 'Bcc', bcc_addr, to_set.union(cc_set))\n \n     # --auto generated addresses, don't include the sender\n-    from_set = __update_header('From')\n-    __update_header('Cc', extra_cc_addr, to_set.union(bcc_set).union(from_set))\n-\n-    # update other address headers\n-    __update_header('Reply-To')\n-    __update_header('Mail-Reply-To')\n-    __update_header('Mail-Followup-To')\n+    from_set = __update_header(msg, 'From')\n+    __update_header(msg, 'Cc', extra_cc_addr,\n+                    to_set.union(bcc_set).union(from_set))\n \n def __get_signers_list(msg):\n     \"\"\"Return the address list generated from signed-off-by and\n@@ -349,6 +345,12 @@ def __build_extra_headers(msg, msg_id, ref_id = None):\n         msg['References'] = ref_id\n     msg['User-Agent'] = 'StGit/%s' % version.version\n \n+    # update other address headers\n+    __update_header(msg, 'Reply-To')\n+    __update_header(msg, 'Mail-Reply-To')\n+    __update_header(msg, 'Mail-Followup-To')\n+\n+\n def __encode_message(msg):\n     # 7 or 8 bit encoding\n     charset = email.Charset.Charset('utf-8')\n"},{"id":"128944","messageId":"20091202004627.7737.23460.stgit@bob.kio","threadId":"21815","inReplyTo":"20091202003503.7737.51579.stgit@bob.kio","subject":"[StGit PATCH v2 5/6] stg mail: add basic support for git send-email","fromName":"Alex Chiang","fromEmail":"achiang@hp.com","sentAt":"2009-12-02T00:46:27Z","receivedAt":"2009-12-02T00:46:27Z","isPatch":true,"sender":{"key":"achiang@hp.com","avatar":null},"body":"This is the first step in turning stg mail into a wrapper for\ngit send-email. It requires passing the --git option to stg mail\nfor now.\n\nOnly a few basic options are supported for now, namely To/Cc/Bcc.\n\ngit send-email options used:\n  --suppress-cc=self\tprevent further information prompts\n  --quiet\t\treduce git send-email output\n\nCc: Karl Wiberg <kha@treskal.com>\nSigned-off-by: Alex Chiang <achiang@hp.com>\n---\n\n stgit/commands/mail.py |   50 ++++++++++++++++++++++++++++++++++++++++++++----\n 1 files changed, 46 insertions(+), 4 deletions(-)\n\ndiff --git a/stgit/commands/mail.py b/stgit/commands/mail.py\nindex f430a13..8a33c22 100644\n--- a/stgit/commands/mail.py\n+++ b/stgit/commands/mail.py\n@@ -140,7 +140,9 @@ options = [\n     opt('-b', '--branch', args = [argparse.stg_branches],\n         short = 'Use BRANCH instead of the default branch'),\n     opt('-m', '--mbox', action = 'store_true',\n-        short = 'Generate an mbox file instead of sending')\n+        short = 'Generate an mbox file instead of sending'),\n+    opt('--git', action = 'store_true',\n+        short = 'Use git send-email (EXPERIMENTAL)')\n     ] + argparse.diff_opts_option()\n \n directory = DirectoryHasRepository(log = False)\n@@ -228,6 +230,42 @@ def __send_message_smtp(smtpserver, from_addr, to_addr_list, msg, options):\n \n     s.quit()\n \n+def __send_message_git(msg, options):\n+    \"\"\"Send the message using git send-email\n+    \"\"\"\n+    from subprocess import call\n+    from tempfile import mkstemp\n+\n+    cmd = [\"git\", \"send-email\", \"--from=%s\" % msg['From']]\n+    cmd.append(\"--quiet\")\n+    cmd.append(\"--suppress-cc=self\")\n+    if not options.auto:\n+        cmd.append(\"--suppress-cc=body\")\n+\n+    # We only support To/Cc/Bcc in git send-email for now.\n+    for x in ['to', 'cc', 'bcc']:\n+        if getattr(options, x):\n+            cmd.extend('--%s=%s' % (x, a) for a in getattr(options, x))\n+\n+    # XXX: hack for now so that we don't duplicate To/Cc/Bcc headers\n+    # in the mail, as git send-email inserts those for us.\n+    del msg['To']\n+    del msg['Cc']\n+    del msg['Bcc']\n+\n+    (fd, path) = mkstemp()\n+    os.write(fd, msg.as_string(options.mbox))\n+    os.close(fd)\n+\n+    try:\n+        try:\n+            cmd.append(path)\n+            call(cmd)\n+        except Exception, err:\n+            raise CmdException, str(err)\n+    finally:\n+        os.unlink(path)\n+\n def __send_message(type, tmpl, options, *args):\n     \"\"\"Message sending dispatcher.\n     \"\"\"\n@@ -245,10 +283,13 @@ def __send_message(type, tmpl, options, *args):\n         out.stdout_raw(msg_str + '\\n')\n         return msg_id\n \n-    out.start('Sending ' + outstr)\n+    if not options.git:\n+        out.start('Sending ' + outstr)\n \n     smtpserver = options.smtp_server or config.get('stgit.smtpserver')\n-    if smtpserver.startswith('/'):\n+    if options.git:\n+        __send_message_git(msg, options)\n+    elif smtpserver.startswith('/'):\n         # Use the sendmail tool\n         __send_message_sendmail(smtpserver, msg_str)\n     else:\n@@ -259,7 +300,8 @@ def __send_message(type, tmpl, options, *args):\n     if type == 'cover' or (type == 'patch' and patch_nr < total_nr):\n         sleep = options.sleep or config.getint('stgit.smtpdelay')\n         time.sleep(sleep)\n-    out.done()\n+    if not options.git:\n+        out.done()\n     return msg_id\n \n def __update_header(msg, header, addr = '', ignore = ()):\n"},{"id":"128946","messageId":"20091202004632.7737.84887.stgit@bob.kio","threadId":"21815","inReplyTo":"20091202003503.7737.51579.stgit@bob.kio","subject":"[StGit PATCH v2 6/6] stg mail: don't parse To/Cc/Bcc in --git mode","fromName":"Alex Chiang","fromEmail":"achiang@hp.com","sentAt":"2009-12-02T00:46:33Z","receivedAt":"2009-12-02T00:46:33Z","isPatch":true,"sender":{"key":"achiang@hp.com","avatar":null},"body":"When using stg mail in --git mode, do not parse command-line To/Cc/Bcc\naddresses.\n\nInstead, we pass them directly to git send-email.\n\nThis allows us to leverage git send-email's support for email aliases.\n\nCc: Karl Wiberg <kha@treskal.com>\nSigned-off-by: Alex Chiang <achiang@hp.com>\n---\n\n stgit/commands/mail.py |   14 +++++---------\n 1 files changed, 5 insertions(+), 9 deletions(-)\n\ndiff --git a/stgit/commands/mail.py b/stgit/commands/mail.py\nindex 8a33c22..d108e75 100644\n--- a/stgit/commands/mail.py\n+++ b/stgit/commands/mail.py\n@@ -247,12 +247,6 @@ def __send_message_git(msg, options):\n         if getattr(options, x):\n             cmd.extend('--%s=%s' % (x, a) for a in getattr(options, x))\n \n-    # XXX: hack for now so that we don't duplicate To/Cc/Bcc headers\n-    # in the mail, as git send-email inserts those for us.\n-    del msg['To']\n-    del msg['Cc']\n-    del msg['Bcc']\n-\n     (fd, path) = mkstemp()\n     os.write(fd, msg.as_string(options.mbox))\n     os.close(fd)\n@@ -277,13 +271,13 @@ def __send_message(type, tmpl, options, *args):\n     msg_id = email.Utils.make_msgid('stgit')\n     msg = build(tmpl, msg_id, options, *args)\n \n-    from_addr, to_addrs = __parse_addresses(msg)\n     msg_str = msg.as_string(options.mbox)\n     if options.mbox:\n         out.stdout_raw(msg_str + '\\n')\n         return msg_id\n \n     if not options.git:\n+        from_addr, to_addrs = __parse_addresses(msg)\n         out.start('Sending ' + outstr)\n \n     smtpserver = options.smtp_server or config.get('stgit.smtpserver')\n@@ -499,7 +493,8 @@ def __build_cover(tmpl, msg_id, options, patches):\n     except Exception, ex:\n         raise CmdException, 'template parsing error: %s' % str(ex)\n \n-    __build_address_headers(msg, options)\n+    if not options.git:\n+        __build_address_headers(msg, options)\n     __build_extra_headers(msg, msg_id, options.refid)\n     __encode_message(msg)\n \n@@ -609,7 +604,8 @@ def __build_message(tmpl, msg_id, options, patch, patch_nr, total_nr, ref_id):\n     else:\n         extra_cc = []\n \n-    __build_address_headers(msg, options, extra_cc)\n+    if not options.git:\n+        __build_address_headers(msg, options, extra_cc)\n     __build_extra_headers(msg, msg_id, ref_id)\n     __encode_message(msg)\n \n"},{"id":"128974","messageId":"b8197bcb0912012246n3b83866cjb93654effc000242@mail.gmail.com","threadId":"21815","inReplyTo":"20091202003503.7737.51579.stgit@bob.kio","subject":"Re: [StGit PATCH v2 0/6] add support for git send-email","fromName":"Karl Wiberg","fromEmail":"kha@treskal.com","sentAt":"2009-12-02T06:46:02Z","receivedAt":"2009-12-02T06:46:02Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On Wed, Dec 2, 2009 at 1:46 AM, Alex Chiang <achiang@hp.com> wrote:\n\n> I also experimented with adding another test case for --git mode,\n> basically duplicating t1900-mail.sh, and then adding the --git\n> argument wherever it made sense.\n\nAh, good.\n\n> However, that resulted in failure of the last 3 test cases, which is\n> due to the fact that we no longer parse To/Cc/Bcc command line args\n> in --git mode, and the resulting mbox file was missing the expected\n> recipient addresses.\n>\n> I played around with that for a while, thinking that I could use git\n> send-email --dry-run to do something equivalent, but then realized\n> that git send-email's run-run mode is definitely not analogous to\n> stg mail's --mbox mode.\n>\n> The upshot is that in stg mail, --git and --mbox don't interact\n> well, and the resulting mbox file will lack the recipients. This\n> might be fixed in the future if we teach git send-email how to\n> generate mbox files, but then we introduce a versioning problem.\n\nOne wild idea: git send-email's --smtp-server flag will accept the\n(full) path of a sendmail program; writing such a program, just\ncapable enough to receive the outgoing emails and dumping them to a\nfile, should be easy. Another option would be a program that speaks\njust enough SMTP to accept the mails. (Incidentally, these two would\nbe useful in testing stg mail even without the --git option.)\n\nI fully understand if you'd rather get on with scratching your actual\nitch, though ...\n\n> So let's just accept this wart for now, and say, if you want an mbox\n> file generated, don't use --git. That seems reasonable to me.\n\nSure.\n\n-- \nKarl Wiberg, kha@treskal.com\n   subrabbit.wordpress.com\n   www.treskal.com/kalle\n"},{"id":"128975","messageId":"b8197bcb0912012253l399bb542sab141021e7ff6353@mail.gmail.com","threadId":"21815","inReplyTo":"20091202004605.7737.2077.stgit@bob.kio","subject":"Re: [StGit PATCH v2 1/6] stg mail: Refactor __send_message and friends","fromName":"Karl Wiberg","fromEmail":"kha@treskal.com","sentAt":"2009-12-02T06:53:26Z","receivedAt":"2009-12-02T06:53:26Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On Wed, Dec 2, 2009 at 1:46 AM, Alex Chiang <achiang@hp.com> wrote:\n\n> +    if (smtppassword and not smtpuser):\n> +        raise Exception('SMTP password supplied, username needed')\n> +    if (smtpusetls and not smtpuser):\n> +        raise Exception('SMTP over TLS requested, username needed')\n> +    if (smtpuser and not smtppassword):\n> +        smtppassword = getpass.getpass(\"Please enter SMTP password: \")\n\nSorry if I confused you with my earlier explanation; I only meant that\nyou should use the _form_ \"raise Exception('message')\", not that you\nshould change the exception type from CmdException to Exception. If\nyou try to trigger these errors, I think you'll find that in the case\nof CmdException, StGit will print just the message and exit with an\nerror; whereas for straight Exception, it'll print the full backtrace\nas well under the assumption that it's a program bug.\n\n-- \nKarl Wiberg, kha@treskal.com\n   subrabbit.wordpress.com\n   www.treskal.com/kalle\n"},{"id":"128976","messageId":"b8197bcb0912012303i3bd1061fhdb391de096996a27@mail.gmail.com","threadId":"21815","inReplyTo":"20091202004616.7737.60382.stgit@bob.kio","subject":"Re: [StGit PATCH v2 3/6] stg mail: make __send_message do more","fromName":"Karl Wiberg","fromEmail":"kha@treskal.com","sentAt":"2009-12-02T07:03:51Z","receivedAt":"2009-12-02T07:03:51Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"Just pointing out a couple of Python tricks you might've wanted to\nuse. No need to update the patch, though.\n\nOn Wed, Dec 2, 2009 at 1:46 AM, Alex Chiang <achiang@hp.com> wrote:\n\n> +        (patch_nr, total_nr) = (args[1], args[2])\n\nCan be written as\n\n  (patch_nr, total_nr) = args[1:3]\n\nor, if args[2] is the last element of the list (which it isn't in this\ncase?),\n\n  (patch_nr, total_nr) = args[1:]\n\n> +    for (p, n) in zip(patches, range(1, total_nr + 1)):\n> +        msg_id = __send_message('patch', tmpl, options, p, n, total_nr, ref_id)\n\nCan be written as\n\n  for (n, p) in enumerate(patches):\n\nif you use n + 1 instead of n in the loop body.\n\n-- \nKarl Wiberg, kha@treskal.com\n   subrabbit.wordpress.com\n   www.treskal.com/kalle\n"},{"id":"128977","messageId":"b8197bcb0912012308n249f70e4j54e76d70f9601279@mail.gmail.com","threadId":"21815","inReplyTo":"20091202003503.7737.51579.stgit@bob.kio","subject":"Re: [StGit PATCH v2 0/6] add support for git send-email","fromName":"Karl Wiberg","fromEmail":"kha@treskal.com","sentAt":"2009-12-02T07:08:55Z","receivedAt":"2009-12-02T07:08:55Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On Wed, Dec 2, 2009 at 1:46 AM, Alex Chiang <achiang@hp.com> wrote:\n\n> This is v2 of the series that starts teaching stg mail how to\n> call git send-email.\n\nAcked-by: Karl Wiberg <kha@treskal.com>\n\nwhen the CmdException/Exception thing is fixed in the first patch.\n\n-- \nKarl Wiberg, kha@treskal.com\n   subrabbit.wordpress.com\n   www.treskal.com/kalle\n"},{"id":"129077","messageId":"b0943d9e0912021435k6d19dc1crfa9c6865217a4973@mail.gmail.com","threadId":"21815","inReplyTo":"20091202003503.7737.51579.stgit@bob.kio","subject":"Re: [StGit PATCH v2 0/6] add support for git send-email","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2009-12-02T22:35:31Z","receivedAt":"2009-12-02T22:35:31Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"Hi Alex,\n\n2009/12/2 Alex Chiang <achiang@hp.com>:\n> This is v2 of the series that starts teaching stg mail how to\n> call git send-email.\n\nThanks for posting these patches (and thanks to Karl for reviewing\nthem). I don't have much to comment (Karl did the hard work here) but\nI'll give them a try tomorrow and let you know.\n\nThanks.\n\n-- \nCatalin\n"},{"id":"129134","messageId":"20091203192731.GD23258@ldl.fc.hp.com","threadId":"21815","inReplyTo":"b8197bcb0912012246n3b83866cjb93654effc000242@mail.gmail.com","subject":"Re: [StGit PATCH v2 0/6] add support for git send-email","fromName":"Alex Chiang","fromEmail":"achiang@hp.com","sentAt":"2009-12-03T19:27:31Z","receivedAt":"2009-12-03T19:27:31Z","isPatch":true,"sender":{"key":"achiang@hp.com","avatar":null},"body":"* Karl Wiberg <kha@treskal.com>:\n> On Wed, Dec 2, 2009 at 1:46 AM, Alex Chiang <achiang@hp.com> wrote:\n> > The upshot is that in stg mail, --git and --mbox don't interact\n> > well, and the resulting mbox file will lack the recipients. This\n> > might be fixed in the future if we teach git send-email how to\n> > generate mbox files, but then we introduce a versioning problem.\n> \n> One wild idea: git send-email's --smtp-server flag will accept the\n> (full) path of a sendmail program; writing such a program, just\n> capable enough to receive the outgoing emails and dumping them to a\n> file, should be easy. Another option would be a program that speaks\n> just enough SMTP to accept the mails. (Incidentally, these two would\n> be useful in testing stg mail even without the --git option.)\n \nHm, I think this is getting to be a bit of overkill. I could see\nadding --mbox support to git send-email as being a better use of\ntime (IMO).\n\n> I fully understand if you'd rather get on with scratching your actual\n> itch, though ...\n \n:)\n\n> > So let's just accept this wart for now, and say, if you want an mbox\n> > file generated, don't use --git. That seems reasonable to me.\n> \n> Sure.\n\nThanks,\n/ac\n"},{"id":"129135","messageId":"20091203192747.GE23258@ldl.fc.hp.com","threadId":"21815","inReplyTo":"b8197bcb0912012253l399bb542sab141021e7ff6353@mail.gmail.com","subject":"Re: [StGit PATCH v2 1/6] stg mail: Refactor __send_message and friends","fromName":"Alex Chiang","fromEmail":"achiang@hp.com","sentAt":"2009-12-03T19:27:47Z","receivedAt":"2009-12-03T19:27:47Z","isPatch":true,"sender":{"key":"achiang@hp.com","avatar":null},"body":"* Karl Wiberg <kha@treskal.com>:\n> On Wed, Dec 2, 2009 at 1:46 AM, Alex Chiang <achiang@hp.com> wrote:\n> \n> > +    if (smtppassword and not smtpuser):\n> > +        raise Exception('SMTP password supplied, username needed')\n> > +    if (smtpusetls and not smtpuser):\n> > +        raise Exception('SMTP over TLS requested, username needed')\n> > +    if (smtpuser and not smtppassword):\n> > +        smtppassword = getpass.getpass(\"Please enter SMTP password: \")\n> \n> Sorry if I confused you with my earlier explanation; I only meant that\n> you should use the _form_ \"raise Exception('message')\", not that you\n> should change the exception type from CmdException to Exception. If\n> you try to trigger these errors, I think you'll find that in the case\n> of CmdException, StGit will print just the message and exit with an\n> error; whereas for straight Exception, it'll print the full backtrace\n> as well under the assumption that it's a program bug.\n\nAh, ok. Will update.\n\n/ac\n"},{"id":"129136","messageId":"20091203193018.GF23258@ldl.fc.hp.com","threadId":"21815","inReplyTo":"b8197bcb0912012303i3bd1061fhdb391de096996a27@mail.gmail.com","subject":"Re: [StGit PATCH v2 3/6] stg mail: make __send_message do more","fromName":"Alex Chiang","fromEmail":"achiang@hp.com","sentAt":"2009-12-03T19:30:19Z","receivedAt":"2009-12-03T19:30:19Z","isPatch":true,"sender":{"key":"achiang@hp.com","avatar":null},"body":"* Karl Wiberg <kha@treskal.com>:\n> Just pointing out a couple of Python tricks you might've wanted to\n> use. No need to update the patch, though.\n> \n> On Wed, Dec 2, 2009 at 1:46 AM, Alex Chiang <achiang@hp.com> wrote:\n> \n> > +        (patch_nr, total_nr) = (args[1], args[2])\n> \n> Can be written as\n> \n>   (patch_nr, total_nr) = args[1:3]\n\nThanks, I did it this way.\n\n> or, if args[2] is the last element of the list (which it isn't in this\n> case?),\n> \n>   (patch_nr, total_nr) = args[1:]\n\nNo, ref_id is the last arg, so that won't work.\n\n> > +    for (p, n) in zip(patches, range(1, total_nr + 1)):\n> > +        msg_id = __send_message('patch', tmpl, options, p, n, total_nr, ref_id)\n> \n> Can be written as\n> \n>   for (n, p) in enumerate(patches):\n> \n> if you use n + 1 instead of n in the loop body.\n\nThat is a little cleaner, but I decided to keep it as zip(). Why?\nBecause using n + 1 in the loop body will push that line past 80\ncolumns. ;)\n\nIt's also the original code (albeit with a simple variable\nrename).\n\nI know this isn't the kernel, and that there are plenty of other\nlines that are 80+ characters, but if you can keep it short, why\nnot?\n\nThanks,\n/ac\n"},{"id":"129143","messageId":"20091203204635.GH23258@ldl.fc.hp.com","threadId":"21815","inReplyTo":"b8197bcb0912012253l399bb542sab141021e7ff6353@mail.gmail.com","subject":"[StGit PATCH v3 1/6] stg mail: Refactor __send_message and friends","fromName":"Alex Chiang","fromEmail":"achiang@hp.com","sentAt":"2009-12-03T20:46:35Z","receivedAt":"2009-12-03T20:46:35Z","isPatch":true,"sender":{"key":"achiang@hp.com","avatar":null},"body":"Instead of passing all the various smtp* args to __send_message\nindividually, let's just pass the options list instead.\n\nThe main motivation is for future patches. The end goal is to\nthin out stg mail's implementation and make it a minimal wrapper\naround git send-email. By passing the options list to __send_message\nwe prepare to pass options directly to git send-email.\n\nAs a bonus, this change results in a cleaner internal API.\n\nFinally, it also pushes the smtp logic where it belongs, viz. into\n__send_message_smtp, instead of cluttering up the main body of\nmail.func().\n\nCc: Karl Wiberg <kha@treskal.com>\nSigned-off-by: Alex Chiang <achiang@hp.com>\n---\n\nCatalin,\n\nThis is the only patch in the series that changed, so no sense in\nsending out all the others.\n\n stgit/commands/mail.py |   43 +++++++++++++++++++------------------------\n 1 files changed, 19 insertions(+), 24 deletions(-)\n\ndiff --git a/stgit/commands/mail.py b/stgit/commands/mail.py\nindex abd42e4..777ee36 100644\n--- a/stgit/commands/mail.py\n+++ b/stgit/commands/mail.py\n@@ -190,10 +190,20 @@ def __send_message_sendmail(sendmail, msg):\n     cmd = sendmail.split()\n     Run(*cmd).raw_input(msg).discard_output()\n \n-def __send_message_smtp(smtpserver, from_addr, to_addr_list, msg,\n-                        smtpuser, smtppassword, use_tls):\n+def __send_message_smtp(smtpserver, from_addr, to_addr_list, msg, options):\n     \"\"\"Send the message using the given SMTP server\n     \"\"\"\n+    smtppassword = options.smtp_password or config.get('stgit.smtppassword')\n+    smtpuser = options.smtp_user or config.get('stgit.smtpuser')\n+    smtpusetls = options.smtp_tls or config.get('stgit.smtptls') == 'yes'\n+\n+    if (smtppassword and not smtpuser):\n+        raise CmdException('SMTP password supplied, username needed')\n+    if (smtpusetls and not smtpuser):\n+        raise CmdException('SMTP over TLS requested, username needed')\n+    if (smtpuser and not smtppassword):\n+        smtppassword = getpass.getpass(\"Please enter SMTP password: \")\n+\n     try:\n         s = smtplib.SMTP(smtpserver)\n     except Exception, err:\n@@ -203,7 +213,7 @@ def __send_message_smtp(smtpserver, from_addr, to_addr_list, msg,\n     try:\n         if smtpuser and smtppassword:\n             s.ehlo()\n-            if use_tls:\n+            if smtpusetls:\n                 if not hasattr(socket, 'ssl'):\n                     raise CmdException,  \"cannot use TLS - no SSL support in Python\"\n                 s.starttls()\n@@ -218,17 +228,17 @@ def __send_message_smtp(smtpserver, from_addr, to_addr_list, msg,\n \n     s.quit()\n \n-def __send_message(smtpserver, from_addr, to_addr_list, msg,\n-                   smtpuser, smtppassword, use_tls):\n+def __send_message(from_addr, to_addr_list, msg, options):\n     \"\"\"Message sending dispatcher.\n     \"\"\"\n+    smtpserver = options.smtp_server or config.get('stgit.smtpserver')\n+\n     if smtpserver.startswith('/'):\n         # Use the sendmail tool\n         __send_message_sendmail(smtpserver, msg)\n     else:\n         # Use the SMTP server (we have host and port information)\n-        __send_message_smtp(smtpserver, from_addr, to_addr_list, msg,\n-                            smtpuser, smtppassword, use_tls)\n+        __send_message_smtp(smtpserver, from_addr, to_addr_list, msg, options)\n \n def __build_address_headers(msg, options, extra_cc = []):\n     \"\"\"Build the address headers and check existing headers in the\n@@ -543,8 +553,6 @@ def func(parser, options, args):\n     \"\"\"Send the patches by e-mail using the patchmail.tmpl file as\n     a template\n     \"\"\"\n-    smtpserver = options.smtp_server or config.get('stgit.smtpserver')\n-\n     applied = crt_series.get_applied()\n \n     if options.all:\n@@ -564,17 +572,6 @@ def func(parser, options, args):\n             raise CmdException, 'Cannot send empty patch \"%s\"' % p\n     out.done()\n \n-    smtppassword = options.smtp_password or config.get('stgit.smtppassword')\n-    smtpuser = options.smtp_user or config.get('stgit.smtpuser')\n-    smtpusetls = options.smtp_tls or config.get('stgit.smtptls') == 'yes'\n-\n-    if (smtppassword and not smtpuser):\n-        raise CmdException, 'SMTP password supplied, username needed'\n-    if (smtpusetls and not smtpuser):\n-        raise CmdException, 'SMTP over TLS requested, username needed'\n-    if (smtpuser and not smtppassword):\n-        smtppassword = getpass.getpass(\"Please enter SMTP password: \")\n-\n     total_nr = len(patches)\n     if total_nr == 0:\n         raise CmdException, 'No patches to send'\n@@ -616,8 +613,7 @@ def func(parser, options, args):\n             out.stdout_raw(msg_string + '\\n')\n         else:\n             out.start('Sending the cover message')\n-            __send_message(smtpserver, from_addr, to_addr_list, msg_string,\n-                           smtpuser, smtppassword, smtpusetls)\n+            __send_message(from_addr, to_addr_list, msg_string, options)\n             time.sleep(sleep)\n             out.done()\n \n@@ -648,8 +644,7 @@ def func(parser, options, args):\n             out.stdout_raw(msg_string + '\\n')\n         else:\n             out.start('Sending patch \"%s\"' % p)\n-            __send_message(smtpserver, from_addr, to_addr_list, msg_string,\n-                           smtpuser, smtppassword, smtpusetls)\n+            __send_message(from_addr, to_addr_list, msg_string, options)\n             # give recipients a chance of receiving related patches in the\n             # correct order.\n             if patch_nr < total_nr:\n"},{"id":"129164","messageId":"b8197bcb0912032300v62b8764bh7bff7e273a4792f5@mail.gmail.com","threadId":"21815","inReplyTo":"20091203193018.GF23258@ldl.fc.hp.com","subject":"Re: [StGit PATCH v2 3/6] stg mail: make __send_message do more","fromName":"Karl Wiberg","fromEmail":"kha@treskal.com","sentAt":"2009-12-04T07:00:29Z","receivedAt":"2009-12-04T07:00:29Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On Thu, Dec 3, 2009 at 8:30 PM, Alex Chiang <achiang@hp.com> wrote:\n\n> * Karl Wiberg <kha@treskal.com>:\n>\n> > On Wed, Dec 2, 2009 at 1:46 AM, Alex Chiang <achiang@hp.com> wrote:\n> >\n> > > +    for (p, n) in zip(patches, range(1, total_nr + 1)):\n> > > +        msg_id = __send_message('patch', tmpl, options, p, n, total_nr, ref_id)\n> >\n> > Can be written as\n> >\n> >   for (n, p) in enumerate(patches):\n> >\n> > if you use n + 1 instead of n in the loop body.\n>\n> That is a little cleaner, but I decided to keep it as zip(). Why?\n> Because using n + 1 in the loop body will push that line past 80\n> columns. ;)\n>\n> It's also the original code (albeit with a simple variable rename).\n>\n> I know this isn't the kernel, and that there are plenty of other\n> lines that are 80+ characters, but if you can keep it short, why\n> not?\n\nOh, I fully favor keeping lines within the 80 columns allotted to us\nby the ancestors---I just didn't realize it was going to be a problem\nhere.\n\nIn general, though, programmer time is worth optimizing for, and\nthinking through exactly what zip(patches, range(1, total_nr + 1))\nmeans (and getting it right!) is a small but not insignificant cost\nevery time someone reads the code.\n\n-- \nKarl Wiberg, kha@treskal.com\n   subrabbit.wordpress.com\n   www.treskal.com/kalle\n"},{"id":"129356","messageId":"b0943d9e0912061416y4089643l2a5ebdf1c1c0960b@mail.gmail.com","threadId":"21815","inReplyTo":"20091202003503.7737.51579.stgit@bob.kio","subject":"Re: [StGit PATCH v2 0/6] add support for git send-email","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2009-12-06T22:16:16Z","receivedAt":"2009-12-06T22:16:16Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"2009/12/2 Alex Chiang <achiang@hp.com>:\n> This is v2 of the series that starts teaching stg mail how to\n> call git send-email.\n\nI merged these patches into the \"proposed\" branch for now and test\nthem for a bit more. It would be nice for some of the stgit options to\nbe translated into git send-email options (I don't mind renaming the\nstgit options to match the git ones):\n\n--refid -> --in-reply-to\n--noreply -> --no-thread\n\nThanks.\n\n-- \nCatalin\n"},{"id":"129382","messageId":"b8197bcb0912062309q4130d207yca069c6ce3256b29@mail.gmail.com","threadId":"21815","inReplyTo":"b0943d9e0912061416y4089643l2a5ebdf1c1c0960b@mail.gmail.com","subject":"Re: [StGit PATCH v2 0/6] add support for git send-email","fromName":"Karl Wiberg","fromEmail":"kha@treskal.com","sentAt":"2009-12-07T07:09:02Z","receivedAt":"2009-12-07T07:09:02Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On Sun, Dec 6, 2009 at 11:16 PM, Catalin Marinas\n<catalin.marinas@gmail.com> wrote:\n\n> --refid -> --in-reply-to\n> --noreply -> --no-thread\n\nAnd I must say, the git options are better named than ours anyway ...\n\n-- \nKarl Wiberg, kha@treskal.com\n   subrabbit.wordpress.com\n   www.treskal.com/kalle\n"}]}