{"thread":{"id":"1840","subject":"[PATCH] Better mail handling in stgit","startedAt":"2005-09-17T13:34:41Z","lastAt":"2005-09-18T08:19:51Z","messageCount":2,"participants":["Pierre Ossman","Catalin Marinas"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"8759","messageId":"432C1B71.4090105@drzeus.cx","threadId":"1840","inReplyTo":null,"subject":"[PATCH] Better mail handling in stgit","fromName":"Pierre Ossman","fromEmail":"drzeus-list@drzeus.cx","sentAt":"2005-09-17T13:34:41Z","receivedAt":"2005-09-17T13:34:41Z","isPatch":true,"sender":{"key":"drzeus-list@drzeus.cx","avatar":null},"body":"Fix some issues with the mail function in StGIT:\n\n * Allow multiple To/Cc/Bcc command line options.\n\n * Better parsing of mail addresses.\n\nSigned-off-by: Pierre Ossman <drzeus@drzeus.cx>\n\n\n--- stgit.orig/commands/mail.py\t2005-08-03 21:04:10.000000000 +0200\n+++ stgit/commands/mail.py\t2005-09-17 14:57:23.000000000 +0200\n@@ -78,11 +78,14 @@\n                        metavar = '[PATCH1][:[PATCH2]]',\n                        help = 'e-mail patches between PATCH1 and PATCH2'),\n            make_option('--to',\n-                       help = 'Add TO to the To: list'),\n+                       help = 'Add TO to the To: list',\n+                       action = 'append'),\n            make_option('--cc',\n-                       help = 'Add CC to the Cc: list'),\n+                       help = 'Add CC to the Cc: list',\n+                       action = 'append'),\n            make_option('--bcc',\n-                       help = 'Add BCC to the Bcc: list'),\n+                       help = 'Add BCC to the Bcc: list',\n+                       action = 'append'),\n            make_option('-t', '--template', metavar = 'FILE',\n                        help = 'use FILE as the message template'),\n            make_option('-f', '--first', metavar = 'FILE',\n@@ -112,7 +115,10 @@\n     \"\"\"Return a two elements tuple: (from, [to])\n     \"\"\"\n     def __addr_list(string):\n-        return re.split('.*?([\\w\\.]+@[\\w\\.]+)', string)[1:-1:2]\n+    \tm = re.search('[^@\\s<,]+@[^>\\s,]+', string);\n+    \tif (m == None):\n+    \t\treturn []\n+    \treturn [ m.group() ] + __addr_list(string[m.end():])\n \n     from_addr_list = []\n     to_addr_list = []\n@@ -152,6 +158,25 @@\n \n     s.quit()\n \n+def __build_address_headers(options):\n+    headers_end = ''\n+    if options.to:\n+    \theaders_end += 'To: '\n+    \tfor to in options.to:\n+\t        headers_end += '%s,' % to\n+\theaders_end = headers_end[:-1] + '\\n'\n+    if options.cc:\n+    \theaders_end += 'Cc: '\n+    \tfor cc in options.cc:\n+\t        headers_end += '%s,' % cc\n+\theaders_end = headers_end[:-1] + '\\n'\n+    if options.bcc:\n+    \theaders_end += 'Bcc: '\n+    \tfor bcc in options.bcc:\n+\t        headers_end += '%s,' % bcc\n+\theaders_end = headers_end[:-1] + '\\n'\n+    return headers_end\n+\n def __build_first(tmpl, total_nr, msg_id, options):\n     \"\"\"Build the first message (series description) to be sent via SMTP\n     \"\"\"\n@@ -160,12 +185,7 @@\n         maintainer = ''\n \n     headers_end = ''\n-    if options.to:\n-        headers_end += 'To: %s\\n' % options.to\n-    if options.cc:\n-        headers_end += 'Cc: %s\\n' % options.cc\n-    if options.bcc:\n-        headers_end += 'Bcc: %s\\n' % options.bcc\n+    headers_end += __build_address_headers(options)\n     headers_end += 'Message-Id: %s\\n' % msg_id\n \n     total_nr_str = str(total_nr)\n@@ -210,12 +230,7 @@\n         maintainer = '%s <%s>' % (p.get_commname(), p.get_commemail())\n \n     headers_end = ''\n-    if options.to:\n-        headers_end += 'To: %s\\n' % options.to\n-    if options.cc:\n-        headers_end += 'Cc: %s\\n' % options.cc\n-    if options.bcc:\n-        headers_end += 'Bcc: %s\\n' % options.bcc\n+    headers_end += __build_address_headers(options)\n     headers_end += 'Message-Id: %s\\n' % msg_id\n     if ref_id:\n         headers_end += \"In-Reply-To: %s\\n\" % ref_id\n"},{"id":"8772","messageId":"1127031591.6959.3.camel@localhost.localdomain","threadId":"1840","inReplyTo":"432C1B71.4090105@drzeus.cx","subject":"Re: [PATCH] Better mail handling in stgit","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2005-09-18T08:19:51Z","receivedAt":"2005-09-18T08:19:51Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"On Sat, 2005-09-17 at 15:34 +0200, Pierre Ossman wrote:\n> Fix some issues with the mail function in StGIT:\n> \n>  * Allow multiple To/Cc/Bcc command line options.\n> \n>  * Better parsing of mail addresses.\n\nApplied. Thanks.\n\nOn a side note, since people don't usually send patches against the\nlatest HEAD and git-apply fails, I implemented a --base option for\nimport which applies the patch on a given commit id and performs a\nthree-way merge with the current HEAD. It's much easier to fix the diff3\nconflicts than modify the patch file to apply cleanly (with no fuzz).\n\n-- \nCatalin\n"}]}