]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/ls.py
main: remove vestigial debug statement
[bup.git] / lib / bup / ls.py
index 970995dfd7e2a5cedc961ba8e1796a9dc498470e..4bd673022cc8379cd07e2049aaafcfc51ccf98cf 100644 (file)
@@ -114,14 +114,19 @@ def within_repo(repo, opt, out, pwd=b''):
                          human_readable=opt.human_readable)
 
     ret = 0
+    want_meta = bool(opt.long_listing or opt.classification)
     pending = []
-    for path in opt.paths:
-        path = posixpath.join(pwd, path)
+    last_n = len(opt.paths) - 1
+    for n, printpath in enumerate(opt.paths):
+        path = posixpath.join(pwd, printpath)
         try:
+            if last_n > 0:
+                out.write(b'%s:\n' % printpath)
+
             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:
@@ -131,7 +136,7 @@ def within_repo(repo, opt, out, pwd=b''):
                 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]
@@ -145,7 +150,7 @@ def within_repo(repo, opt, out, pwd=b''):
                     if opt.l:
                         sub_item = vfs.ensure_item_has_metadata(repo, sub_item,
                                                                 include_size=True)
-                    else:
+                    elif want_meta:
                         sub_item = vfs.augment_item_meta(repo, sub_item,
                                                          include_size=True)
                     line = item_line(sub_item, sub_name)
@@ -155,8 +160,9 @@ def within_repo(repo, opt, out, pwd=b''):
                         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)
@@ -167,8 +173,12 @@ def within_repo(repo, opt, out, pwd=b''):
             log('bup: %s\n' % ex)
             ret = 1
 
-    if pending:
-        out.write(columnate(pending, b''))
+        if pending:
+            out.write(columnate(pending, b''))
+            pending = []
+
+        if n < last_n:
+            out.write(b'\n')
 
     return ret