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

  • Committer: Aaron Bentley
  • Date: 2007-12-21 19:56:30 UTC
  • mto: This revision was merged to the branch mainline in revision 3143.
  • Revision ID: abentley@panoramicfeedback.com-20071221195630-u9lqadyl8letkois
Add ability to find branches inside repositories

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
        :param using: If True, list only branches using this repository.
 
773
        """
 
774
 
 
775
        class Evaluator(object):
 
776
 
 
777
            def __init__(self):
 
778
                self.first_call = True
 
779
 
 
780
            def __call__(self, bzrdir):
 
781
                # On the first call, the parameter is always the bzrdir
 
782
                # containing the current repo.
 
783
                if not self.first_call:
 
784
                    try:
 
785
                        repository = bzrdir.open_repository()
 
786
                    except errors.NoRepositoryPresent:
 
787
                        pass
 
788
                    else:
 
789
                        return False, (None, repository)
 
790
                self.first_call = False
 
791
                try:
 
792
                    value = (bzrdir.open_branch(), None)
 
793
                except errors.NotBranchError:
 
794
                    value = (None, None)
 
795
                return True, value
 
796
 
 
797
        branches = []
 
798
        for branch, repository in bzrdir.BzrDir.find_bzrdirs(
 
799
                self.bzrdir.root_transport, evaluate=Evaluator()):
 
800
            if branch is not None:
 
801
                branches.append(branch)
 
802
            if not using and repository is not None:
 
803
                branches.extend(repository.find_branches())
 
804
        return branches
 
805
 
769
806
    def get_data_stream(self, revision_ids):
770
807
        raise NotImplementedError(self.get_data_stream)
771
808