Read about our upcoming Code of Conduct on this issue

This instance will be upgraded to Heptapod 0.28.1 on 2022-01-26 at 16:00 UTC+1 (a few minutes of down time)

Commit ed815207 authored by Manuel Jacob's avatar Manuel Jacob
Browse files

archival: abort if compression method is unavailable

`tarfile.CompressionError` is documented to be the "exception for unavailable
compression methods".

Also, make tests conditional on whether the lzma module is available or not.

branch : stable
parent 40120de810ba
Pipeline #7896 passed with stage
in 37 minutes and 16 seconds
......@@ -189,7 +189,12 @@ class tarit(object):
name, pycompat.sysstr(mode), gzfileobj
return, pycompat.sysstr(mode + kind), fileobj)
name, pycompat.sysstr(mode + kind), fileobj
except tarfile.CompressionError as e:
raise error.Abort(pycompat.bytestr(e))
if isinstance(dest, bytes):
self.z = taropen(b'w:', name=dest)
......@@ -1074,3 +1074,14 @@ def has_rustfmt():
return matchoutput(
'`rustup which --toolchain nightly rustfmt` --version', b'rustfmt'
@check("lzma", "python lzma module")
def has_lzma():
import _lzma
return True
except ImportError:
return False
......@@ -576,12 +576,18 @@ old file -- date clamped to 1980
test xz support only available in Python 3.4
#if py3
#if lzma
$ hg archive ../archive.txz
$ which xz >/dev/null && xz -l ../archive.txz | head -n1 || true
Strms Blocks Compressed Uncompressed Ratio Check Filename (xz !)
$ rm -f ../archive.txz
#if py3 no-lzma
$ hg archive ../archive.txz
abort: lzma module is not available
#if no-py3
$ hg archive ../archive.txz
abort: xz compression is only available in Python 3
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment