From 96f88a29d25ef3d690ea24f3e1ced8299f12c365 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 14 Jan 2016 18:57:05 +0100 Subject: [PATCH] add --list option for borg create like --stats enables statistics output, --list enables the file/dirs list output. --- borg/archiver.py | 6 +++++- borg/testsuite/archiver.py | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/borg/archiver.py b/borg/archiver.py index 3c09840cd..7ba11a039 100644 --- a/borg/archiver.py +++ b/borg/archiver.py @@ -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', diff --git a/borg/testsuite/archiver.py b/borg/testsuite/archiver.py index 58d20c528..d264224ae 100644 --- a/borg/testsuite/archiver.py +++ b/borg/testsuite/archiver.py @@ -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):