/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

Find callers of list_files() and make sure the tree is always locked.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1577
1577
        elif tree is None:
1578
1578
            tree = branch.basis_tree()
1579
1579
 
1580
 
        for fp, fc, fkind, fid, entry in tree.list_files(include_root=False):
1581
 
            if fp.startswith(relpath):
1582
 
                fp = osutils.pathjoin(prefix, fp[len(relpath):])
1583
 
                if non_recursive and '/' in fp:
1584
 
                    continue
1585
 
                if not all and not selection[fc]:
1586
 
                    continue
1587
 
                if kind is not None and fkind != kind:
1588
 
                    continue
1589
 
                if verbose:
1590
 
                    kindch = entry.kind_character()
1591
 
                    outstring = '%-8s %s%s' % (fc, fp, kindch)
1592
 
                    if show_ids and fid is not None:
1593
 
                        outstring = "%-50s %s" % (outstring, fid)
1594
 
                    self.outf.write(outstring + '\n')
1595
 
                elif null:
1596
 
                    self.outf.write(fp + '\0')
1597
 
                    if show_ids:
 
1580
        tree.lock_read()
 
1581
        try:
 
1582
            for fp, fc, fkind, fid, entry in tree.list_files(include_root=False):
 
1583
                if fp.startswith(relpath):
 
1584
                    fp = osutils.pathjoin(prefix, fp[len(relpath):])
 
1585
                    if non_recursive and '/' in fp:
 
1586
                        continue
 
1587
                    if not all and not selection[fc]:
 
1588
                        continue
 
1589
                    if kind is not None and fkind != kind:
 
1590
                        continue
 
1591
                    if verbose:
 
1592
                        kindch = entry.kind_character()
 
1593
                        outstring = '%-8s %s%s' % (fc, fp, kindch)
 
1594
                        if show_ids and fid is not None:
 
1595
                            outstring = "%-50s %s" % (outstring, fid)
 
1596
                        self.outf.write(outstring + '\n')
 
1597
                    elif null:
 
1598
                        self.outf.write(fp + '\0')
 
1599
                        if show_ids:
 
1600
                            if fid is not None:
 
1601
                                self.outf.write(fid)
 
1602
                            self.outf.write('\0')
 
1603
                        self.outf.flush()
 
1604
                    else:
1598
1605
                        if fid is not None:
1599
 
                            self.outf.write(fid)
1600
 
                        self.outf.write('\0')
1601
 
                    self.outf.flush()
1602
 
                else:
1603
 
                    if fid is not None:
1604
 
                        my_id = fid
1605
 
                    else:
1606
 
                        my_id = ''
1607
 
                    if show_ids:
1608
 
                        self.outf.write('%-50s %s\n' % (fp, my_id))
1609
 
                    else:
1610
 
                        self.outf.write(fp + '\n')
 
1606
                            my_id = fid
 
1607
                        else:
 
1608
                            my_id = ''
 
1609
                        if show_ids:
 
1610
                            self.outf.write('%-50s %s\n' % (fp, my_id))
 
1611
                        else:
 
1612
                            self.outf.write(fp + '\n')
 
1613
        finally:
 
1614
            tree.unlock()
1611
1615
 
1612
1616
 
1613
1617
class cmd_unknowns(Command):
1712
1716
    @display_command
1713
1717
    def run(self):
1714
1718
        tree = WorkingTree.open_containing(u'.')[0]
1715
 
        for path, file_class, kind, file_id, entry in tree.list_files():
1716
 
            if file_class != 'I':
1717
 
                continue
1718
 
            ## XXX: Slightly inefficient since this was already calculated
1719
 
            pat = tree.is_ignored(path)
1720
 
            print '%-50s %s' % (path, pat)
 
1719
        tree.lock_read()
 
1720
        try:
 
1721
            for path, file_class, kind, file_id, entry in tree.list_files():
 
1722
                if file_class != 'I':
 
1723
                    continue
 
1724
                ## XXX: Slightly inefficient since this was already calculated
 
1725
                pat = tree.is_ignored(path)
 
1726
                print '%-50s %s' % (path, pat)
 
1727
        finally:
 
1728
            tree.unlock()
1721
1729
 
1722
1730
 
1723
1731
class cmd_lookup_revision(Command):