From 1785ca54ba82ba851905478446d9bf00a3f9f597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= Date: Mon, 23 Nov 2015 19:54:30 -0500 Subject: [PATCH] do not display unchanged files by default add a --unchanged topical file to display those files --- borg/archiver.py | 10 ++++++++-- borg/testsuite/archiver.py | 11 +++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/borg/archiver.py b/borg/archiver.py index 1c396a920..eefe81369 100644 --- a/borg/archiver.py +++ b/borg/archiver.py @@ -74,8 +74,12 @@ class Archiver: logger.warning(msg) def print_file_status(self, status, path): - if self.changed: - print("%1s %s" % (status, remove_surrogates(path)), file=sys.stderr) + if status == 'U': + if self.unchanged: + print("%1s %s" % (status, remove_surrogates(path)), file=sys.stderr) + else: + if self.changed: + print("%1s %s" % (status, remove_surrogates(path)), file=sys.stderr) def do_serve(self, args): """Start in server mode. This command is usually not used manually. @@ -804,6 +808,8 @@ class Archiver: 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('--unchanged', action='store_true', dest='unchanged', default=False, + help="""display which files were *not* added to the archive""") subparser.add_argument('-e', '--exclude', dest='excludes', type=ExcludePattern, action='append', metavar="PATTERN", help='exclude paths matching PATTERN') diff --git a/borg/testsuite/archiver.py b/borg/testsuite/archiver.py index c458f97f5..fcabb35d8 100644 --- a/borg/testsuite/archiver.py +++ b/borg/testsuite/archiver.py @@ -724,7 +724,10 @@ class ArchiverTestCase(ArchiverTestCaseBase): self.assert_in("A input/file2", output) def test_create_topical(self): + now = time.time() self.create_regular_file('file1', size=1024 * 80) + os.utime('input/file1', (now-5, now-5)) + self.create_regular_file('file2', size=1024 * 80) self.cmd('init', self.repository_location) # no listing by default output = self.cmd('create', self.repository_location + '::test', 'input') @@ -733,11 +736,11 @@ 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', '--unchanged', self.repository_location + '::test1', 'input') - #self.assert_in('file1', output) + 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) + 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