If we just want to get a list of files, there's no point in
reading metadata, since it simply isn't needed. Pass want_meta
to the appropriate functions only when we need the metadata,
and similarly call vfs.augment_item_meta() only then.
Note that the previous vfs change really made this effective,
we'd otherwise lose the information.
Note also that unfortunately this is necessary even for the
--file-type command line option because otherwise we cannot
identify FIFOs; for everything else the git mode appears to
be sufficient.
Together, this reduces the number of blob reads from 62 to 8
for 'bup ls' on a trivial folder (the bup git's root folder).
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
human_readable=opt.human_readable)
ret = 0
human_readable=opt.human_readable)
ret = 0
+ want_meta = bool(opt.long_listing or opt.classification)
pending = []
last_n = len(opt.paths) - 1
for n, printpath in enumerate(opt.paths):
pending = []
last_n = len(opt.paths) - 1
for n, printpath in enumerate(opt.paths):
if opt.directory:
resolved = vfs.resolve(repo, path, follow=False)
else:
if opt.directory:
resolved = vfs.resolve(repo, path, follow=False)
else:
- resolved = vfs.try_resolve(repo, path)
+ resolved = vfs.try_resolve(repo, path, want_meta=want_meta)
leaf_name, leaf_item = resolved[-1]
if not leaf_item:
leaf_name, leaf_item = resolved[-1]
if not leaf_item:
ret = 1
continue
if not opt.directory and S_ISDIR(vfs.item_mode(leaf_item)):
ret = 1
continue
if not opt.directory and S_ISDIR(vfs.item_mode(leaf_item)):
- items = vfs.contents(repo, leaf_item)
+ items = vfs.contents(repo, leaf_item, want_meta=want_meta)
if opt.show_hidden == 'all':
# Match non-bup "ls -a ... /".
parent = resolved[-2] if len(resolved) > 1 else resolved[0]
if opt.show_hidden == 'all':
# Match non-bup "ls -a ... /".
parent = resolved[-2] if len(resolved) > 1 else resolved[0]
if opt.l:
sub_item = vfs.ensure_item_has_metadata(repo, sub_item,
include_size=True)
if opt.l:
sub_item = vfs.ensure_item_has_metadata(repo, sub_item,
include_size=True)
sub_item = vfs.augment_item_meta(repo, sub_item,
include_size=True)
line = item_line(sub_item, sub_name)
sub_item = vfs.augment_item_meta(repo, sub_item,
include_size=True)
line = item_line(sub_item, sub_name)
out.write(line)
out.write(b'\n')
else:
out.write(line)
out.write(b'\n')
else:
- leaf_item = vfs.augment_item_meta(repo, leaf_item,
- include_size=True)
+ if opt.long_listing:
+ leaf_item = vfs.augment_item_meta(repo, leaf_item,
+ include_size=True)
line = item_line(leaf_item, os.path.normpath(path))
if not opt.long_listing and istty1:
pending.append(line)
line = item_line(leaf_item, os.path.normpath(path))
if not opt.long_listing and istty1:
pending.append(line)