add --list option for borg create

like --stats enables statistics output, --list enables the file/dirs list output.
This commit is contained in:
Thomas Waldmann 2016-01-14 18:57:05 +01:00
parent fa054d0f2e
commit 96f88a29d2
2 changed files with 9 additions and 5 deletions

View File

@ -80,7 +80,7 @@ class Archiver:
logger.warning(msg)
def print_file_status(self, status, path):
if self.output_filter is None or status in self.output_filter:
if self.output_list and (self.output_filter is None or status in self.output_filter):
logger.info("%1s %s", status, remove_surrogates(path))
def do_serve(self, args):
@ -129,6 +129,7 @@ class Archiver:
def do_create(self, args):
"""Create new archive"""
self.output_filter = args.output_filter
self.output_list = args.output_list
dry_run = args.dry_run
t0 = datetime.now()
if not dry_run:
@ -858,6 +859,9 @@ class Archiver:
help="""show progress display while creating the archive, showing Original,
Compressed and Deduplicated sizes, followed by the Number of files seen
and the path being processed, default: %(default)s""")
subparser.add_argument('--list', dest='output_list',
action='store_true', default=False,
help='output verbose list of items (files, dirs, ...)')
subparser.add_argument('--filter', dest='output_filter', metavar='STATUSCHARS',
help='only display items with the given status characters')
subparser.add_argument('-e', '--exclude', dest='excludes',

View File

@ -762,11 +762,11 @@ class ArchiverTestCase(ArchiverTestCaseBase):
os.utime('input/file1', (now - 5, now - 5)) # 5 seconds ago
self.create_regular_file('file2', size=1024 * 80)
self.cmd('init', self.repository_location)
output = self.cmd('create', '-v', self.repository_location + '::test', 'input')
output = self.cmd('create', '-v', '--list', self.repository_location + '::test', 'input')
self.assert_in("A input/file1", output)
self.assert_in("A input/file2", output)
# should find first file as unmodified
output = self.cmd('create', '-v', self.repository_location + '::test1', 'input')
output = self.cmd('create', '-v', '--list', self.repository_location + '::test1', 'input')
self.assert_in("U input/file1", output)
# this is expected, although surprising, for why, see:
# http://borgbackup.readthedocs.org/en/latest/faq.html#i-am-seeing-a-added-status-for-a-unchanged-file
@ -785,7 +785,7 @@ class ArchiverTestCase(ArchiverTestCaseBase):
output = self.cmd('create', self.repository_location + '::test0', 'input')
self.assert_not_in('file1', output)
# should list the file as unchanged
output = self.cmd('create', '-v', '--filter=U', self.repository_location + '::test1', 'input')
output = self.cmd('create', '-v', '--list', '--filter=U', self.repository_location + '::test1', 'input')
self.assert_in('file1', output)
# should *not* list the file as changed
output = self.cmd('create', '-v', '--filter=AM', self.repository_location + '::test2', 'input')
@ -793,7 +793,7 @@ class ArchiverTestCase(ArchiverTestCaseBase):
# change the file
self.create_regular_file('file1', size=1024 * 100)
# should list the file as changed
output = self.cmd('create', '-v', '--filter=AM', self.repository_location + '::test3', 'input')
output = self.cmd('create', '-v', '--list', '--filter=AM', self.repository_location + '::test3', 'input')
self.assert_in('file1', output)
def test_cmdline_compatibility(self):