do not display unchanged files by default

add a --unchanged topical file to display those files
This commit is contained in:
Antoine Beaupré 2015-11-23 19:54:30 -05:00
parent fce5aed5bb
commit 1785ca54ba
2 changed files with 15 additions and 6 deletions

View File

@ -74,6 +74,10 @@ class Archiver:
logger.warning(msg) logger.warning(msg)
def print_file_status(self, status, path): def print_file_status(self, status, path):
if status == 'U':
if self.unchanged:
print("%1s %s" % (status, remove_surrogates(path)), file=sys.stderr)
else:
if self.changed: if self.changed:
print("%1s %s" % (status, remove_surrogates(path)), file=sys.stderr) print("%1s %s" % (status, remove_surrogates(path)), file=sys.stderr)
@ -804,6 +808,8 @@ class Archiver:
and the path being processed, default: %(default)s""") and the path being processed, default: %(default)s""")
subparser.add_argument('--changed', action='store_true', dest='changed', default=False, subparser.add_argument('--changed', action='store_true', dest='changed', default=False,
help="""display which files were added to the archive""") 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', subparser.add_argument('-e', '--exclude', dest='excludes',
type=ExcludePattern, action='append', type=ExcludePattern, action='append',
metavar="PATTERN", help='exclude paths matching PATTERN') metavar="PATTERN", help='exclude paths matching PATTERN')

View File

@ -724,7 +724,10 @@ class ArchiverTestCase(ArchiverTestCaseBase):
self.assert_in("A input/file2", output) self.assert_in("A input/file2", output)
def test_create_topical(self): def test_create_topical(self):
now = time.time()
self.create_regular_file('file1', size=1024 * 80) 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) self.cmd('init', self.repository_location)
# no listing by default # no listing by default
output = self.cmd('create', self.repository_location + '::test', 'input') 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') 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', '--unchanged', self.repository_location + '::test1', 'input') output = self.cmd('create', '--unchanged', 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', '--changed', self.repository_location + '::test2', 'input') output = self.cmd('create', '--changed', self.repository_location + '::test2', 'input')
#self.assert_not_in('file1', output) self.assert_not_in('file1', output)
# 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