[PATCH] Fix parsing of interesing series reply structures

Daniel Axtens dja at axtens.net
Thu Nov 17 15:53:35 AEDT 2016


There are some things probably shouldn't do on public mailing
lists, but which people do anyway.

The first, and most understandable, is this:

          - [PATCH 1/2] test: Add some lorem ipsum
            - [PATCH 2/2] test: Convert to Markdown
              - [PATCH v2 1/2] test: Add some lorem ipsum
                - [PATCH v2 2/2] test: Convert to Markdown

We should correctly parse these by:
 - creating a new series if the version number changes
 - when deciding whether to create a SeriesReference, search by
   message-id alone, not the message-id/series pair. (Otherwise,
   we try to create a series ref for v1 2/2 in the series for v2,
   which breaks a uniqueness constraint.

The second, and less excusable, is this:

          - [PATCH 1/2] test: Add some lorem ipsum
            - [PATCH 2/2] test: Convert to Markdown
              - [PATCH 1/2] test: Add some lorem ipsum
                - [PATCH 2/2] test: Convert to Markdown

Parsing this is *hard*, especially if we handle out-of-order delivery.
I think this is so obtuse that anything short of crashing is
acceptable.

With this patch:
 - add a guard to add_patch so that if we're adding patch number x, but
   there is an existing x of n in the series, we bail without adding it.
 - this means that we end up with the second [1/2] without a series, and
   the second [2/2] in an untitled series. This is bad, but better than
   crashing, and it's very hard to figure out how to stop 2/2 getting a
   series of its own.

Signed-off-by: Daniel Axtens <dja at axtens.net>
---
 patchwork/models.py                                |   6 +
 patchwork/parser.py                                |  28 ++-
 patchwork/tests/series/bugs-nocover-noversion.mbox | 222 +++++++++++++++++++++
 patchwork/tests/series/bugs-nocover.mbox           | 222 +++++++++++++++++++++
 patchwork/tests/test_series.py                     |  46 +++++
 5 files changed, 518 insertions(+), 6 deletions(-)
 create mode 100644 patchwork/tests/series/bugs-nocover-noversion.mbox
 create mode 100644 patchwork/tests/series/bugs-nocover.mbox

diff --git a/patchwork/models.py b/patchwork/models.py
index a27dda65649a..62d916447da2 100644
--- a/patchwork/models.py
+++ b/patchwork/models.py
@@ -669,6 +669,12 @@ class Series(models.Model):
             # future
             return
 
+        # see if we've already got this patch in this series
+        if SeriesPatch.objects.filter(series=self, number=number).count():
+            # this is probably due to getting some poorly-behaved email: see
+            # test_series.py - RevisedSeriesTest.test_reply_nocover_noversion
+            return
+
         # both user defined names and cover letter-based names take precedence
         if not self.name and number == 1:
             self.name = patch.name  # keep the prefixes for patch-based names
diff --git a/patchwork/parser.py b/patchwork/parser.py
index b1544c951a3f..c731f6dc3668 100644
--- a/patchwork/parser.py
+++ b/patchwork/parser.py
@@ -789,7 +789,12 @@ def parse_mail(mail, list_id=None):
             delegate = auto_delegate(project, filenames)
 
         series = find_series(mail)
-        if not series and n:  # the series markers indicates a series
+        # We will create a new series if:
+        # - we have a patch number (x of n), and
+        # - either:
+        #    * there is no series, or
+        #    * the version doesn't match
+        if n and ((not series) or (series.version != version)):
             series = Series(date=date,
                             submitter=author,
                             version=version,
@@ -803,7 +808,15 @@ def parse_mail(mail, list_id=None):
             # as the earlier patch does not reference the later one.
             for ref in refs + [msgid]:
                 # we don't want duplicates
-                SeriesReference.objects.get_or_create(series=series, msgid=ref)
+                try:
+                    # we could have a ref to a previous series. (For
+                    # example, a series sent in reply to another
+                    # series.) That should not create a series ref
+                    # for this series, so check for the msg-id only,
+                    # not the msg-id/series pair.
+                    SeriesReference.objects.get(msgid=ref)
+                except SeriesReference.DoesNotExist:
+                    SeriesReference.objects.create(series=series, msgid=ref)
 
         patch = Patch(
             msgid=msgid,
@@ -820,10 +833,13 @@ def parse_mail(mail, list_id=None):
         patch.save()
         logger.debug('Patch saved')
 
-        # add to a series if we have found one, and we have a numbered
-        # patch. Don't add unnumbered patches (for example diffs sent
-        # in reply, or just messages with random refs/in-reply-tos)
-        if series and x:
+        # add to a series if:
+        # - we have found a series
+        # - we have a numbered patch. Don't add unnumbered patches
+        #   (for example diffs sent in reply, or just messages with
+        #   random refs/in-reply-tos)
+        # - the series version matches.
+        if series and x and series.version == version:
             series.add_patch(patch, x)
 
         return patch
diff --git a/patchwork/tests/series/bugs-nocover-noversion.mbox b/patchwork/tests/series/bugs-nocover-noversion.mbox
new file mode 100644
index 000000000000..77308386f1bf
--- /dev/null
+++ b/patchwork/tests/series/bugs-nocover-noversion.mbox
@@ -0,0 +1,222 @@
+From stephenfinucane at gmail.com Sun Sep 11 23:22:13 2016
+Return-Path: <stephenfinucane at gmail.com>
+From: Stephen Finucane <stephenfinucane at gmail.com>
+To: stephenfinucane at hotmail.com
+Subject: [PATCH 1/2] test: Add some lorem ipsum
+Date: Sun, 11 Sep 2016 23:22:03 +0100
+Message-ID: <1473632524-8585-2-git-send-email-stephenfinucane at gmail.com>
+X-Mailer: git-send-email 2.7.4
+MIME-Version: 1.0
+Content-Type: text/plain
+Content-Length: 670
+Lines: 22
+
+From: Stephen Finucane <stephenfinucane at hotmail.com>
+
+---
+ test.txt | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/test.txt b/test.txt
+index f75ba05..a6c61c0 100644
+--- a/test.txt
++++ b/test.txt
+@@ -1 +1,8 @@
+ Hello, world.
++
++Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eget eleifend
++augue. Nullam at metus venenatis, laoreet neque nec, convallis mauris.
++Pellentesque aliquam at nisi et laoreet. Duis non nisl venenatis, rhoncus risus
++id, elementum felis. In hac habitasse platea dictumst. Nam sit amet maximus
++eros. Nam quis ligula ut tortor egestas bibendum. Nunc sed purus sit amet
++tellus commodo bibendum ut vel dolor.
+-- 
+2.7.4
+
+
+From stephenfinucane at gmail.com Sun Sep 11 23:22:16 2016
+Return-Path: <stephenfinucane at gmail.com>
+From: Stephen Finucane <stephenfinucane at gmail.com>
+To: stephenfinucane at hotmail.com
+Subject: [PATCH 2/2] test: Convert to Markdown
+Date: Sun, 11 Sep 2016 23:22:04 +0100
+Message-ID: <1473632524-8585-3-git-send-email-stephenfinucane at gmail.com>
+X-Mailer: git-send-email 2.7.4
+In-Reply-To: <1473632524-8585-2-git-send-email-stephenfinucane at gmail.com>
+References: <1473632524-8585-2-git-send-email-stephenfinucane at gmail.com>
+MIME-Version: 1.0
+Content-Type: text/plain
+Content-Length: 1345
+Lines: 40
+
+From: Stephen Finucane <stephenfinucane at hotmail.com>
+
+---
+ test.md  | 8 ++++++++
+ test.txt | 8 --------
+ 2 files changed, 8 insertions(+), 8 deletions(-)
+ create mode 100644 test.md
+ delete mode 100644 test.txt
+
+diff --git a/test.md b/test.md
+new file mode 100644
+index 0000000..e5ff90e
+--- /dev/null
++++ b/test.md
+@@ -0,0 +1,8 @@
++# Hello, world
++
++Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eget eleifend
++augue. Nullam at metus venenatis, laoreet neque nec, convallis mauris.
++Pellentesque aliquam at nisi et laoreet. Duis non nisl venenatis, rhoncus risus
++id, elementum felis. In hac habitasse platea dictumst. Nam sit amet maximus
++eros. Nam quis ligula ut tortor egestas bibendum. Nunc sed purus sit amet
++tellus commodo bibendum ut vel dolor.
+diff --git a/test.txt b/test.txt
+deleted file mode 100644
+index a6c61c0..0000000
+--- a/test.txt
++++ /dev/null
+@@ -1,8 +0,0 @@
+-Hello, world.
+-
+-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eget eleifend
+-augue. Nullam at metus venenatis, laoreet neque nec, convallis mauris.
+-Pellentesque aliquam at nisi et laoreet. Duis non nisl venenatis, rhoncus risus
+-id, elementum felis. In hac habitasse platea dictumst. Nam sit amet maximus
+-eros. Nam quis ligula ut tortor egestas bibendum. Nunc sed purus sit amet
+-tellus commodo bibendum ut vel dolor.
+-- 
+2.7.4
+
+
+From stephenfinucane at gmail.com Sun Sep 11 23:31:04 2016
+Return-Path: <stephenfinucane at gmail.com>
+From: Stephen Finucane <stephenfinucane at gmail.com>
+To: stephenfinucane at hotmail.com
+Subject: [PATCH 1/2] test: Add some lorem ipsum
+Date: Sun, 11 Sep 2016 23:30:54 +0100
+Message-ID: <1473633055-10316-2-git-send-email-stephenfinucane at gmail.com>
+X-Mailer: git-send-email 2.7.4
+In-Reply-To: <1473632524-8585-2-git-send-email-stephenfinucane at gmail.com>
+References: <1473632524-8585-2-git-send-email-stephenfinucane at gmail.com>
+MIME-Version: 1.0
+Content-Type: text/plain
+Content-Length: 1363
+Lines: 35
+
+From: Stephen Finucane <stephenfinucane at hotmail.com>
+
+This is a better commit message.
+---
+v2:
+- Add some additional content
+---
+ test.txt | 16 ++++++++++++++++
+ 1 file changed, 16 insertions(+)
+
+diff --git a/test.txt b/test.txt
+index f75ba05..4478ac2 100644
+--- a/test.txt
++++ b/test.txt
+@@ -1 +1,17 @@
+ Hello, world.
++
++Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eget eleifend
++augue. Nullam at metus venenatis, laoreet neque nec, convallis mauris.
++Pellentesque aliquam at nisi et laoreet. Duis non nisl venenatis, rhoncus risus
++id, elementum felis. In hac habitasse platea dictumst. Nam sit amet maximus
++eros. Nam quis ligula ut tortor egestas bibendum. Nunc sed purus sit amet
++tellus commodo bibendum ut vel dolor.
++
++Curabitur scelerisque tempus efficitur. Maecenas aliquet elementum quam, ac
++pharetra nisi gravida a. Nam vitae malesuada leo. Nam accumsan facilisis metus
++sed vulputate. Ut libero odio, tempor ac posuere vel, malesuada quis ex. Donec
++interdum ipsum et nibh molestie auctor eget in neque. Sed nec hendrerit enim.
++Etiam scelerisque non magna eu molestie. Maecenas dui quam, tempor quis ipsum
++eu, dapibus congue dui. Integer tincidunt accumsan tortor sed maximus. Praesent
++eu magna accumsan, consequat turpis quis, fringilla ante. Vestibulum nec
++maximus nulla. Donec vehicula nisl at pharetra eleifend.
+-- 
+2.7.4
+
+
+From stephenfinucane at gmail.com Sun Sep 11 23:31:07 2016
+Return-Path: <stephenfinucane at gmail.com>
+Received: from MARS.lan (host39-81.statics.netsource.ie. [212.17.39.81])
+        by smtp.gmail.com with ESMTPSA id e5sm14784082wma.13.2016.09.11.15.31.01
+        for <stephenfinucane at hotmail.com>
+        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
+        Sun, 11 Sep 2016 15:31:01 -0700 (PDT)
+From: Stephen Finucane <stephenfinucane at gmail.com>
+To: stephenfinucane at hotmail.com
+Subject: [PATCH 2/2] test: Convert to Markdown
+Date: Sun, 11 Sep 2016 23:30:55 +0100
+Message-ID: <1473633055-10316-3-git-send-email-stephenfinucane at gmail.com>
+X-Mailer: git-send-email 2.7.4
+In-Reply-To: <1473633055-10316-2-git-send-email-stephenfinucane at gmail.com>
+References: <1473633055-10316-2-git-send-email-stephenfinucane at gmail.com>
+MIME-Version: 1.0
+Content-Type: text/plain
+Content-Length: 2589
+Lines: 58
+
+From: Stephen Finucane <stephenfinucane at hotmail.com>
+
+---
+ test.md  | 17 +++++++++++++++++
+ test.txt | 17 -----------------
+ 2 files changed, 17 insertions(+), 17 deletions(-)
+ create mode 100644 test.md
+ delete mode 100644 test.txt
+
+diff --git a/test.md b/test.md
+new file mode 100644
+index 0000000..201bfe7
+--- /dev/null
++++ b/test.md
+@@ -0,0 +1,17 @@
++# Hello, world
++
++Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eget eleifend
++augue. Nullam at metus venenatis, laoreet neque nec, convallis mauris.
++Pellentesque aliquam at nisi et laoreet. Duis non nisl venenatis, rhoncus risus
++id, elementum felis. In hac habitasse platea dictumst. Nam sit amet maximus
++eros. Nam quis ligula ut tortor egestas bibendum. Nunc sed purus sit amet
++tellus commodo bibendum ut vel dolor.
++
++Curabitur scelerisque tempus efficitur. Maecenas aliquet elementum quam, ac
++pharetra nisi gravida a. Nam vitae malesuada leo. Nam accumsan facilisis metus
++sed vulputate. Ut libero odio, tempor ac posuere vel, malesuada quis ex. Donec
++interdum ipsum et nibh molestie auctor eget in neque. Sed nec hendrerit enim.
++Etiam scelerisque non magna eu molestie. Maecenas dui quam, tempor quis ipsum
++eu, dapibus congue dui. Integer tincidunt accumsan tortor sed maximus. Praesent
++eu magna accumsan, consequat turpis quis, fringilla ante. Vestibulum nec
++maximus nulla. Donec vehicula nisl at pharetra eleifend.
+diff --git a/test.txt b/test.txt
+deleted file mode 100644
+index 4478ac2..0000000
+--- a/test.txt
++++ /dev/null
+@@ -1,17 +0,0 @@
+-Hello, world.
+-
+-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eget eleifend
+-augue. Nullam at metus venenatis, laoreet neque nec, convallis mauris.
+-Pellentesque aliquam at nisi et laoreet. Duis non nisl venenatis, rhoncus risus
+-id, elementum felis. In hac habitasse platea dictumst. Nam sit amet maximus
+-eros. Nam quis ligula ut tortor egestas bibendum. Nunc sed purus sit amet
+-tellus commodo bibendum ut vel dolor.
+-
+-Curabitur scelerisque tempus efficitur. Maecenas aliquet elementum quam, ac
+-pharetra nisi gravida a. Nam vitae malesuada leo. Nam accumsan facilisis metus
+-sed vulputate. Ut libero odio, tempor ac posuere vel, malesuada quis ex. Donec
+-interdum ipsum et nibh molestie auctor eget in neque. Sed nec hendrerit enim.
+-Etiam scelerisque non magna eu molestie. Maecenas dui quam, tempor quis ipsum
+-eu, dapibus congue dui. Integer tincidunt accumsan tortor sed maximus. Praesent
+-eu magna accumsan, consequat turpis quis, fringilla ante. Vestibulum nec
+-maximus nulla. Donec vehicula nisl at pharetra eleifend.
+-- 
+2.7.4
+
+
diff --git a/patchwork/tests/series/bugs-nocover.mbox b/patchwork/tests/series/bugs-nocover.mbox
new file mode 100644
index 000000000000..a433c7f06107
--- /dev/null
+++ b/patchwork/tests/series/bugs-nocover.mbox
@@ -0,0 +1,222 @@
+From stephenfinucane at gmail.com Sun Sep 11 23:22:13 2016
+Return-Path: <stephenfinucane at gmail.com>
+From: Stephen Finucane <stephenfinucane at gmail.com>
+To: stephenfinucane at hotmail.com
+Subject: [PATCH 1/2] test: Add some lorem ipsum
+Date: Sun, 11 Sep 2016 23:22:03 +0100
+Message-ID: <1473632524-8585-2-git-send-email-stephenfinucane at gmail.com>
+X-Mailer: git-send-email 2.7.4
+MIME-Version: 1.0
+Content-Type: text/plain
+Content-Length: 670
+Lines: 22
+
+From: Stephen Finucane <stephenfinucane at hotmail.com>
+
+---
+ test.txt | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/test.txt b/test.txt
+index f75ba05..a6c61c0 100644
+--- a/test.txt
++++ b/test.txt
+@@ -1 +1,8 @@
+ Hello, world.
++
++Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eget eleifend
++augue. Nullam at metus venenatis, laoreet neque nec, convallis mauris.
++Pellentesque aliquam at nisi et laoreet. Duis non nisl venenatis, rhoncus risus
++id, elementum felis. In hac habitasse platea dictumst. Nam sit amet maximus
++eros. Nam quis ligula ut tortor egestas bibendum. Nunc sed purus sit amet
++tellus commodo bibendum ut vel dolor.
+-- 
+2.7.4
+
+
+From stephenfinucane at gmail.com Sun Sep 11 23:22:16 2016
+Return-Path: <stephenfinucane at gmail.com>
+From: Stephen Finucane <stephenfinucane at gmail.com>
+To: stephenfinucane at hotmail.com
+Subject: [PATCH 2/2] test: Convert to Markdown
+Date: Sun, 11 Sep 2016 23:22:04 +0100
+Message-ID: <1473632524-8585-3-git-send-email-stephenfinucane at gmail.com>
+X-Mailer: git-send-email 2.7.4
+In-Reply-To: <1473632524-8585-2-git-send-email-stephenfinucane at gmail.com>
+References: <1473632524-8585-2-git-send-email-stephenfinucane at gmail.com>
+MIME-Version: 1.0
+Content-Type: text/plain
+Content-Length: 1345
+Lines: 40
+
+From: Stephen Finucane <stephenfinucane at hotmail.com>
+
+---
+ test.md  | 8 ++++++++
+ test.txt | 8 --------
+ 2 files changed, 8 insertions(+), 8 deletions(-)
+ create mode 100644 test.md
+ delete mode 100644 test.txt
+
+diff --git a/test.md b/test.md
+new file mode 100644
+index 0000000..e5ff90e
+--- /dev/null
++++ b/test.md
+@@ -0,0 +1,8 @@
++# Hello, world
++
++Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eget eleifend
++augue. Nullam at metus venenatis, laoreet neque nec, convallis mauris.
++Pellentesque aliquam at nisi et laoreet. Duis non nisl venenatis, rhoncus risus
++id, elementum felis. In hac habitasse platea dictumst. Nam sit amet maximus
++eros. Nam quis ligula ut tortor egestas bibendum. Nunc sed purus sit amet
++tellus commodo bibendum ut vel dolor.
+diff --git a/test.txt b/test.txt
+deleted file mode 100644
+index a6c61c0..0000000
+--- a/test.txt
++++ /dev/null
+@@ -1,8 +0,0 @@
+-Hello, world.
+-
+-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eget eleifend
+-augue. Nullam at metus venenatis, laoreet neque nec, convallis mauris.
+-Pellentesque aliquam at nisi et laoreet. Duis non nisl venenatis, rhoncus risus
+-id, elementum felis. In hac habitasse platea dictumst. Nam sit amet maximus
+-eros. Nam quis ligula ut tortor egestas bibendum. Nunc sed purus sit amet
+-tellus commodo bibendum ut vel dolor.
+-- 
+2.7.4
+
+
+From stephenfinucane at gmail.com Sun Sep 11 23:31:04 2016
+Return-Path: <stephenfinucane at gmail.com>
+From: Stephen Finucane <stephenfinucane at gmail.com>
+To: stephenfinucane at hotmail.com
+Subject: [PATCH v2 1/2] test: Add some lorem ipsum
+Date: Sun, 11 Sep 2016 23:30:54 +0100
+Message-ID: <1473633055-10316-2-git-send-email-stephenfinucane at gmail.com>
+X-Mailer: git-send-email 2.7.4
+In-Reply-To: <1473632524-8585-2-git-send-email-stephenfinucane at gmail.com>
+References: <1473632524-8585-2-git-send-email-stephenfinucane at gmail.com>
+MIME-Version: 1.0
+Content-Type: text/plain
+Content-Length: 1363
+Lines: 35
+
+From: Stephen Finucane <stephenfinucane at hotmail.com>
+
+This is a better commit message.
+---
+v2:
+- Add some additional content
+---
+ test.txt | 16 ++++++++++++++++
+ 1 file changed, 16 insertions(+)
+
+diff --git a/test.txt b/test.txt
+index f75ba05..4478ac2 100644
+--- a/test.txt
++++ b/test.txt
+@@ -1 +1,17 @@
+ Hello, world.
++
++Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eget eleifend
++augue. Nullam at metus venenatis, laoreet neque nec, convallis mauris.
++Pellentesque aliquam at nisi et laoreet. Duis non nisl venenatis, rhoncus risus
++id, elementum felis. In hac habitasse platea dictumst. Nam sit amet maximus
++eros. Nam quis ligula ut tortor egestas bibendum. Nunc sed purus sit amet
++tellus commodo bibendum ut vel dolor.
++
++Curabitur scelerisque tempus efficitur. Maecenas aliquet elementum quam, ac
++pharetra nisi gravida a. Nam vitae malesuada leo. Nam accumsan facilisis metus
++sed vulputate. Ut libero odio, tempor ac posuere vel, malesuada quis ex. Donec
++interdum ipsum et nibh molestie auctor eget in neque. Sed nec hendrerit enim.
++Etiam scelerisque non magna eu molestie. Maecenas dui quam, tempor quis ipsum
++eu, dapibus congue dui. Integer tincidunt accumsan tortor sed maximus. Praesent
++eu magna accumsan, consequat turpis quis, fringilla ante. Vestibulum nec
++maximus nulla. Donec vehicula nisl at pharetra eleifend.
+-- 
+2.7.4
+
+
+From stephenfinucane at gmail.com Sun Sep 11 23:31:07 2016
+Return-Path: <stephenfinucane at gmail.com>
+Received: from MARS.lan (host39-81.statics.netsource.ie. [212.17.39.81])
+        by smtp.gmail.com with ESMTPSA id e5sm14784082wma.13.2016.09.11.15.31.01
+        for <stephenfinucane at hotmail.com>
+        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
+        Sun, 11 Sep 2016 15:31:01 -0700 (PDT)
+From: Stephen Finucane <stephenfinucane at gmail.com>
+To: stephenfinucane at hotmail.com
+Subject: [PATCH v2 2/2] test: Convert to Markdown
+Date: Sun, 11 Sep 2016 23:30:55 +0100
+Message-ID: <1473633055-10316-3-git-send-email-stephenfinucane at gmail.com>
+X-Mailer: git-send-email 2.7.4
+In-Reply-To: <1473633055-10316-2-git-send-email-stephenfinucane at gmail.com>
+References: <1473633055-10316-2-git-send-email-stephenfinucane at gmail.com>
+MIME-Version: 1.0
+Content-Type: text/plain
+Content-Length: 2589
+Lines: 58
+
+From: Stephen Finucane <stephenfinucane at hotmail.com>
+
+---
+ test.md  | 17 +++++++++++++++++
+ test.txt | 17 -----------------
+ 2 files changed, 17 insertions(+), 17 deletions(-)
+ create mode 100644 test.md
+ delete mode 100644 test.txt
+
+diff --git a/test.md b/test.md
+new file mode 100644
+index 0000000..201bfe7
+--- /dev/null
++++ b/test.md
+@@ -0,0 +1,17 @@
++# Hello, world
++
++Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eget eleifend
++augue. Nullam at metus venenatis, laoreet neque nec, convallis mauris.
++Pellentesque aliquam at nisi et laoreet. Duis non nisl venenatis, rhoncus risus
++id, elementum felis. In hac habitasse platea dictumst. Nam sit amet maximus
++eros. Nam quis ligula ut tortor egestas bibendum. Nunc sed purus sit amet
++tellus commodo bibendum ut vel dolor.
++
++Curabitur scelerisque tempus efficitur. Maecenas aliquet elementum quam, ac
++pharetra nisi gravida a. Nam vitae malesuada leo. Nam accumsan facilisis metus
++sed vulputate. Ut libero odio, tempor ac posuere vel, malesuada quis ex. Donec
++interdum ipsum et nibh molestie auctor eget in neque. Sed nec hendrerit enim.
++Etiam scelerisque non magna eu molestie. Maecenas dui quam, tempor quis ipsum
++eu, dapibus congue dui. Integer tincidunt accumsan tortor sed maximus. Praesent
++eu magna accumsan, consequat turpis quis, fringilla ante. Vestibulum nec
++maximus nulla. Donec vehicula nisl at pharetra eleifend.
+diff --git a/test.txt b/test.txt
+deleted file mode 100644
+index 4478ac2..0000000
+--- a/test.txt
++++ /dev/null
+@@ -1,17 +0,0 @@
+-Hello, world.
+-
+-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eget eleifend
+-augue. Nullam at metus venenatis, laoreet neque nec, convallis mauris.
+-Pellentesque aliquam at nisi et laoreet. Duis non nisl venenatis, rhoncus risus
+-id, elementum felis. In hac habitasse platea dictumst. Nam sit amet maximus
+-eros. Nam quis ligula ut tortor egestas bibendum. Nunc sed purus sit amet
+-tellus commodo bibendum ut vel dolor.
+-
+-Curabitur scelerisque tempus efficitur. Maecenas aliquet elementum quam, ac
+-pharetra nisi gravida a. Nam vitae malesuada leo. Nam accumsan facilisis metus
+-sed vulputate. Ut libero odio, tempor ac posuere vel, malesuada quis ex. Donec
+-interdum ipsum et nibh molestie auctor eget in neque. Sed nec hendrerit enim.
+-Etiam scelerisque non magna eu molestie. Maecenas dui quam, tempor quis ipsum
+-eu, dapibus congue dui. Integer tincidunt accumsan tortor sed maximus. Praesent
+-eu magna accumsan, consequat turpis quis, fringilla ante. Vestibulum nec
+-maximus nulla. Donec vehicula nisl at pharetra eleifend.
+-- 
+2.7.4
+
+
diff --git a/patchwork/tests/test_series.py b/patchwork/tests/test_series.py
index 58abb0df303c..ae6e378d9dc5 100644
--- a/patchwork/tests/test_series.py
+++ b/patchwork/tests/test_series.py
@@ -309,6 +309,52 @@ class RevisedSeriesTest(_BaseTestCase):
         self.assertEqual(len([p for p in patches if not p.latest_series]), 1)
         self.assertSerialized(covers, [1])
 
+    def test_reply_nocover_noversion(self):
+        """Series with a revision sent without a version label or cover
+        letter, in reply to earlier version of the same series.
+
+        Parse a series with two patches, followed by a second revision
+        of the same. The second revision is not labeled with a series
+        version marker.
+
+        This is really, really annoying and people shouldn't do it.
+        If we can just parse this without crashing, that's probably
+        good enough. At the time of writing, the second [1/2] will
+        not get a series, and the second [2/2] will get an untitled
+        series. This sucks, but it's difficult to know how to stop
+        that from happening.
+
+        Input:
+
+            - [PATCH 1/2] test: Add some lorem ipsum
+              - [PATCH 2/2] test: Convert to Markdown
+                - [PATCH 1/2] test: Add some lorem ipsum
+                  - [PATCH 2/2] test: Convert to Markdown
+
+        """
+        covers, patches, _ = self._parse_mbox(
+            'bugs-nocover-noversion.mbox', [0, 4, 0])
+
+    def test_reply_nocover(self):
+        """Series with a revision sent in-reply-to a patch, no cover letters.
+
+        Parse a series with two patches, followed by a second revision
+        of the same. The second revision is correctly labeled but is
+        sent in reply to the second patch of the first revision.
+
+        Input:
+
+          - [PATCH 1/2] test: Add some lorem ipsum
+            - [PATCH 2/2] test: Convert to Markdown
+              - [PATCH v2 1/2] test: Add some lorem ipsum
+                - [PATCH v2 2/2] test: Convert to Markdown
+
+        """
+        covers, patches, _ = self._parse_mbox(
+            'bugs-nocover.mbox', [0, 4, 0])
+
+        self.assertSerialized(patches, [2, 2])
+
 
 class SeriesNameTestCase(TestCase):
 
-- 
2.7.4



More information about the Patchwork mailing list