1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-26 17:57:59 +00:00

remove deprecated "--compression <number>"

use --compression zlib,<number> instead
in case of 0, you could also use --compression none
This commit is contained in:
Thomas Waldmann 2016-01-16 00:12:11 +01:00
parent ad31fcd7c0
commit 3476fffe7d
2 changed files with 14 additions and 33 deletions

View file

@ -466,35 +466,21 @@ def CompressionSpec(s):
count = len(values) count = len(values)
if count < 1: if count < 1:
raise ValueError raise ValueError
compression = values[0] # --compression algo[,level]
try: name = values[0]
compression = int(compression) if name in ('none', 'lz4', ):
if count > 1: return dict(name=name)
raise ValueError if name in ('zlib', 'lzma', ):
# DEPRECATED: it is just --compression N if count < 2:
if 0 <= compression <= 9: level = 6 # default compression level in py stdlib
print('Warning: --compression %d is deprecated, please use --compression zlib,%d.' % (compression, compression)) elif count == 2:
if compression == 0: level = int(values[1])
print('Hint: instead of --compression zlib,0 you could also use --compression none for better performance.') if not 0 <= level <= 9:
print('Hint: archives generated using --compression none are not compatible with borg < 0.25.0.')
return dict(name='zlib', level=compression)
raise ValueError
except ValueError:
# --compression algo[,...]
name = compression
if name in ('none', 'lz4', ):
return dict(name=name)
if name in ('zlib', 'lzma', ):
if count < 2:
level = 6 # default compression level in py stdlib
elif count == 2:
level = int(values[1])
if not 0 <= level <= 9:
raise ValueError
else:
raise ValueError raise ValueError
return dict(name=name, level=level) else:
raise ValueError raise ValueError
return dict(name=name, level=level)
raise ValueError
def dir_is_cachedir(path): def dir_is_cachedir(path):

View file

@ -458,11 +458,6 @@ def test_pattern_matcher():
def test_compression_specs(): def test_compression_specs():
with pytest.raises(ValueError): with pytest.raises(ValueError):
CompressionSpec('') CompressionSpec('')
assert CompressionSpec('0') == dict(name='zlib', level=0)
assert CompressionSpec('1') == dict(name='zlib', level=1)
assert CompressionSpec('9') == dict(name='zlib', level=9)
with pytest.raises(ValueError):
CompressionSpec('10')
assert CompressionSpec('none') == dict(name='none') assert CompressionSpec('none') == dict(name='none')
assert CompressionSpec('lz4') == dict(name='lz4') assert CompressionSpec('lz4') == dict(name='lz4')
assert CompressionSpec('zlib') == dict(name='zlib', level=6) assert CompressionSpec('zlib') == dict(name='zlib', level=6)