[PATCH] Move genmsgid from patchbomb to mercurial.mail

John Goerzen jgoerzen at complete.org
Thu Mar 22 12:03:18 CDT 2007


# HG changeset patch
# User John Goerzen <jgoerzen at complete.org>
# Date 1174582813 18000
# Node ID ad71c4d0ff9f12163d138706c924b85249c2c064
# 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
@@ -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