2353
2353
recursive=False, from_root=False,
2354
2354
unknown=False, versioned=False, ignored=False,
2355
2355
null=False, kind=None, show_ids=False, path=None):
2356
# Validate the command line options
2357
2357
if kind and kind not in ('file', 'directory', 'symlink'):
2358
2358
raise errors.BzrCommandError('invalid kind specified')
2360
2359
if verbose and null:
2361
2360
raise errors.BzrCommandError('Cannot set both --verbose and --null')
2362
all = not (unknown or versioned or ignored)
2364
selection = {'I':ignored, '?':unknown, 'V':versioned}
2366
2361
if path is None:
2371
raise errors.BzrCommandError('cannot specify both --from-root'
2375
tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
2364
raise errors.BzrCommandError('cannot specify both --from-root'
2368
tree, branch, dir = bzrdir.BzrDir.open_containing_tree_or_branch(path)
2369
mutter("ls dir is %s", dir)
2381
2370
if revision is not None or tree is None:
2382
2371
tree = _get_one_revision_tree('ls', revision, branch=branch)
2385
if isinstance(tree, WorkingTree) and tree.supports_views():
2386
view_files = tree.views.lookup_view()
2389
view_str = views.view_display_str(view_files)
2390
note("Ignoring files outside view. View is %s" % view_str)
2373
# Calculate the prefix to use
2394
for fp, fc, fkind, fid, entry in tree.list_files(include_root=False):
2395
if fp.startswith(relpath):
2396
rp = fp[len(relpath):]
2397
fp = osutils.pathjoin(prefix, rp)
2398
if not recursive and '/' in rp:
2400
if not all and not selection[fc]:
2402
if kind is not None and fkind != kind:
2406
views.check_path_in_view(tree, fp)
2407
except errors.FileOutsideView:
2409
kindch = entry.kind_character()
2410
outstring = fp + kindch
2412
outstring = '%-8s %s' % (fc, outstring)
2413
if show_ids and fid is not None:
2414
outstring = "%-50s %s" % (outstring, fid)
2415
self.outf.write(outstring + '\n')
2417
self.outf.write(fp + '\0')
2420
self.outf.write(fid)
2421
self.outf.write('\0')
2429
self.outf.write('%-50s %s\n' % (outstring, my_id))
2431
self.outf.write(outstring + '\n')
2382
from bzrlib import ls
2383
ls.ls(tree, self.outf, from_dir=dir, recursive=recursive,
2384
kind=kind, unknown=unknown, versioned=versioned, ignored=ignored,
2385
verbose=verbose, null=null, show_ids=show_ids, prefix=prefix)
2436
2388
class cmd_unknowns(Command):