/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/transform.py

  • Committer: Aaron Bentley
  • Date: 2008-07-23 15:54:26 UTC
  • mto: (3363.11.16 list_files)
  • mto: This revision was merged to the branch mainline in revision 3662.
  • Revision ID: aaron@aaronbentley.com-20080723155426-rztmpd206oz7fwkd
Implement walkdirs in terms of TreeTransform

Show diffs side-by-side

added added

removed removed

Lines of Context:
1699
1699
    def list_files(self, include_root=False):
1700
1700
        return self._transform._tree.list_files(include_root)
1701
1701
 
1702
 
    def walkdirs(self, prefix=""):
1703
 
        return self._transform._tree.walkdirs(prefix)
 
1702
    def walkdirs(self, prefix=''):
 
1703
        pending = [self._transform.root]
 
1704
        while len(pending) > 0:
 
1705
            parent_id = pending.pop()
 
1706
            children = []
 
1707
            subdirs = []
 
1708
            prefix = prefix.rstrip('/')
 
1709
            parent_path = self._final_paths.get_path(parent_id)
 
1710
            parent_file_id = self._transform.final_file_id(parent_id)
 
1711
            for child_id in self._all_children(parent_id):
 
1712
                path_from_root = self._final_paths.get_path(child_id)
 
1713
                basename = self._transform.final_name(child_id)
 
1714
                kind = self._transform.final_kind(child_id)
 
1715
                if kind == 'directory':
 
1716
                    subdirs.append(child_id)
 
1717
                file_id = self._transform.final_file_id(child_id)
 
1718
                children.append((path_from_root, basename, kind, None,
 
1719
                                 file_id, kind))
 
1720
            children.sort()
 
1721
            if parent_path.startswith(prefix):
 
1722
                yield (parent_path, parent_file_id), children
 
1723
            pending.extend(sorted(subdirs, key=self._final_paths.get_path,
 
1724
                                  reverse=True))
1704
1725
 
1705
1726
    def get_parent_ids(self):
1706
1727
        return self._parent_ids