Mercurial > hg
comparison mercurial/archival.py @ 44473:6c36a521572e stable
gzip: rename the argument to `mtime` to match upstream python
Python gained the feature we missed in 3.1. The argument name is `mtime`. We
align our version for consistency.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 10 Mar 2020 18:57:49 +0100 |
parents | 9f70512ae2cf |
children | a23b859ad17d |
comparison
equal
deleted
inserted
replaced
44472:b7760c2d33de | 44473:6c36a521572e |
---|---|
136 or compress with gzip or bzip2.''' | 136 or compress with gzip or bzip2.''' |
137 | 137 |
138 class GzipFileWithTime(gzip.GzipFile): | 138 class GzipFileWithTime(gzip.GzipFile): |
139 def __init__(self, *args, **kw): | 139 def __init__(self, *args, **kw): |
140 timestamp = None | 140 timestamp = None |
141 if 'timestamp' in kw: | 141 if 'mtime' in kw: |
142 timestamp = kw.pop('timestamp') | 142 timestamp = kw.pop('mtime') |
143 if timestamp is None: | 143 if timestamp is None: |
144 self.timestamp = time.time() | 144 self.timestamp = time.time() |
145 else: | 145 else: |
146 self.timestamp = timestamp | 146 self.timestamp = timestamp |
147 gzip.GzipFile.__init__(self, *args, **kw) | 147 gzip.GzipFile.__init__(self, *args, **kw) |
176 gzfileobj = self.GzipFileWithTime( | 176 gzfileobj = self.GzipFileWithTime( |
177 name, | 177 name, |
178 pycompat.sysstr(mode + b'b'), | 178 pycompat.sysstr(mode + b'b'), |
179 zlib.Z_BEST_COMPRESSION, | 179 zlib.Z_BEST_COMPRESSION, |
180 fileobj, | 180 fileobj, |
181 timestamp=mtime, | 181 mtime=mtime, |
182 ) | 182 ) |
183 self.fileobj = gzfileobj | 183 self.fileobj = gzfileobj |
184 return tarfile.TarFile.taropen( # pytype: disable=attribute-error | 184 return tarfile.TarFile.taropen( # pytype: disable=attribute-error |
185 name, pycompat.sysstr(mode), gzfileobj | 185 name, pycompat.sysstr(mode), gzfileobj |
186 ) | 186 ) |