patchbomb: extract function for generating message-id
authorAugie Fackler <raf@durin42.com>
Thu, 16 Aug 2018 00:39:32 -0400
changeset 39117 4899c6d22dff
parent 39116 ffb34ee6de9e
child 39118 1415b78869eb
patchbomb: extract function for generating message-id Differential Revision: https://phab.mercurial-scm.org/D4293
hgext/patchbomb.py
--- a/hgext/patchbomb.py	Wed Aug 15 11:27:57 2018 +0530
+++ b/hgext/patchbomb.py	Thu Aug 16 00:39:32 2018 -0400
@@ -469,6 +469,10 @@
         ui.status(_("no changes found\n"))
     return revs
 
+def _msgid(node, timestamp):
+    return '<%s.%d@%s>' % (node, timestamp,
+                           encoding.strtolocal(socket.getfqdn()))
+
 emailopts = [
     ('', 'body', None, _('send patches as inline message text (default)')),
     ('a', 'attach', None, _('send patches as attachments')),
@@ -677,8 +681,7 @@
         start_time = dateutil.makedate()
 
     def genmsgid(id):
-        return '<%s.%d@%s>' % (id[:20], int(start_time[0]),
-                               encoding.strtolocal(socket.getfqdn()))
+        return _msgid(id[:20], int(start_time[0]))
 
     # deprecated config: patchbomb.from
     sender = (opts.get('from') or ui.config('email', 'from') or