~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-05-07 11:50:28 UTC
  • mfrom: (5147.4.7 more-colo)
  • Revision ID: pqm@pqm.ubuntu.com-20100507115028-tuuxmnormm8oetw6
(vila, for jelmer) Pass the colocated branch name along in more places,
        add extra tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
737
737
            raise errors.NoRepositoryPresent(self)
738
738
        return found_repo
739
739
 
740
 
    def get_branch_reference(self):
 
740
    def get_branch_reference(self, name=None):
741
741
        """Return the referenced URL for the branch in this bzrdir.
742
742
 
 
743
        :param name: Optional colocated branch name
743
744
        :raises NotBranchError: If there is no Branch.
 
745
        :raises NoColocatedBranchSupport: If a branch name was specified
 
746
            but colocated branches are not supported.
744
747
        :return: The URL the branch in this bzrdir references if it is a
745
748
            reference branch, or None for regular branches.
746
749
        """
 
750
        if name is not None:
 
751
            raise errors.NoColocatedBranchSupport(self)
747
752
        return None
748
753
 
749
754
    def get_branch_transport(self, branch_format, name=None):
994
999
                raise errors.NotBranchError(path=url)
995
1000
            a_transport = new_t
996
1001
 
997
 
    def _get_tree_branch(self):
 
1002
    def _get_tree_branch(self, name=None):
998
1003
        """Return the branch and tree, if any, for this bzrdir.
999
1004
 
 
1005
        :param name: Name of colocated branch to open.
 
1006
 
1000
1007
        Return None for tree if not present or inaccessible.
1001
1008
        Raise NotBranchError if no branch is present.
1002
1009
        :return: (tree, branch)
1005
1012
            tree = self.open_workingtree()
1006
1013
        except (errors.NoWorkingTree, errors.NotLocalUrl):
1007
1014
            tree = None
1008
 
            branch = self.open_branch()
 
1015
            branch = self.open_branch(name=name)
1009
1016
        else:
1010
 
            branch = tree.branch
 
1017
            if name is not None:
 
1018
                branch = self.open_branch(name=name)
 
1019
            else:
 
1020
                branch = tree.branch
1011
1021
        return tree, branch
1012
1022
 
1013
1023
    @classmethod
1736
1746
    def destroy_workingtree_metadata(self):
1737
1747
        self.transport.delete_tree('checkout')
1738
1748
 
1739
 
    def find_branch_format(self):
 
1749
    def find_branch_format(self, name=None):
1740
1750
        """Find the branch 'format' for this bzrdir.
1741
1751
 
1742
1752
        This might be a synthetic object for e.g. RemoteBranch and SVN.
1743
1753
        """
1744
1754
        from bzrlib.branch import BranchFormat
1745
 
        return BranchFormat.find_format(self)
 
1755
        return BranchFormat.find_format(self, name=name)
1746
1756
 
1747
1757
    def _get_mkdir_mode(self):
1748
1758
        """Figure out the mode to use when creating a bzrdir subdir."""
1750
1760
                                     lockable_files.TransportLock)
1751
1761
        return temp_control._dir_mode
1752
1762
 
1753
 
    def get_branch_reference(self):
 
1763
    def get_branch_reference(self, name=None):
1754
1764
        """See BzrDir.get_branch_reference()."""
1755
1765
        from bzrlib.branch import BranchFormat
1756
 
        format = BranchFormat.find_format(self)
1757
 
        return format.get_reference(self)
 
1766
        format = BranchFormat.find_format(self, name=name)
 
1767
        return format.get_reference(self, name=name)
1758
1768
 
1759
1769
    def get_branch_transport(self, branch_format, name=None):
1760
1770
        """See BzrDir.get_branch_transport()."""
1854
1864
    def open_branch(self, name=None, unsupported=False,
1855
1865
                    ignore_fallbacks=False):
1856
1866
        """See BzrDir.open_branch."""
1857
 
        format = self.find_branch_format()
 
1867
        format = self.find_branch_format(name=name)
1858
1868
        self._check_supported(format, unsupported)
1859
1869
        return format.open(self, name=name,
1860
1870
            _found=True, ignore_fallbacks=ignore_fallbacks)