~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-01-02 22:56:30 UTC
  • mfrom: (2215.3.1 ls)
  • Revision ID: pqm@pqm.ubuntu.com-20070102225630-e2bbb87a8d1151bf
Allow ls to take a PATH

Show diffs side-by-side

added added

removed removed

Lines of Context:
1522
1522
    """List files in a tree.
1523
1523
    """
1524
1524
 
 
1525
    takes_args = ['path?']
1525
1526
    # TODO: Take a revision or remote path and list that tree instead.
1526
1527
    takes_options = ['verbose', 'revision',
1527
1528
                     Option('non-recursive',
1539
1540
    def run(self, revision=None, verbose=False, 
1540
1541
            non_recursive=False, from_root=False,
1541
1542
            unknown=False, versioned=False, ignored=False,
1542
 
            null=False, kind=None, show_ids=False):
 
1543
            null=False, kind=None, show_ids=False, path=None):
1543
1544
 
1544
1545
        if kind and kind not in ('file', 'directory', 'symlink'):
1545
1546
            raise errors.BzrCommandError('invalid kind specified')
1550
1551
 
1551
1552
        selection = {'I':ignored, '?':unknown, 'V':versioned}
1552
1553
 
1553
 
        tree, relpath = WorkingTree.open_containing(u'.')
 
1554
        if path is None:
 
1555
            fs_path = '.'
 
1556
            prefix = ''
 
1557
        else:
 
1558
            if from_root:
 
1559
                raise errors.BzrCommandError('cannot specify both --from-root'
 
1560
                                             ' and PATH')
 
1561
            fs_path = path
 
1562
            prefix = path
 
1563
        tree, relpath = WorkingTree.open_containing(fs_path)
1554
1564
        if from_root:
1555
1565
            relpath = u''
1556
1566
        elif relpath:
1561
1571
 
1562
1572
        for fp, fc, fkind, fid, entry in tree.list_files(include_root=False):
1563
1573
            if fp.startswith(relpath):
1564
 
                fp = fp[len(relpath):]
 
1574
                fp = osutils.pathjoin(prefix, fp[len(relpath):])
1565
1575
                if non_recursive and '/' in fp:
1566
1576
                    continue
1567
1577
                if not all and not selection[fc]: