parser: Detect series markers Mercurial produces

Submitted by Andrew Shadura on Jan. 22, 2017, 12:44 a.m.

Details

Message ID 20170122004454.7988-1-andrew.shadura@collabora.co.uk
State Superseded
Headers show

Commit Message

Andrew Shadura Jan. 22, 2017, 12:44 a.m.
Unlike Git, Mercurial produces email subject lines of the
following format: "[PATCH M of N] ...". '(?:/| of )' pattern
matches both 'M/N' and 'M of N' formats.

Signed-off-by: Andrew Shadura <andrew.shadura@collabora.co.uk>
---
 patchwork/parser.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stephen Finucane Jan. 22, 2017, 9:28 p.m.
On Sun, 2017-01-22 at 01:44 +0100, Andrew Shadura wrote:
> Unlike Git, Mercurial produces email subject lines of the
> following format: "[PATCH M of N] ...". '(?:/| of )' pattern
> matches both 'M/N' and 'M of N' formats.
> 
> Signed-off-by: Andrew Shadura <andrew.shadura@collabora.co.uk>

This looks a-OK to me, but I would like to add an additional test case
in patchwork/tests/test_series.py to prevent this regressing if we
could. I can write the tests but I need some mbox files to validate
against. Could you supply me with some sample, Mercurial-produced patch
emails for this (email me directly)? A two patch series, with and
without a cover letter, would suffice (look at the files in
patchwork/tests/series for examples).

Thanks,
Stephen

> ---
>  patchwork/parser.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/patchwork/parser.py b/patchwork/parser.py
> index 16cc53c..2e692fa 100644
> --- a/patchwork/parser.py
> +++ b/patchwork/parser.py
> @@ -309,7 +309,7 @@ def parse_series_marker(subject_prefixes):
>          (x, n) if markers found, else (None, None)
>      """
>  
> -    regex = re.compile('^([0-9]+)/([0-9]+)$')
> +    regex = re.compile('^([0-9]+)(?:/| of )([0-9]+)$')
>      m = _find_matching_prefix(subject_prefixes, regex)
>      if m:
>          return (int(m.group(1)), int(m.group(2)))

Patch hide | download patch | download mbox

diff --git a/patchwork/parser.py b/patchwork/parser.py
index 16cc53c..2e692fa 100644
--- a/patchwork/parser.py
+++ b/patchwork/parser.py
@@ -309,7 +309,7 @@  def parse_series_marker(subject_prefixes):
         (x, n) if markers found, else (None, None)
     """
 
-    regex = re.compile('^([0-9]+)/([0-9]+)$')
+    regex = re.compile('^([0-9]+)(?:/| of )([0-9]+)$')
     m = _find_matching_prefix(subject_prefixes, regex)
     if m:
         return (int(m.group(1)), int(m.group(2)))