Răsfoiți Sursa

Merge pull request #553 from ThomasWaldmann/list-option

add --list option for borg create
TW 9 ani în urmă
părinte
comite
34142adcb0
2 a modificat fișierele cu 9 adăugiri și 5 ștergeri
  1. 5 1
      borg/archiver.py
  2. 4 4
      borg/testsuite/archiver.py

+ 5 - 1
borg/archiver.py

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

+ 4 - 4
borg/testsuite/archiver.py

@@ -762,11 +762,11 @@ class ArchiverTestCase(ArchiverTestCaseBase):
         os.utime('input/file1', (now - 5, now - 5)) # 5 seconds ago
         os.utime('input/file1', (now - 5, now - 5)) # 5 seconds ago
         self.create_regular_file('file2', size=1024 * 80)
         self.create_regular_file('file2', size=1024 * 80)
         self.cmd('init', self.repository_location)
         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/file1", output)
         self.assert_in("A input/file2", output)
         self.assert_in("A input/file2", output)
         # should find first file as unmodified
         # 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)
         self.assert_in("U input/file1", output)
         # this is expected, although surprising, for why, see:
         # 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
         # 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')
         output = self.cmd('create', self.repository_location + '::test0', 'input')
         self.assert_not_in('file1', output)
         self.assert_not_in('file1', output)
         # should list the file as unchanged
         # 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)
         self.assert_in('file1', output)
         # should *not* list the file as changed
         # should *not* list the file as changed
         output = self.cmd('create', '-v', '--filter=AM', self.repository_location + '::test2', 'input')
         output = self.cmd('create', '-v', '--filter=AM', self.repository_location + '::test2', 'input')
@@ -793,7 +793,7 @@ class ArchiverTestCase(ArchiverTestCaseBase):
         # change the file
         # change the file
         self.create_regular_file('file1', size=1024 * 100)
         self.create_regular_file('file1', size=1024 * 100)
         # should list the file as changed
         # 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)
         self.assert_in('file1', output)
 
 
     def test_cmdline_compatibility(self):
     def test_cmdline_compatibility(self):