Răsfoiți Sursa

do not display unchanged files by default

add a --unchanged topical file to display those files
Antoine Beaupré 9 ani în urmă
părinte
comite
1785ca54ba
2 a modificat fișierele cu 15 adăugiri și 6 ștergeri
  1. 8 2
      borg/archiver.py
  2. 7 4
      borg/testsuite/archiver.py

+ 8 - 2
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')

+ 7 - 4
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