There are merits to supporting single-patch series, not least the ability to provide two consistent interfaces that show _all_ patches in the '/patches' endpoint and the '/series' endpoint.
Signed-off-by: Stephen Finucane <step...@that.guru> --- patchwork/parser.py | 21 ++++-- patchwork/tests/series/base-single-patch.mbox | 34 +++++++++ .../series/revision-threaded-to-single-patch.mbox | 85 ++++++++++++++++++++++ patchwork/tests/test_series.py | 38 ++++++++-- 4 files changed, 165 insertions(+), 13 deletions(-) create mode 100644 patchwork/tests/series/base-single-patch.mbox create mode 100644 patchwork/tests/series/revision-threaded-to-single-patch.mbox diff --git a/patchwork/parser.py b/patchwork/parser.py index aa5ac58..b6c8047 100644 --- a/patchwork/parser.py +++ b/patchwork/parser.py @@ -903,15 +903,20 @@ def parse_mail(mail, list_id=None): filenames = find_filenames(diff) delegate = find_delegate_by_filename(project, filenames) - series = find_series(project, mail) + # if we don't have a series marker, we will never have an existing + # series to match against. + series = None + if n: + series = find_series(project, mail) + else: + x = n = 1 + # We will create a new series if: - # - we have a patch number (x of n), and - # - either: - # * there is no series, or - # * we have a patch with this number already - if n and ((not series) or - (SeriesPatch.objects.filter(series=series, number=x).count() - )): + # - there is no existing series to assign this patch to, or + # - there is an existing series, but it already has a patch with this + # number in it + if not series or ( + SeriesPatch.objects.filter(series=series, number=x).count()): series = Series(project=project, date=date, submitter=author, diff --git a/patchwork/tests/series/base-single-patch.mbox b/patchwork/tests/series/base-single-patch.mbox new file mode 100644 index 0000000..a47c3cf --- /dev/null +++ b/patchwork/tests/series/base-single-patch.mbox @@ -0,0 +1,34 @@ +From stephenfinuc...@gmail.com Sun Sep 11 23:22:13 2016 +Return-Path: <stephenfinuc...@gmail.com> +From: Stephen Finucane <stephenfinuc...@gmail.com> +To: stephenfinuc...@hotmail.com +Subject: [PATCH] test: Add some lorem ipsum +Date: Sun, 11 Sep 2016 23:22:03 +0100 +Message-ID: <1473632524-8585-2-git-send-email-stephenfinuc...@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 <stephenfinuc...@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 diff --git a/patchwork/tests/series/revision-threaded-to-single-patch.mbox b/patchwork/tests/series/revision-threaded-to-single-patch.mbox new file mode 100644 index 0000000..1e7b952 --- /dev/null +++ b/patchwork/tests/series/revision-threaded-to-single-patch.mbox @@ -0,0 +1,85 @@ +From stephenfinuc...@gmail.com Sun Sep 11 23:22:13 2016 +Return-Path: <stephenfinuc...@gmail.com> +From: Stephen Finucane <stephenfinuc...@gmail.com> +To: stephenfinuc...@hotmail.com +Subject: [PATCH] test: Add some lorem ipsum +Date: Sun, 11 Sep 2016 23:22:03 +0100 +Message-ID: <1473632524-8585-2-git-send-email-stephenfinuc...@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 <stephenfinuc...@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 stephenfinuc...@gmail.com Sun Sep 11 23:31:04 2016 +Return-Path: <stephenfinuc...@gmail.com> +From: Stephen Finucane <stephenfinuc...@gmail.com> +To: stephenfinuc...@hotmail.com +Subject: [PATCH v2] test: Add some lorem ipsum +Date: Sun, 11 Sep 2016 23:30:54 +0100 +Message-ID: <1473633055-10316-2-git-send-email-stephenfinuc...@gmail.com> +X-Mailer: git-send-email 2.7.4 +In-Reply-To: <1473632524-8585-2-git-send-email-stephenfinuc...@gmail.com> +References: <1473632524-8585-2-git-send-email-stephenfinuc...@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain +Content-Length: 1363 +Lines: 35 + +From: Stephen Finucane <stephenfinuc...@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 diff --git a/patchwork/tests/test_series.py b/patchwork/tests/test_series.py index 390ee51..c1ede06 100644 --- a/patchwork/tests/test_series.py +++ b/patchwork/tests/test_series.py @@ -94,6 +94,20 @@ class _BaseTestCase(TestCase): class BaseSeriesTest(_BaseTestCase): """Tests for a series without any revisions.""" + def test_single_patch(self): + """Series with only a single patch. + + Parse a "series" with only a single patch and no subject prefixes. + + Input: + + - [PATCH] test: Add some lorem ipsum + """ + _, patches, _ = self._parse_mbox( + 'base-single-patch.mbox', [0, 1, 0]) + + self.assertSerialized(patches, [1]) + def test_cover_letter(self): """Series with a cover letter. @@ -291,6 +305,21 @@ class RevisedSeriesTest(_BaseTestCase): self.assertSerialized(patches, [2, 2]) self.assertSerialized(covers, [1, 1]) + def test_threaded_to_single_patch(self): + """Series with a revision sent in-reply-to a single-patch series. + + Parse a series with a single patch, followed by a second revision of + the same. The second revision is correctly labeled but is sent in reply + to the original patch. + + - [PATCH] test: Add some lorem ipsum + - [PATCH v2] test: Add some lorem ipsum + """ + _, patches, _ = self._parse_mbox( + 'revision-threaded-to-single-patch.mbox', [0, 2, 0]) + + self.assertSerialized(patches, [1, 1]) + def test_threaded_to_cover(self): """Series with a revision sent in-reply-to a cover. @@ -427,8 +456,8 @@ class RevisedSeriesTest(_BaseTestCase): """Series with a reply with a diff but no number. The random message with the diff should not belong to the - series, as it lacks a n/N label. We expect 1 series and the - random message to be orphaned. + series, as it lacks a n/N label. We expect two series and the + random message to be assigned its own series. Input: @@ -439,9 +468,8 @@ class RevisedSeriesTest(_BaseTestCase): covers, patches, _ = self._parse_mbox( 'bugs-unnumbered.mbox', [1, 2, 0]) - self.assertEqual(len([p for p in patches if p.latest_series]), 1) - self.assertEqual(len([p for p in patches if not p.latest_series]), 1) - self.assertSerialized(covers, [1]) + self.assertSerialized(patches, [1, 1]) + self.assertSerialized(covers, [1, 0]) def test_reply_nocover_noversion(self): """Series with a revision sent without a version label or cover -- 2.9.4 _______________________________________________ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork