Patchwork [2,of,2,V2] py3: use raw strings in line continuation (convert ext)

login
register
mail settings
Submitter Mateusz Kwapich
Date Oct. 10, 2016, 12:44 p.m.
Message ID <c3435d8ca0ecbe8b9952.1476103451@devvm314.lla2.facebook.com>
Download mbox | patch
Permalink /patch/17024/
State Accepted
Headers show

Comments

Mateusz Kwapich - Oct. 10, 2016, 12:44 p.m.
# HG changeset patch
# User Mateusz Kwapich <mitrandir@fb.com>
# Date 1476102691 25200
#      Mon Oct 10 05:31:31 2016 -0700
# Node ID c3435d8ca0ecbe8b99522170306ae52cc67c3743
# Parent  aeda1ae1dab23ba648806a632d86b49d802c84c0
py3: use raw strings in line continuation (convert ext)

Our py2 to py3 string translations marks those as bytestrings.
Pulkit Goyal - Oct. 10, 2016, 7:20 p.m.
On Oct 10, 2016 2:44 PM, "Mateusz Kwapich" <mitrandir@fb.com> wrote:
>
> # HG changeset patch
> # User Mateusz Kwapich <mitrandir@fb.com>
> # Date 1476102691 25200
> #      Mon Oct 10 05:31:31 2016 -0700
> # Node ID c3435d8ca0ecbe8b99522170306ae52cc67c3743
> # Parent  aeda1ae1dab23ba648806a632d86b49d802c84c0
> py3: use raw strings in line continuation (convert ext)
>

Thanks Mateusz for the patches, I feel like soon we will be able to say
"Mercurial is Python 3.5 compatible."

> Our py2 to py3 string translations marks those as bytestrings.
>
> diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py
> --- a/hgext/convert/subversion.py
> +++ b/hgext/convert/subversion.py
> @@ -531,8 +531,8 @@ class svn_source(converter_source):
>      def checkrevformat(self, revstr, mapname='splicemap'):
>          """ fails if revision format does not match the correct format"""
>          if not re.match(r'svn:[0-9a-f]{8,8}-[0-9a-f]{4,4}-'
> -                              '[0-9a-f]{4,4}-[0-9a-f]{4,4}-[0-9a-f]'
> -                              '{12,12}(.*)\@[0-9]+$',revstr):
> +                              r'[0-9a-f]{4,4}-[0-9a-f]{4,4}-[0-9a-f]'
> +                              r'{12,12}(.*)\@[0-9]+$',revstr):
>              raise error.Abort(_('%s entry %s is not a valid revision'
>                                 ' identifier') % (mapname, revstr))
>
> diff --git a/tests/test-check-py3-compat.t b/tests/test-check-py3-compat.t
> --- a/tests/test-check-py3-compat.t
> +++ b/tests/test-check-py3-compat.t
> @@ -16,24 +16,10 @@
>    $ hg files 'set:(**.py) - grep(pygments)' | sed 's|\\|/|g' \
>    > | xargs $PYTHON3 contrib/check-py3-compat.py \
>    > | sed 's/[0-9][0-9]*)$/*)/'
> -  hgext/convert/bzr.py: error importing: <SyntaxError> cannot mix bytes
and nonbytes literals (subversion.py, line 533) (error at convcmd.py:*)
> -  hgext/convert/convcmd.py: error importing: <SyntaxError> cannot mix
bytes and nonbytes literals (subversion.py, line 533) (error at
convcmd.py:*)
> -  hgext/convert/subversion.py: error importing: <SyntaxError> cannot mix
bytes and nonbytes literals (subversion.py, line 533) (error at
convcmd.py:*)
> -  hgext/convert/transport.py: error importing: <SyntaxError> cannot mix
bytes and nonbytes literals (subversion.py, line 533) (error at
convcmd.py:*)
> +  hgext/convert/transport.py: error importing: <ImportError> No module
named 'svn.client' (error at transport.py:*)
>    hgext/fsmonitor/pywatchman/capabilities.py: error importing:
<ImportError> No module named 'pybser' (error at __init__.py:*)
>    hgext/fsmonitor/pywatchman/pybser.py: error importing: <ImportError>
No module named 'pybser' (error at __init__.py:*)
>    hgext/fsmonitor/watchmanclient.py: error importing: <ImportError> No
module named 'pybser' (error at __init__.py:*)
> -  hgext/largefiles/basestore.py: error importing: <SyntaxError> cannot
mix bytes and nonbytes literals (subversion.py, line 533) (error at
convcmd.py:*)
> -  hgext/largefiles/lfcommands.py: error importing: <SyntaxError> cannot
mix bytes and nonbytes literals (subversion.py, line 533) (error at
convcmd.py:*)
> -  hgext/largefiles/lfutil.py: error importing: <SyntaxError> cannot mix
bytes and nonbytes literals (subversion.py, line 533) (error at
convcmd.py:*)
> -  hgext/largefiles/localstore.py: error importing: <SyntaxError> cannot
mix bytes and nonbytes literals (subversion.py, line 533) (error at
convcmd.py:*)
> -  hgext/largefiles/overrides.py: error importing: <SyntaxError> cannot
mix bytes and nonbytes literals (subversion.py, line 533) (error at
convcmd.py:*)
> -  hgext/largefiles/proto.py: error importing: <SyntaxError> cannot mix
bytes and nonbytes literals (subversion.py, line 533) (error at
convcmd.py:*)
> -  hgext/largefiles/remotestore.py: error importing: <SyntaxError> cannot
mix bytes and nonbytes literals (subversion.py, line 533) (error at
convcmd.py:*)
> -  hgext/largefiles/reposetup.py: error importing: <SyntaxError> cannot
mix bytes and nonbytes literals (subversion.py, line 533) (error at
convcmd.py:*)
> -  hgext/largefiles/storefactory.py: error importing: <SyntaxError>
cannot mix bytes and nonbytes literals (subversion.py, line 533) (error at
convcmd.py:*)
> -  hgext/largefiles/uisetup.py: error importing: <SyntaxError> cannot mix
bytes and nonbytes literals (subversion.py, line 533) (error at
convcmd.py:*)
> -  hgext/largefiles/wirestore.py: error importing: <SyntaxError> cannot
mix bytes and nonbytes literals (subversion.py, line 533) (error at
convcmd.py:*)
>    hgext/mq.py: error importing: <TypeError> __import__() argument 1 must
be str, not bytes (error at extensions.py:*)
>    mercurial/scmwindows.py: error importing: <ImportError> No module
named 'winreg' (error at scmwindows.py:*)
>    mercurial/win32.py: error importing: <ImportError> No module named
'msvcrt' (error at win32.py:*)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py
--- a/hgext/convert/subversion.py
+++ b/hgext/convert/subversion.py
@@ -531,8 +531,8 @@  class svn_source(converter_source):
     def checkrevformat(self, revstr, mapname='splicemap'):
         """ fails if revision format does not match the correct format"""
         if not re.match(r'svn:[0-9a-f]{8,8}-[0-9a-f]{4,4}-'
-                              '[0-9a-f]{4,4}-[0-9a-f]{4,4}-[0-9a-f]'
-                              '{12,12}(.*)\@[0-9]+$',revstr):
+                              r'[0-9a-f]{4,4}-[0-9a-f]{4,4}-[0-9a-f]'
+                              r'{12,12}(.*)\@[0-9]+$',revstr):
             raise error.Abort(_('%s entry %s is not a valid revision'
                                ' identifier') % (mapname, revstr))
 
