~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

Unhide ls, add kind flag

Show diffs side-by-side

added added

removed removed

Lines of Context:
1516
1516
class cmd_ls(Command):
1517
1517
    """List files in a tree.
1518
1518
    """
 
1519
 
1519
1520
    # TODO: Take a revision or remote path and list that tree instead.
1520
 
    hidden = True
1521
1521
    takes_options = ['verbose', 'revision',
1522
1522
                     Option('non-recursive',
1523
1523
                            help='don\'t recurse into sub-directories'),
1528
1528
                     Option('ignored', help='Print ignored files'),
1529
1529
 
1530
1530
                     Option('null', help='Null separate the files'),
 
1531
                     'kind',
1531
1532
                    ]
1532
1533
    @display_command
1533
1534
    def run(self, revision=None, verbose=False, 
1534
1535
            non_recursive=False, from_root=False,
1535
1536
            unknown=False, versioned=False, ignored=False,
1536
 
            null=False):
 
1537
            null=False, kind=None):
 
1538
 
 
1539
        if kind and kind not in ('file', 'directory', 'symlink'):
 
1540
            raise errors.BzrCommandError('invalid kind specified')
1537
1541
 
1538
1542
        if verbose and null:
1539
1543
            raise errors.BzrCommandError('Cannot set both --verbose and --null')
1550
1554
            tree = tree.branch.repository.revision_tree(
1551
1555
                revision[0].in_history(tree.branch).rev_id)
1552
1556
 
1553
 
        for fp, fc, kind, fid, entry in tree.list_files(include_root=False):
 
1557
        for fp, fc, fkind, fid, entry in tree.list_files(include_root=False):
1554
1558
            if fp.startswith(relpath):
1555
1559
                fp = fp[len(relpath):]
1556
1560
                if non_recursive and '/' in fp:
1557
1561
                    continue
1558
1562
                if not all and not selection[fc]:
1559
1563
                    continue
 
1564
                if kind is not None and fkind != kind:
 
1565
                    continue
1560
1566
                if verbose:
1561
1567
                    kindch = entry.kind_character()
1562
1568
                    self.outf.write('%-8s %s%s\n' % (fc, fp, kindch))