Patchwork [2,of,3,STABLE] gzip: indent the custom Gzip code

login
register
mail settings
Submitter Pierre-Yves David
Date March 10, 2020, 6:23 p.m.
Message ID <d50ce19a49dac6ac8710.1583864638@nodosa.octobus.net>
Download mbox | patch
Permalink /patch/45675/
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 1583862799 -3600
#      Tue Mar 10 18:53:19 2020 +0100
# Branch stable
# Node ID d50ce19a49dac6ac8710291d903a93188dd97f1d
# Parent  f0f5e4dbc875fb4a7201987deba6c1eb2cbdbdee
# EXP-Topic fix-3.8
# Available At https://dev.heptapod.net/octobus/mercurial-devel/
#              hg pull https://dev.heptapod.net/octobus/mercurial-devel/ -r d50ce19a49da
gzip: indent the custom Gzip code

We need a new conditional in the next changesets (Adding 3.8 support). We do the
large code move beforehand for clarity.

Patch

diff --git a/mercurial/archival.py b/mercurial/archival.py
--- a/mercurial/archival.py
+++ b/mercurial/archival.py
@@ -135,34 +135,36 @@  class tarit(object):
     '''write archive to tar file or stream.  can write uncompressed,
     or compress with gzip or bzip2.'''
 
-    class GzipFileWithTime(gzip.GzipFile):
-        def __init__(self, *args, **kw):
-            timestamp = None
-            if 'mtime' in kw:
-                timestamp = kw.pop('mtime')
-            if timestamp is None:
-                self.timestamp = time.time()
-            else:
-                self.timestamp = timestamp
-            gzip.GzipFile.__init__(self, *args, **kw)
+    if True:
+
+        class GzipFileWithTime(gzip.GzipFile):
+            def __init__(self, *args, **kw):
+                timestamp = None
+                if 'mtime' in kw:
+                    timestamp = kw.pop('mtime')
+                if timestamp is None:
+                    self.timestamp = time.time()
+                else:
+                    self.timestamp = timestamp
+                gzip.GzipFile.__init__(self, *args, **kw)
 
-        def _write_gzip_header(self):
-            self.fileobj.write(b'\037\213')  # magic header
-            self.fileobj.write(b'\010')  # compression method
-            fname = self.name
-            if fname and fname.endswith(b'.gz'):
-                fname = fname[:-3]
-            flags = 0
-            if fname:
-                flags = gzip.FNAME  # pytype: disable=module-attr
-            self.fileobj.write(pycompat.bytechr(flags))
-            gzip.write32u(  # pytype: disable=module-attr
-                self.fileobj, int(self.timestamp)
-            )
-            self.fileobj.write(b'\002')
-            self.fileobj.write(b'\377')
-            if fname:
-                self.fileobj.write(fname + b'\000')
+            def _write_gzip_header(self):
+                self.fileobj.write(b'\037\213')  # magic header
+                self.fileobj.write(b'\010')  # compression method
+                fname = self.name
+                if fname and fname.endswith(b'.gz'):
+                    fname = fname[:-3]
+                flags = 0
+                if fname:
+                    flags = gzip.FNAME  # pytype: disable=module-attr
+                self.fileobj.write(pycompat.bytechr(flags))
+                gzip.write32u(  # pytype: disable=module-attr
+                    self.fileobj, int(self.timestamp)
+                )
+                self.fileobj.write(b'\002')
+                self.fileobj.write(b'\377')
+                if fname:
+                    self.fileobj.write(fname + b'\000')
 
     def __init__(self, dest, mtime, kind=b''):
         self.mtime = mtime