~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Robert Collins
  • Date: 2010-06-21 01:30:45 UTC
  • mfrom: (5309 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5310.
  • Revision ID: robertc@robertcollins.net-20100621013045-s59nfjps3rkcn53j
Merge trunk to fix NEWS sections.

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)
2863
2873
            self.revisions[rev_id] = rev
2864
2874
 
2865
2875
    def _load_old_inventory(self, rev_id):
2866
 
        old_inv_xml = self.branch.repository.inventory_store.get(rev_id).read()
 
2876
        f = self.branch.repository.inventory_store.get(rev_id)
 
2877
        try:
 
2878
            old_inv_xml = f.read()
 
2879
        finally:
 
2880
            f.close()
2867
2881
        inv = xml4.serializer_v4.read_inventory_from_string(old_inv_xml)
2868
2882
        inv.revision_id = rev_id
2869
2883
        rev = self.revisions[rev_id]
2947
2961
                ie.revision = previous_ie.revision
2948
2962
                return
2949
2963
        if ie.has_text():
2950
 
            text = self.branch.repository._text_store.get(ie.text_id)
2951
 
            file_lines = text.readlines()
 
2964
            f = self.branch.repository._text_store.get(ie.text_id)
 
2965
            try:
 
2966
                file_lines = f.readlines()
 
2967
            finally:
 
2968
                f.close()
2952
2969
            w.add_lines(rev_id, previous_revisions, file_lines)
2953
2970
            self.text_count += 1
2954
2971
        else:
3235
3252
        # XXX: It's a bit ugly that the network name is here, because we'd
3236
3253
        # like to believe that format objects are stateless or at least
3237
3254
        # immutable,  However, we do at least avoid mutating the name after
3238
 
        # it's returned.  See <https://bugs.edge.launchpad.net/bzr/+bug/504102>
 
3255
        # it's returned.  See <https://bugs.launchpad.net/bzr/+bug/504102>
3239
3256
        self._network_name = None
3240
3257
 
3241
3258
    def __repr__(self):