From 9899eaf241b1e6351733bf1d2db68046edec5994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= Date: Mon, 23 Nov 2015 12:10:21 -0500 Subject: [PATCH] silence file listing unless --changed is present --- borg/archiver.py | 6 +++++- borg/testsuite/archiver.py | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/borg/archiver.py b/borg/archiver.py index e7c9cb572..15c6caf85 100644 --- a/borg/archiver.py +++ b/borg/archiver.py @@ -74,7 +74,8 @@ class Archiver: logger.warning(msg) def print_file_status(self, status, path): - logger.info("1s %s", status, remove_surrogates(path)) + if self.args.changed: + logger.info("%1s %s" % (status, remove_surrogates(path))) def do_serve(self, args): """Start in server mode. This command is usually not used manually. @@ -801,6 +802,8 @@ class Archiver: help="""toggle 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('--changed', action='store_true', dest='changed', default=False, + help="""display which files were added to the archive""") subparser.add_argument('-e', '--exclude', dest='excludes', type=ExcludePattern, action='append', metavar="PATTERN", help='exclude paths matching PATTERN') @@ -1171,6 +1174,7 @@ class Archiver: args = self.preprocess_args(args) parser = self.build_parser(args) args = parser.parse_args(args or ['-h']) + self.args = args update_excludes(args) return args diff --git a/borg/testsuite/archiver.py b/borg/testsuite/archiver.py index 9d78988c6..a066f6ec1 100644 --- a/borg/testsuite/archiver.py +++ b/borg/testsuite/archiver.py @@ -723,6 +723,27 @@ class ArchiverTestCase(ArchiverTestCaseBase): # http://borgbackup.readthedocs.org/en/latest/faq.html#i-am-seeing-a-added-status-for-a-unchanged-file self.assert_in("A input/file2", output) + def test_create_topical(self): + self.create_regular_file('file1', size=1024 * 80) + self.cmd('init', self.repository_location) + # no listing by default + output = self.cmd('create', self.repository_location + '::test', 'input') + self.assert_not_in('file1', output) + # shouldn't be listed even if unchanged + 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', '--unchanged', self.repository_location + '::test1', 'input') + #self.assert_in('file1', output) + # should *not* list the file as changed + #output = self.cmd('create', '--changed', self.repository_location + '::test2', 'input') + #self.assert_not_in('file1', output) + # change the file + self.create_regular_file('file1', size=1024 * 100) + # should list the file as changed + output = self.cmd('create', '--changed', self.repository_location + '::test3', 'input') + self.assert_in('file1', output) + def test_cmdline_compatibility(self): self.create_regular_file('file1', size=1024 * 80) self.cmd('init', self.repository_location)