From: Rob Browning Date: Sat, 9 Dec 2017 00:23:53 +0000 (-0600) Subject: ls: retrieve all of the available metadata when requested X-Git-Tag: 0.30~142 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=17a0521d1cf250f9aa9a06aea7a1bdc55d253519;ds=sidebyside ls: retrieve all of the available metadata when requested When a detailed listing is requested, use ensure_item_has_metadata() to provide all of the available metadata for each item (e.g. directories). Signed-off-by: Rob Browning Tested-by: Rob Browning --- diff --git a/lib/bup/ls.py b/lib/bup/ls.py index 6149ab5..b59f43f 100644 --- a/lib/bup/ls.py +++ b/lib/bup/ls.py @@ -45,7 +45,7 @@ def item_info(item, name, else: result += name if classification: - result += xstat.classification_str(item.meta.mode, + result += xstat.classification_str(vfs.item_mode(item), classification == 'all') return result @@ -129,16 +129,18 @@ def do_ls(args, default='.', onabort=None, spec_prefix=''): # Match non-bup "ls -a ... /". parent = resolved[-2] if len(resolved) > 1 else resolved[0] items = chain(items, (('..', parent[1]),)) - - items = ((x[0], vfs.augment_item_meta(repo, x[1], - include_size=True)) - for x in items) for sub_name, sub_item in sorted(items, key=lambda x: x[0]): if show_hidden != 'all' and sub_name == '.': continue if sub_name.startswith('.') and \ show_hidden not in ('almost', 'all'): continue + if opt.l: + sub_item = vfs.ensure_item_has_metadata(repo, sub_item, + include_size=True) + else: + sub_item = vfs.augment_item_meta(repo, sub_item, + include_size=True) line = item_line(sub_item, sub_name) pending.append(line) if not opt.l and istty1 else print(line) else: diff --git a/t/test-ls.sh b/t/test-ls.sh index 1f668b5..ef71c19 100755 --- a/t/test-ls.sh +++ b/t/test-ls.sh @@ -33,6 +33,11 @@ WVPASS bup index src WVPASS bup save -n src -d 242312160 --strip src WVPASS bup tag some-tag src +uid="$(WVPASS id -u)" || exit $? +gid="$(WVPASS bup-python -c 'import os; print os.stat("src").st_gid')" || exit $? +user="$(WVPASS id -un)" || exit $? +group="$(WVPASS bup-python -c 'import grp, os; +print grp.getgrgid(os.stat("src").st_gid)[0]')" || exit $? src_commit_hash=$(git log --format=%H -n1 src) src_tree_hash=$(git log --format=%T -n1 src) @@ -110,27 +115,27 @@ WVPASSEQ "$(WVPASS bup ls -d src/latest)" "src/latest" WVSTART "ls (long)" WVPASSEQ "$(WVPASS bup ls -l / | tr -s ' ' ' ')" \ -"drwxr-xr-x 0/0 0 1970-01-01 00:00 src" +"drwx------ $user/$group 0 2009-10-03 23:48 src" WVPASSEQ "$(WVPASS bup ls -lA / | tr -s ' ' ' ')" \ "drwxr-xr-x 0/0 0 1970-01-01 00:00 .tag -drwxr-xr-x 0/0 0 1970-01-01 00:00 src" +drwx------ $user/$group 0 2009-10-03 23:48 src" WVPASSEQ "$(WVPASS bup ls -lAF / | tr -s ' ' ' ')" \ "drwxr-xr-x 0/0 0 1970-01-01 00:00 .tag/ -drwxr-xr-x 0/0 0 1970-01-01 00:00 src/" +drwx------ $user/$group 0 2009-10-03 23:48 src/" WVPASSEQ "$(WVPASS bup ls -la / | tr -s ' ' ' ')" \ "drwxr-xr-x 0/0 0 1970-01-01 00:00 . drwxr-xr-x 0/0 0 1970-01-01 00:00 .. drwxr-xr-x 0/0 0 1970-01-01 00:00 .tag -drwxr-xr-x 0/0 0 1970-01-01 00:00 src" +drwx------ $user/$group 0 2009-10-03 23:48 src" WVPASSEQ "$(WVPASS bup ls -laF / | tr -s ' ' ' ')" \ "drwxr-xr-x 0/0 0 1970-01-01 00:00 ./ drwxr-xr-x 0/0 0 1970-01-01 00:00 ../ drwxr-xr-x 0/0 0 1970-01-01 00:00 .tag/ -drwxr-xr-x 0/0 0 1970-01-01 00:00 src/" +drwx------ $user/$group 0 2009-10-03 23:48 src/" socket_mode="$(WVPASS ls -l src/socket | cut -b -10)" || exit $? @@ -176,13 +181,6 @@ else || exit $? fi - -uid="$(WVPASS id -u)" || exit $? -gid="$(WVPASS bup-python -c 'import os; print os.stat("src").st_gid')" || exit $? -user="$(WVPASS id -un)" || exit $? -group="$(WVPASS bup-python -c 'import grp, os; -print grp.getgrgid(os.stat("src").st_gid)[0]')" || exit $? - WVPASSEQ "$(bup ls -l src/latest | tr -s ' ' ' ')" \ "$bad_symlink_mode $user/$group $bad_symlink_size $bad_symlink_date bad-symlink -> not-there -rwx------ $user/$group 0 2009-10-03 23:48 executable @@ -193,7 +191,7 @@ $symlink_mode $user/$group $symlink_size $symlink_date symlink -> file" WVPASSEQ "$(bup ls -la src/latest | tr -s ' ' ' ')" \ "drwx------ $user/$group 0 2009-10-03 23:48 . -drwxr-xr-x 0/0 0 1970-01-01 00:00 .. +drwx------ $user/$group 0 2009-10-03 23:48 .. -rw------- $user/$group 0 2009-10-03 23:48 .dotfile $bad_symlink_mode $user/$group $bad_symlink_size $bad_symlink_date bad-symlink -> not-there -rwx------ $user/$group 0 2009-10-03 23:48 executable @@ -241,8 +239,8 @@ WVPASSEQ "$(bup ls -ld "src/latest" | tr -s ' ' ' ')" \ WVSTART "ls (backup set - long)" WVPASSEQ "$(bup ls -l --numeric-ids src | cut -d' ' -f 1-2)" \ -"drwxr-xr-x 0/0 -drwxr-xr-x 0/0" +"drwx------ $uid/$gid +drwx------ $uid/$gid" WVPASSEQ "$(bup ls -ds "src/latest" | tr -s ' ' ' ')" \ "$src_tree_hash src/latest"