patchbomb: always use message-id of first patch for series-id
authorAugie Fackler <raf@durin42.com>
Sat, 07 Jun 2014 11:06:15 -0400
changeset 21726 fae032549ca2
parent 21725 e8496c4ba6c0
child 21727 5f98ad8fb8d9
patchbomb: always use message-id of first patch for series-id This currently has the side effect that the 0 of N message has no series-id. This won't matter for Mercurial's own use, but may be undesirable for other projects depending on their workflow. The way the header is inserted is intentionally a little funny to make the test expectation diff easier to review.
hgext/patchbomb.py
tests/test-patchbomb.t
--- a/hgext/patchbomb.py	Sat Jun 07 11:30:06 2014 -0400
+++ b/hgext/patchbomb.py	Sat Jun 07 11:06:15 2014 -0400
@@ -509,9 +509,12 @@
     sender_addr = email.Utils.parseaddr(sender)[1]
     sender = mail.addressencode(ui, sender, _charsets, opts.get('test'))
     sendmail = None
+    firstpatch = None
     for i, (m, subj, ds) in enumerate(msgs):
         try:
             m['Message-Id'] = genmsgid(m['X-Mercurial-Node'])
+            if not firstpatch:
+                firstpatch = m['Message-Id']
         except TypeError:
             m['Message-Id'] = genmsgid('patchbomb')
         if parent:
@@ -519,7 +522,10 @@
             m['References'] = parent
         if not parent or 'X-Mercurial-Node' not in m:
             parent = m['Message-Id']
-        m['X-Mercurial-Series-Id'] = parent
+        # For 0 of N messages, we won't have seen a patch yet, so
+        # don't try and produce an X-Mercurial-Series-Id.
+        if firstpatch:
+            m['X-Mercurial-Series-Id'] = firstpatch
 
         m['User-Agent'] = 'Mercurial-patchbomb/%s' % util.version()
         m['Date'] = email.Utils.formatdate(start_time[0], localtime=True)
--- a/tests/test-patchbomb.t	Sat Jun 07 11:30:06 2014 -0400
+++ b/tests/test-patchbomb.t	Sat Jun 07 11:06:15 2014 -0400
@@ -87,7 +87,6 @@
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 2] test
   Message-Id: <patchbomb.120@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.120@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:02:00 +0000
   From: quux
@@ -106,7 +105,7 @@
   Message-Id: <8580ff50825a50c8f716.121@*> (glob)
   In-Reply-To: <patchbomb.120@*> (glob)
   References: <patchbomb.120@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.120@*> (glob)
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.121@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:02:01 +0000
   From: quux
@@ -138,7 +137,7 @@
   Message-Id: <97d72e5f12c7e84f8506.122@*> (glob)
   In-Reply-To: <patchbomb.120@*> (glob)
   References: <patchbomb.120@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.120@*> (glob)
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.121@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:02:02 +0000
   From: quux
@@ -224,7 +223,6 @@
   MIME-Version: 1.0
   Subject: test
   Message-Id: <patchbomb.180@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.180@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:03:00 +0000
   From: quux
@@ -606,7 +604,6 @@
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 2] test
   Message-Id: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:00 +0000
   From: quux
@@ -629,7 +626,7 @@
   Message-Id: <8580ff50825a50c8f716.61@*> (glob)
   In-Reply-To: <patchbomb.60@*> (glob)
   References: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.61@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:01 +0000
   From: quux
@@ -665,7 +662,7 @@
   Message-Id: <97d72e5f12c7e84f8506.62@*> (glob)
   In-Reply-To: <patchbomb.60@*> (glob)
   References: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.61@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:02 +0000
   From: quux
@@ -807,7 +804,6 @@
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 3] test
   Message-Id: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:00 +0000
   From: quux
@@ -825,7 +821,7 @@
   Message-Id: <8580ff50825a50c8f716.61@*> (glob)
   In-Reply-To: <patchbomb.60@*> (glob)
   References: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.61@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:01 +0000
   From: quux
@@ -863,7 +859,7 @@
   Message-Id: <97d72e5f12c7e84f8506.62@*> (glob)
   In-Reply-To: <patchbomb.60@*> (glob)
   References: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.61@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:02 +0000
   From: quux
@@ -901,7 +897,7 @@
   Message-Id: <a2ea8fc83dd8b93cfd86.63@*> (glob)
   In-Reply-To: <patchbomb.60@*> (glob)
   References: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.61@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:03 +0000
   From: quux
