Patchwork [3,of,3,STABLE] gzip: use the stdlib version with python 3 (issue6284)

login
register
mail settings
Submitter Pierre-Yves David
Date March 10, 2020, 6:23 p.m.
Message ID <48b865a401be25e65387.1583864639@nodosa.octobus.net>
Download mbox | patch
Permalink /patch/45673/
State New
Headers show

Comments

Pierre-Yves David - March 10, 2020, 6:23 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1583862884 -3600
#      Tue Mar 10 18:54:44 2020 +0100
# Branch stable
# Node ID 48b865a401be25e653870f652776b6836b6fed60
# Parent  d50ce19a49dac6ac8710291d903a93188dd97f1d
# EXP-Topic fix-3.8
# Available At https://dev.heptapod.net/octobus/mercurial-devel/
#              hg pull https://dev.heptapod.net/octobus/mercurial-devel/ -r 48b865a401be
gzip: use the stdlib version with python 3 (issue6284)

It turned out that the stdlib gained the feature we missed in python 3.1. We can
now use it directly.
Pierre-Yves David - March 10, 2020, 6:31 p.m.
Here is the associated CI run

https://foss.heptapod.net/octobus/mercurial-devel/pipelines/3957

(the CI is python 2.7 and 3.7. I did local test with 3.8)

tests/test-subrepo-deep-nested-change.t was broken before this patch and 
worked afterward.

On 3/10/20 7:23 PM, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1583862884 -3600
> #      Tue Mar 10 18:54:44 2020 +0100
> # Branch stable
> # Node ID 48b865a401be25e653870f652776b6836b6fed60
> # Parent  d50ce19a49dac6ac8710291d903a93188dd97f1d
> # EXP-Topic fix-3.8
> # Available At https://dev.heptapod.net/octobus/mercurial-devel/
> #              hg pull https://dev.heptapod.net/octobus/mercurial-devel/ -r 48b865a401be
> gzip: use the stdlib version with python 3 (issue6284)
> 
> It turned out that the stdlib gained the feature we missed in python 3.1. We can
> now use it directly.
> 
> diff --git a/mercurial/archival.py b/mercurial/archival.py
> --- a/mercurial/archival.py
> +++ b/mercurial/archival.py
> @@ -135,7 +135,9 @@ class tarit(object):
>       '''write archive to tar file or stream.  can write uncompressed,
>       or compress with gzip or bzip2.'''
>   
> -    if True:
> +    if pycompat.ispy3:
> +        GzipFileWithTime = gzip.GzipFile  # camelcase-required
> +    else:
>   
>           class GzipFileWithTime(gzip.GzipFile):
>               def __init__(self, *args, **kw):
>

Patch

diff --git a/mercurial/archival.py b/mercurial/archival.py
--- a/mercurial/archival.py
+++ b/mercurial/archival.py
@@ -135,7 +135,9 @@  class tarit(object):
     '''write archive to tar file or stream.  can write uncompressed,
     or compress with gzip or bzip2.'''
 
-    if True:
+    if pycompat.ispy3:
+        GzipFileWithTime = gzip.GzipFile  # camelcase-required
+    else:
 
         class GzipFileWithTime(gzip.GzipFile):
             def __init__(self, *args, **kw):