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

  • Committer: Robert Collins
  • Date: 2010-05-11 08:36:16 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100511083616-b8fjb19zomwupid0
Make all lock methods return Result objects, rather than lock_read returning self, as per John's review.

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, name=None):
 
740
    def get_branch_reference(self):
741
741
        """Return the referenced URL for the branch in this bzrdir.
742
742
 
743
 
        :param name: Optional colocated branch name
744
743
        :raises NotBranchError: If there is no Branch.
745
 
        :raises NoColocatedBranchSupport: If a branch name was specified
746
 
            but colocated branches are not supported.
747
744
        :return: The URL the branch in this bzrdir references if it is a
748
745
            reference branch, or None for regular branches.
749
746
        """
750
 
        if name is not None:
751
 
            raise errors.NoColocatedBranchSupport(self)
752
747
        return None
753
748
 
754
749
    def get_branch_transport(self, branch_format, name=None):
999
994
                raise errors.NotBranchError(path=url)
1000
995
            a_transport = new_t
1001
996
 
1002
 
    def _get_tree_branch(self, name=None):
 
997
    def _get_tree_branch(self):
1003
998
        """Return the branch and tree, if any, for this bzrdir.
1004
999
 
1005
 
        :param name: Name of colocated branch to open.
1006
 
 
1007
1000
        Return None for tree if not present or inaccessible.
1008
1001
        Raise NotBranchError if no branch is present.
1009
1002
        :return: (tree, branch)
1012
1005
            tree = self.open_workingtree()
1013
1006
        except (errors.NoWorkingTree, errors.NotLocalUrl):
1014
1007
            tree = None
1015
 
            branch = self.open_branch(name=name)
 
1008
            branch = self.open_branch()
1016
1009
        else:
1017
 
            if name is not None:
1018
 
                branch = self.open_branch(name=name)
1019
 
            else:
1020
 
                branch = tree.branch
 
1010
            branch = tree.branch
1021
1011
        return tree, branch
1022
1012
 
1023
1013
    @classmethod
1746
1736
    def destroy_workingtree_metadata(self):
1747
1737
        self.transport.delete_tree('checkout')
1748
1738
 
1749
 
    def find_branch_format(self, name=None):
 
1739
    def find_branch_format(self):
1750
1740
        """Find the branch 'format' for this bzrdir.
1751
1741
 
1752
1742
        This might be a synthetic object for e.g. RemoteBranch and SVN.
1753
1743
        """
1754
1744
        from bzrlib.branch import BranchFormat
1755
 
        return BranchFormat.find_format(self, name=name)
 
1745
        return BranchFormat.find_format(self)
1756
1746
 
1757
1747
    def _get_mkdir_mode(self):
1758
1748
        """Figure out the mode to use when creating a bzrdir subdir."""
1760
1750
                                     lockable_files.TransportLock)
1761
1751
        return temp_control._dir_mode
1762
1752
 
1763
 
    def get_branch_reference(self, name=None):
 
1753
    def get_branch_reference(self):
1764
1754
        """See BzrDir.get_branch_reference()."""
1765
1755
        from bzrlib.branch import BranchFormat
1766
 
        format = BranchFormat.find_format(self, name=name)
1767
 
        return format.get_reference(self, name=name)
 
1756
        format = BranchFormat.find_format(self)
 
1757
        return format.get_reference(self)
1768
1758
 
1769
1759
    def get_branch_transport(self, branch_format, name=None):
1770
1760
        """See BzrDir.get_branch_transport()."""
1864
1854
    def open_branch(self, name=None, unsupported=False,
1865
1855
                    ignore_fallbacks=False):
1866
1856
        """See BzrDir.open_branch."""
1867
 
        format = self.find_branch_format(name=name)
 
1857
        format = self.find_branch_format()
1868
1858
        self._check_supported(format, unsupported)
1869
1859
        return format.open(self, name=name,
1870
1860
            _found=True, ignore_fallbacks=ignore_fallbacks)
2873
2863
            self.revisions[rev_id] = rev
2874
2864
 
2875
2865
    def _load_old_inventory(self, rev_id):
2876
 
        f = self.branch.repository.inventory_store.get(rev_id)
2877
 
        try:
2878
 
            old_inv_xml = f.read()
2879
 
        finally:
2880
 
            f.close()
 
2866
        old_inv_xml = self.branch.repository.inventory_store.get(rev_id).read()
2881
2867
        inv = xml4.serializer_v4.read_inventory_from_string(old_inv_xml)
2882
2868
        inv.revision_id = rev_id
2883
2869
        rev = self.revisions[rev_id]
2961
2947
                ie.revision = previous_ie.revision
2962
2948
                return
2963
2949
        if ie.has_text():
2964
 
            f = self.branch.repository._text_store.get(ie.text_id)
2965
 
            try:
2966
 
                file_lines = f.readlines()
2967
 
            finally:
2968
 
                f.close()
 
2950
            text = self.branch.repository._text_store.get(ie.text_id)
 
2951
            file_lines = text.readlines()
2969
2952
            w.add_lines(rev_id, previous_revisions, file_lines)
2970
2953
            self.text_count += 1
2971
2954
        else:
3252
3235
        # XXX: It's a bit ugly that the network name is here, because we'd
3253
3236
        # like to believe that format objects are stateless or at least
3254
3237
        # immutable,  However, we do at least avoid mutating the name after
3255
 
        # it's returned.  See <https://bugs.launchpad.net/bzr/+bug/504102>
 
3238
        # it's returned.  See <https://bugs.edge.launchpad.net/bzr/+bug/504102>
3256
3239
        self._network_name = None
3257
3240
 
3258
3241
    def __repr__(self):