Patchwork [1,of,8] py3: fix type of regex literals in patch.py

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 3, 2017, 2:36 p.m.
Message ID <313ecdde1470bb3a0e1f.1504449379@mimosa>
Download mbox | patch
Permalink /patch/23640/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 3, 2017, 2:36 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1504422735 -32400
#      Sun Sep 03 16:12:15 2017 +0900
# Node ID 313ecdde1470bb3a0e1f9beced7e596b8004e456
# Parent  68afb88b51bb626cd25440e2df812f2306463b55
py3: fix type of regex literals in patch.py
Augie Fackler - Sept. 13, 2017, 3 a.m.
On Sun, Sep 03, 2017 at 11:36:19PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1504422735 -32400
> #      Sun Sep 03 16:12:15 2017 +0900
> # Node ID 313ecdde1470bb3a0e1f9beced7e596b8004e456
> # Parent  68afb88b51bb626cd25440e2df812f2306463b55
> py3: fix type of regex literals in patch.py

Series LGTM, but I can't get them to apply despite my best efforts. Resend?

Or just push them yourself, and I'll look at them when they land. Either way.

>
> diff --git a/mercurial/patch.py b/mercurial/patch.py
> --- a/mercurial/patch.py
> +++ b/mercurial/patch.py
> @@ -205,10 +205,11 @@ def extract(ui, fileobj):
>
>      # attempt to detect the start of a patch
>      # (this heuristic is borrowed from quilt)
> -    diffre = re.compile(r'^(?:Index:[ \t]|diff[ \t]|RCS file: |'
> -                        r'retrieving revision [0-9]+(\.[0-9]+)*$|'
> -                        r'---[ \t].*?^\+\+\+[ \t]|'
> -                        r'\*\*\*[ \t].*?^---[ \t])', re.MULTILINE|re.DOTALL)
> +    diffre = re.compile(br'^(?:Index:[ \t]|diff[ \t]|RCS file: |'
> +                        br'retrieving revision [0-9]+(\.[0-9]+)*$|'
> +                        br'---[ \t].*?^\+\+\+[ \t]|'
> +                        br'\*\*\*[ \t].*?^---[ \t])',
> +                        re.MULTILINE | re.DOTALL)
>
>      data = {}
>      fd, tmpname = tempfile.mkstemp(prefix='hg-patch-')
> @@ -230,7 +231,7 @@ def extract(ui, fileobj):
>                  pend = subject.find(']')
>                  if pend >= 0:
>                      subject = subject[pend + 1:].lstrip()
> -            subject = re.sub(r'\n[ \t]+', ' ', subject)
> +            subject = re.sub(br'\n[ \t]+', ' ', subject)
>              ui.debug('Subject: %s\n' % subject)
>          if data['user']:
>              ui.debug('From: %s\n' % data['user'])
> @@ -1760,7 +1761,7 @@ def scanpatch(fp):
>      - ('hunk',    [hunk_lines])
>      - ('range',   (-start,len, +start,len, proc))
>      """
> -    lines_re = re.compile(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)')
> +    lines_re = re.compile(br'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)')
>      lr = linereader(fp)
>
>      def scanwhile(first, p):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Yuya Nishihara - Sept. 13, 2017, 1:04 p.m.
On Tue, 12 Sep 2017 23:00:03 -0400, Augie Fackler wrote:
> On Sun, Sep 03, 2017 at 11:36:19PM +0900, Yuya Nishihara wrote:
> > # HG changeset patch
> > # User Yuya Nishihara <yuya@tcha.org>
> > # Date 1504422735 -32400
> > #      Sun Sep 03 16:12:15 2017 +0900
> > # Node ID 313ecdde1470bb3a0e1f9beced7e596b8004e456
> > # Parent  68afb88b51bb626cd25440e2df812f2306463b55
> > py3: fix type of regex literals in patch.py
> 
> Series LGTM, but I can't get them to apply despite my best efforts. Resend?

This has been queued by Sean. Perhaps his email was bounced.
Augie Fackler - Sept. 13, 2017, 2:01 p.m.
> On Sep 13, 2017, at 09:04, Yuya Nishihara <yuya@tcha.org> wrote:
> 
> On Tue, 12 Sep 2017 23:00:03 -0400, Augie Fackler wrote:
>> On Sun, Sep 03, 2017 at 11:36:19PM +0900, Yuya Nishihara wrote:
>>> # HG changeset patch
>>> # User Yuya Nishihara <yuya@tcha.org>
>>> # Date 1504422735 -32400
>>> #      Sun Sep 03 16:12:15 2017 +0900
>>> # Node ID 313ecdde1470bb3a0e1f9beced7e596b8004e456
>>> # Parent  68afb88b51bb626cd25440e2df812f2306463b55
>>> py3: fix type of regex literals in patch.py
>> 
>> Series LGTM, but I can't get them to apply despite my best efforts. Resend?
> 
> This has been queued by Sean. Perhaps his email was bounced.

Argh. I'll look into whitelisting his domain on the hg server end.

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -205,10 +205,11 @@  def extract(ui, fileobj):
 
     # attempt to detect the start of a patch
     # (this heuristic is borrowed from quilt)
-    diffre = re.compile(r'^(?:Index:[ \t]|diff[ \t]|RCS file: |'
-                        r'retrieving revision [0-9]+(\.[0-9]+)*$|'
-                        r'---[ \t].*?^\+\+\+[ \t]|'
-                        r'\*\*\*[ \t].*?^---[ \t])', re.MULTILINE|re.DOTALL)
+    diffre = re.compile(br'^(?:Index:[ \t]|diff[ \t]|RCS file: |'
+                        br'retrieving revision [0-9]+(\.[0-9]+)*$|'
+                        br'---[ \t].*?^\+\+\+[ \t]|'
+                        br'\*\*\*[ \t].*?^---[ \t])',
+                        re.MULTILINE | re.DOTALL)
 
     data = {}
     fd, tmpname = tempfile.mkstemp(prefix='hg-patch-')
@@ -230,7 +231,7 @@  def extract(ui, fileobj):
                 pend = subject.find(']')
                 if pend >= 0:
                     subject = subject[pend + 1:].lstrip()
-            subject = re.sub(r'\n[ \t]+', ' ', subject)
+            subject = re.sub(br'\n[ \t]+', ' ', subject)
             ui.debug('Subject: %s\n' % subject)
         if data['user']:
             ui.debug('From: %s\n' % data['user'])
@@ -1760,7 +1761,7 @@  def scanpatch(fp):
     - ('hunk',    [hunk_lines])
     - ('range',   (-start,len, +start,len, proc))
     """
-    lines_re = re.compile(r'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)')
+    lines_re = re.compile(br'@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)')
     lr = linereader(fp)
 
     def scanwhile(first, p):