/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 breezy/tree.py

Add a recurse_nested argument to Tree.list_files.

Merged from https://code.launchpad.net/~jelmer/brz/follow-tree-references-list-files/+merge/374066

Show diffs side-by-side

added added

removed removed

Lines of Context:
353
353
        """
354
354
        raise NotImplementedError(self.iter_child_entries)
355
355
 
356
 
    def list_files(self, include_root=False, from_dir=None, recursive=True):
 
356
    def list_files(self, include_root=False, from_dir=None, recursive=True,
 
357
                   recurse_nested=False):
357
358
        """List all files in this tree.
358
359
 
359
360
        :param include_root: Whether to include the entry for the tree root
360
361
        :param from_dir: Directory under which to list files
361
362
        :param recursive: Whether to list files recursively
 
363
        :param recurse_nested: enter nested trees
362
364
        :return: iterator over tuples of
363
365
            (path, versioned, kind, inventory entry)
364
366
        """
370
372
                if entry.kind == 'tree-reference':
371
373
                    yield path
372
374
 
 
375
    def get_containing_nested_tree(self, path):
 
376
        """Find the nested tree that contains a path.
 
377
 
 
378
        :return: tuple with (nested tree and path inside the nested tree)
 
379
        """
 
380
        for nested_path in self.iter_references():
 
381
            nested_path += '/'
 
382
            if path.startswith(nested_path):
 
383
                nested_tree = self.get_nested_tree(nested_path)
 
384
                return nested_tree, path[len(nested_path):]
 
385
        else:
 
386
            return None, None
 
387
 
373
388
    def get_nested_tree(self, path):
374
389
        """Open the nested tree at the specified path.
375
390