~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
766
766
            result['size'] = t
767
767
        return result
768
768
 
 
769
    def find_branches(self, using=False):
 
770
        """Find branches underneath this repository.
 
771
 
 
772
        This will include branches inside other branches.
 
773
 
 
774
        :param using: If True, list only branches using this repository.
 
775
        """
 
776
 
 
777
        class Evaluator(object):
 
778
 
 
779
            def __init__(self):
 
780
                self.first_call = True
 
781
 
 
782
            def __call__(self, bzrdir):
 
783
                # On the first call, the parameter is always the bzrdir
 
784
                # containing the current repo.
 
785
                if not self.first_call:
 
786
                    try:
 
787
                        repository = bzrdir.open_repository()
 
788
                    except errors.NoRepositoryPresent:
 
789
                        pass
 
790
                    else:
 
791
                        return False, (None, repository)
 
792
                self.first_call = False
 
793
                try:
 
794
                    value = (bzrdir.open_branch(), None)
 
795
                except errors.NotBranchError:
 
796
                    value = (None, None)
 
797
                return True, value
 
798
 
 
799
        branches = []
 
800
        for branch, repository in bzrdir.BzrDir.find_bzrdirs(
 
801
                self.bzrdir.root_transport, evaluate=Evaluator()):
 
802
            if branch is not None:
 
803
                branches.append(branch)
 
804
            if not using and repository is not None:
 
805
                branches.extend(repository.find_branches())
 
806
        return branches
 
807
 
769
808
    def get_data_stream(self, revision_ids):
770
809
        raise NotImplementedError(self.get_data_stream)
771
810