Mercurial > public > mercurial-scm > hg
diff mercurial/archival.py @ 45048:2c0043977b6d stable
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.
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Wed, 08 Jul 2020 08:57:21 +0200 |
parents | f8427841c8fc |
children | 3a6ec080b521 |
line wrap: on
line diff
--- a/mercurial/archival.py Wed Jul 08 08:25:30 2020 +0200 +++ b/mercurial/archival.py Wed Jul 08 08:57:21 2020 +0200 @@ -189,7 +189,12 @@ name, pycompat.sysstr(mode), gzfileobj ) else: - return tarfile.open(name, pycompat.sysstr(mode + kind), fileobj) + try: + return tarfile.open( + 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)