@@ -1140,7 +1136,6 @@
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 3] test
   Message-Id: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:00 +0000
   From: quux
@@ -1158,7 +1153,7 @@
   Message-Id: <8580ff50825a50c8f716.61@*> (glob)
   In-Reply-To: <patchbomb.60@*> (glob)
   References: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.61@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:01 +0000
   From: quux
@@ -1205,7 +1200,7 @@
   Message-Id: <97d72e5f12c7e84f8506.62@*> (glob)
   In-Reply-To: <patchbomb.60@*> (glob)
   References: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.61@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:02 +0000
   From: quux
@@ -1252,7 +1247,7 @@
   Message-Id: <a2ea8fc83dd8b93cfd86.63@*> (glob)
   In-Reply-To: <patchbomb.60@*> (glob)
   References: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.61@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:03 +0000
   From: quux
@@ -1321,7 +1316,6 @@
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 1] test
   Message-Id: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:00 +0000
   From: quux
@@ -1340,7 +1334,7 @@
   Message-Id: <ff2c9fa2018b15fa74b3.61@*> (glob)
   In-Reply-To: <patchbomb.60@*> (glob)
   References: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
+  X-Mercurial-Series-Id: <ff2c9fa2018b15fa74b3.61@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:01 +0000
   From: quux
@@ -1375,7 +1369,6 @@
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 1] test
   Message-Id: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:00 +0000
   From: quux
@@ -1395,7 +1388,7 @@
   Message-Id: <ff2c9fa2018b15fa74b3.61@*> (glob)
   In-Reply-To: <patchbomb.60@*> (glob)
   References: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
+  X-Mercurial-Series-Id: <ff2c9fa2018b15fa74b3.61@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:01 +0000
   From: quux
@@ -1432,7 +1425,6 @@
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 2] test
   Message-Id: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:00 +0000
   From: quux
@@ -1451,7 +1443,7 @@
   Message-Id: <8580ff50825a50c8f716.61@*> (glob)
   In-Reply-To: <patchbomb.60@*> (glob)
   References: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.61@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:01 +0000
   From: quux
@@ -1483,7 +1475,7 @@
   Message-Id: <97d72e5f12c7e84f8506.62@*> (glob)
   In-Reply-To: <patchbomb.60@*> (glob)
   References: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.61@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:02 +0000
   From: quux
@@ -1642,7 +1634,6 @@
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 2] test
   Message-Id: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:00 +0000
   From: quux
@@ -1660,7 +1651,7 @@
   Message-Id: <8580ff50825a50c8f716.61@*> (glob)
   In-Reply-To: <patchbomb.60@*> (glob)
   References: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.61@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:01 +0000
   From: quux
@@ -1698,7 +1689,7 @@
   Message-Id: <97d72e5f12c7e84f8506.62@*> (glob)
   In-Reply-To: <patchbomb.60@*> (glob)
   References: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.61@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:02 +0000
   From: quux
@@ -1745,7 +1736,7 @@
   Message-Id: <7aead2484924c445ad8c.60@*> (glob)
   In-Reply-To: <baz>
   References: <baz>
-  X-Mercurial-Series-Id: <baz>
+  X-Mercurial-Series-Id: <7aead2484924c445ad8c.60@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:00 +0000
   From: quux
@@ -1788,7 +1779,7 @@
   Message-Id: <8580ff50825a50c8f716.60@*> (glob)
   In-Reply-To: <baz>
   References: <baz>
-  X-Mercurial-Series-Id: <baz>
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.60@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:00 +0000
   From: quux
@@ -1820,7 +1811,7 @@
   Message-Id: <97d72e5f12c7e84f8506.61@*> (glob)
   In-Reply-To: <baz>
   References: <baz>
-  X-Mercurial-Series-Id: <baz>
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.60@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:01 +0000
   From: quux
@@ -1860,7 +1851,6 @@
   Message-Id: <patchbomb.60@*> (glob)
   In-Reply-To: <baz>
   References: <baz>
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:00 +0000
   From: quux
@@ -1879,7 +1869,7 @@
   Message-Id: <8580ff50825a50c8f716.61@*> (glob)
   In-Reply-To: <patchbomb.60@*> (glob)
   References: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.61@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:01 +0000
   From: quux
@@ -1911,7 +1901,7 @@
   Message-Id: <97d72e5f12c7e84f8506.62@*> (glob)
   In-Reply-To: <patchbomb.60@*> (glob)
   References: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.61@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:02 +0000
   From: quux
@@ -1988,7 +1978,6 @@
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 2 fooFlag] test
   Message-Id: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:00 +0000
   From: quux
@@ -2007,7 +1996,7 @@
   Message-Id: <8580ff50825a50c8f716.61@*> (glob)
   In-Reply-To: <patchbomb.60@*> (glob)
   References: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.61@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:01 +0000
   From: quux
@@ -2039,7 +2028,7 @@
   Message-Id: <97d72e5f12c7e84f8506.62@*> (glob)
   In-Reply-To: <patchbomb.60@*> (glob)
   References: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.61@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:02 +0000
   From: quux
@@ -2115,7 +2104,6 @@
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 2 fooFlag barFlag] test
   Message-Id: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:00 +0000
   From: quux
@@ -2134,7 +2122,7 @@
   Message-Id: <8580ff50825a50c8f716.61@*> (glob)
   In-Reply-To: <patchbomb.60@*> (glob)
   References: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.61@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:01 +0000
   From: quux
@@ -2166,7 +2154,7 @@
   Message-Id: <97d72e5f12c7e84f8506.62@*> (glob)
   In-Reply-To: <patchbomb.60@*> (glob)
   References: <patchbomb.60@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.60@*> (glob)
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.61@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:01:02 +0000
   From: quux
@@ -2326,7 +2314,6 @@
   Content-Transfer-Encoding: 7bit
   Subject: [PATCH 0 of 6] test
   Message-Id: <patchbomb.315532860@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.315532860@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Tue, 01 Jan 1980 00:01:00 +0000
   From: test
@@ -2344,7 +2331,7 @@
   Message-Id: <ff2c9fa2018b15fa74b3.315532861@*> (glob)
   In-Reply-To: <patchbomb.315532860@*> (glob)
   References: <patchbomb.315532860@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.315532860@*> (glob)
+  X-Mercurial-Series-Id: <ff2c9fa2018b15fa74b3.315532861@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Tue, 01 Jan 1980 00:01:01 +0000
   From: test
@@ -2375,7 +2362,7 @@
   Message-Id: <909a00e13e9d78b575ae.315532862@*> (glob)
   In-Reply-To: <patchbomb.315532860@*> (glob)
   References: <patchbomb.315532860@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.315532860@*> (glob)
+  X-Mercurial-Series-Id: <ff2c9fa2018b15fa74b3.315532861@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Tue, 01 Jan 1980 00:01:02 +0000
   From: test
@@ -2413,7 +2400,7 @@
   Message-Id: <a2ea8fc83dd8b93cfd86.315532863@*> (glob)
   In-Reply-To: <patchbomb.315532860@*> (glob)
   References: <patchbomb.315532860@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.315532860@*> (glob)
+  X-Mercurial-Series-Id: <ff2c9fa2018b15fa74b3.315532861@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Tue, 01 Jan 1980 00:01:03 +0000
   From: test
@@ -2460,7 +2447,7 @@
   Message-Id: <240fb913fc1b7ff15ddb.315532864@*> (glob)
   In-Reply-To: <patchbomb.315532860@*> (glob)
   References: <patchbomb.315532860@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.315532860@*> (glob)
+  X-Mercurial-Series-Id: <ff2c9fa2018b15fa74b3.315532861@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Tue, 01 Jan 1980 00:01:04 +0000
   From: test
@@ -2491,7 +2478,7 @@
   Message-Id: <5d5ef15dfe5e7bd3a4ee.315532865@*> (glob)
   In-Reply-To: <patchbomb.315532860@*> (glob)
   References: <patchbomb.315532860@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.315532860@*> (glob)
+  X-Mercurial-Series-Id: <ff2c9fa2018b15fa74b3.315532861@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Tue, 01 Jan 1980 00:01:05 +0000
   From: test
@@ -2523,7 +2510,7 @@
   Message-Id: <2f9fa9b998c5fe3ac2bd.315532866@*> (glob)
   In-Reply-To: <patchbomb.315532860@*> (glob)
   References: <patchbomb.315532860@*> (glob)
-  X-Mercurial-Series-Id: <patchbomb.315532860@*> (glob)
+  X-Mercurial-Series-Id: <ff2c9fa2018b15fa74b3.315532861@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Tue, 01 Jan 1980 00:01:06 +0000
   From: test