diff --git a/tests/test-check-py3-compat.t b/tests/test-check-py3-compat.t
--- a/tests/test-check-py3-compat.t
+++ b/tests/test-check-py3-compat.t
@@ -16,24 +16,10 @@ 
   $ hg files 'set:(**.py) - grep(pygments)' | sed 's|\\|/|g' \
   > | xargs $PYTHON3 contrib/check-py3-compat.py \
   > | sed 's/[0-9][0-9]*)$/*)/'
-  hgext/convert/bzr.py: error importing: <SyntaxError> cannot mix bytes and nonbytes literals (subversion.py, line 533) (error at convcmd.py:*)
-  hgext/convert/convcmd.py: error importing: <SyntaxError> cannot mix bytes and nonbytes literals (subversion.py, line 533) (error at convcmd.py:*)
-  hgext/convert/subversion.py: error importing: <SyntaxError> cannot mix bytes and nonbytes literals (subversion.py, line 533) (error at convcmd.py:*)
-  hgext/convert/transport.py: error importing: <SyntaxError> cannot mix bytes and nonbytes literals (subversion.py, line 533) (error at convcmd.py:*)
+  hgext/convert/transport.py: error importing: <ImportError> No module named 'svn.client' (error at transport.py:*)
   hgext/fsmonitor/pywatchman/capabilities.py: error importing: <ImportError> No module named 'pybser' (error at __init__.py:*)
   hgext/fsmonitor/pywatchman/pybser.py: error importing: <ImportError> No module named 'pybser' (error at __init__.py:*)
   hgext/fsmonitor/watchmanclient.py: error importing: <ImportError> No module named 'pybser' (error at __init__.py:*)
-  hgext/largefiles/basestore.py: error importing: <SyntaxError> cannot mix bytes and nonbytes literals (subversion.py, line 533) (error at convcmd.py:*)
-  hgext/largefiles/lfcommands.py: error importing: <SyntaxError> cannot mix bytes and nonbytes literals (subversion.py, line 533) (error at convcmd.py:*)
-  hgext/largefiles/lfutil.py: error importing: <SyntaxError> cannot mix bytes and nonbytes literals (subversion.py, line 533) (error at convcmd.py:*)
-  hgext/largefiles/localstore.py: error importing: <SyntaxError> cannot mix bytes and nonbytes literals (subversion.py, line 533) (error at convcmd.py:*)
-  hgext/largefiles/overrides.py: error importing: <SyntaxError> cannot mix bytes and nonbytes literals (subversion.py, line 533) (error at convcmd.py:*)
-  hgext/largefiles/proto.py: error importing: <SyntaxError> cannot mix bytes and nonbytes literals (subversion.py, line 533) (error at convcmd.py:*)
-  hgext/largefiles/remotestore.py: error importing: <SyntaxError> cannot mix bytes and nonbytes literals (subversion.py, line 533) (error at convcmd.py:*)
-  hgext/largefiles/reposetup.py: error importing: <SyntaxError> cannot mix bytes and nonbytes literals (subversion.py, line 533) (error at convcmd.py:*)
-  hgext/largefiles/storefactory.py: error importing: <SyntaxError> cannot mix bytes and nonbytes literals (subversion.py, line 533) (error at convcmd.py:*)
-  hgext/largefiles/uisetup.py: error importing: <SyntaxError> cannot mix bytes and nonbytes literals (subversion.py, line 533) (error at convcmd.py:*)
-  hgext/largefiles/wirestore.py: error importing: <SyntaxError> cannot mix bytes and nonbytes literals (subversion.py, line 533) (error at convcmd.py:*)
   hgext/mq.py: error importing: <TypeError> __import__() argument 1 must be str, not bytes (error at extensions.py:*)
   mercurial/scmwindows.py: error importing: <ImportError> No module named 'winreg' (error at scmwindows.py:*)
   mercurial/win32.py: error importing: <ImportError> No module named 'msvcrt' (error at win32.py:*)