[PATCH 3 of 4] Move genmsgid from patchbomb to mercurial.mail

John Goerzen jgoerzen at complete.org
Wed Mar 21 22:59:08 CDT 2007


# HG changeset patch
# User John Goerzen <jgoerzen at complete.org>
# Date 1174535734 18000
# Node ID cf386be05926f5d4ce3bef3eca71c8fe2af5a53f
# Parent  d44a7fcfe7078cc60b23a03ce69b0d9b57314a6e
Move genmsgid from patchbomb to mercurial.mail

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -63,7 +63,7 @@
 #
 # That should be all.  Now your patchbomb is on its way out.
 
-import os, errno, socket
+import os, errno
 import email.MIMEMultipart, email.MIMEText, email.Utils
 from mercurial import cmdutil, commands, hg, mail, ui, patch, util
 from mercurial.i18n import _
@@ -171,9 +171,6 @@ def patchbomb(ui, repo, *revs, **opts):
 
     start_time = util.makedate()
 
-    def genmsgid(id):
-        return '<%s.%s@%s>' % (id[:20], int(start_time[0]), socket.getfqdn())
-
     patches = []
 
     class exportee:
@@ -252,9 +249,9 @@ def patchbomb(ui, repo, *revs, **opts):
     sender_addr = email.Utils.parseaddr(sender)[1]
     for m in msgs:
         try:
-            m['Message-Id'] = genmsgid(m['X-Mercurial-Node'])
+            m['Message-Id'] = mail.genmsgid(m['X-Mercurial-Node'])
         except TypeError:
-            m['Message-Id'] = genmsgid('patchbomb')
+            m['Message-Id'] = mail.genmsgid('patchbomb')
         if parent:
             m['In-Reply-To'] = parent
         else:
diff --git a/mercurial/mail.py b/mercurial/mail.py
--- a/mercurial/mail.py
+++ b/mercurial/mail.py
@@ -6,7 +6,7 @@
 # of the GNU General Public License, incorporated herein by reference.
 
 from i18n import _
-import os, smtplib, templater, util, socket
+import os, smtplib, templater, util, socket, socket
 
 def _smtp(ui):
     '''send mail using smtp.'''
@@ -68,3 +68,8 @@ def connect(ui):
 
 def sendmail(ui, sender, recipients, msg):
     return connect(ui).sendmail(sender, recipients, msg)
+
+
+def genmsgid(id):
+    return '<%s.%s@%s>' % (id[:20], int(util.makedate()[0]), socket.getfqdn())
+


More information about the Mercurial-devel mailing list