~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-02-16 00:53:04 UTC
  • mfrom: (4997.1.3 find-branches-local)
  • Revision ID: pqm@pqm.ubuntu.com-20100216005304-1p8xafkhiizh6ugi
(Jelmer) Add BzrDir.list_branches().

Show diffs side-by-side

added added

removed removed

Lines of Context:
1484
1484
        :param using: If True, list only branches using this repository.
1485
1485
        """
1486
1486
        if using and not self.is_shared():
1487
 
            try:
1488
 
                return [self.bzrdir.open_branch()]
1489
 
            except errors.NotBranchError:
1490
 
                return []
 
1487
            return self.bzrdir.list_branches()
1491
1488
        class Evaluator(object):
1492
1489
 
1493
1490
            def __init__(self):
1502
1499
                    except errors.NoRepositoryPresent:
1503
1500
                        pass
1504
1501
                    else:
1505
 
                        return False, (None, repository)
 
1502
                        return False, ([], repository)
1506
1503
                self.first_call = False
1507
 
                try:
1508
 
                    value = (bzrdir.open_branch(), None)
1509
 
                except errors.NotBranchError:
1510
 
                    value = (None, None)
 
1504
                value = (bzrdir.list_branches(), None)
1511
1505
                return True, value
1512
1506
 
1513
 
        branches = []
1514
 
        for branch, repository in bzrdir.BzrDir.find_bzrdirs(
 
1507
        ret = []
 
1508
        for branches, repository in bzrdir.BzrDir.find_bzrdirs(
1515
1509
                self.bzrdir.root_transport, evaluate=Evaluator()):
1516
 
            if branch is not None:
1517
 
                branches.append(branch)
 
1510
            if branches is not None:
 
1511
                ret.extend(branches)
1518
1512
            if not using and repository is not None:
1519
 
                branches.extend(repository.find_branches())
1520
 
        return branches
 
1513
                ret.extend(repository.find_branches())
 
1514
        return ret
1521
1515
 
1522
1516
    @needs_read_lock
1523
1517
    def search_missing_revision_ids(self, other, revision_id=None, find_ghosts=True):