# HG changeset patch # User David Demelier # Date 2019-09-17 10:47:31 # Node ID c04e0836f039ed629d2f86f9011c853049a1546b # Parent 06080afd05650a9d614d6b69a22dd1cd627ecd92 archive: add XZ support if built with Python 3 diff --git a/mercurial/archival.py b/mercurial/archival.py --- a/mercurial/archival.py +++ b/mercurial/archival.py @@ -67,6 +67,7 @@ exts = { 'tbz2': ['.tbz2', '.tar.bz2'], 'tgz': ['.tgz', '.tar.gz'], 'zip': ['.zip'], + 'txz': ['.txz', '.tar.xz'] } def guesskind(dest): @@ -270,6 +271,7 @@ archivers = { 'tar': tarit, 'tbz2': lambda name, mtime: tarit(name, mtime, 'bz2'), 'tgz': lambda name, mtime: tarit(name, mtime, 'gz'), + 'txz': lambda name, mtime: tarit(name, mtime, 'xz'), 'uzip': lambda name, mtime: zipit(name, mtime, False), 'zip': zipit, } @@ -295,6 +297,9 @@ def archive(repo, dest, node, kind, deco subrepos tells whether to include subrepos. ''' + if kind == 'txz' and not pycompat.ispy3: + raise error.Abort(_('xz compression is only available in Python 3')) + if kind == 'files': if prefix: raise error.Abort(_('cannot give prefix when archiving to files')) diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -514,6 +514,7 @@ def archive(ui, repo, dest, **opts): :``tar``: tar archive, uncompressed :``tbz2``: tar archive, compressed using bzip2 :``tgz``: tar archive, compressed using gzip + :``txz``: tar archive, compressed using lzma (only in Python 3) :``uzip``: zip archive, uncompressed :``zip``: zip archive, compressed using deflate diff --git a/tests/test-archive.t b/tests/test-archive.t --- a/tests/test-archive.t +++ b/tests/test-archive.t @@ -566,6 +566,19 @@ old file -- date clamped to 1980 *172*80*00:00*old/.hg_archival.txt (glob) *0*80*00:00*old/old (glob) +test xz support only available in Python 3.4 + +#if py3 + $ hg archive ../archive.txz + $ xz -l ../archive.txz | head -n1 + Strms Blocks Compressed Uncompressed Ratio Check Filename + $ rm -f ../archive.txz +#else + $ hg archive ../archive.txz + abort: xz compression is only available in Python 3 + [255] +#endif + show an error when a provided pattern matches no files $ hg archive -I file_that_does_not_exist.foo ../empty.zip