/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-06 11:08:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506110810-h3j07fh5gmw54s25
Cleaner matcher matching revised unlocking protocol.

Show diffs side-by-side

added added

removed removed

Lines of Context:
375
375
            recurse = True
376
376
            try:
377
377
                bzrdir = BzrDir.open_from_transport(current_transport)
378
 
            except (errors.NotBranchError, errors.PermissionDenied):
 
378
            except errors.NotBranchError:
379
379
                pass
380
380
            else:
381
381
                recurse, value = evaluate(bzrdir)
382
382
                yield value
383
383
            try:
384
384
                subdirs = list_current(current_transport)
385
 
            except (errors.NoSuchFile, errors.PermissionDenied):
 
385
            except errors.NoSuchFile:
386
386
                continue
387
387
            if recurse:
388
388
                for subdir in sorted(subdirs, reverse=True):
394
394
        """
395
395
        try:
396
396
            return [self.open_branch()]
397
 
        except (errors.NotBranchError, errors.NoRepositoryPresent):
 
397
        except errors.NotBranchError:
398
398
            return []
399
399
 
400
400
    @staticmethod
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
1244
1234
        repository_policy = result.determine_repository_policy(
1245
1235
            force_new_repo, stacked_branch_url, require_stacking=stacked)
1246
1236
        result_repo, is_new_repo = repository_policy.acquire_repository()
1247
 
        is_stacked = stacked or (len(result_repo._fallback_repositories) != 0)
1248
 
        if is_new_repo and revision_id is not None and not is_stacked:
 
1237
        if is_new_repo and revision_id is not None and not stacked:
1249
1238
            fetch_spec = graph.PendingAncestryResult(
1250
1239
                [revision_id], source_repository)
1251
1240
        else:
1747
1736
    def destroy_workingtree_metadata(self):
1748
1737
        self.transport.delete_tree('checkout')
1749
1738
 
1750
 
    def find_branch_format(self, name=None):
 
1739
    def find_branch_format(self):
1751
1740
        """Find the branch 'format' for this bzrdir.
1752
1741
 
1753
1742
        This might be a synthetic object for e.g. RemoteBranch and SVN.
1754
1743
        """
1755
1744
        from bzrlib.branch import BranchFormat
1756
 
        return BranchFormat.find_format(self, name=name)
 
1745
        return BranchFormat.find_format(self)
1757
1746
 
1758
1747
    def _get_mkdir_mode(self):
1759
1748
        """Figure out the mode to use when creating a bzrdir subdir."""
1761
1750
                                     lockable_files.TransportLock)
1762
1751
        return temp_control._dir_mode
1763
1752
 
1764
 
    def get_branch_reference(self, name=None):
 
1753
    def get_branch_reference(self):
1765
1754
        """See BzrDir.get_branch_reference()."""
1766
1755
        from bzrlib.branch import BranchFormat
1767
 
        format = BranchFormat.find_format(self, name=name)
1768
 
        return format.get_reference(self, name=name)
 
1756
        format = BranchFormat.find_format(self)
 
1757
        return format.get_reference(self)
1769
1758
 
1770
1759
    def get_branch_transport(self, branch_format, name=None):
1771
1760
        """See BzrDir.get_branch_transport()."""
1865
1854
    def open_branch(self, name=None, unsupported=False,
1866
1855
                    ignore_fallbacks=False):
1867
1856
        """See BzrDir.open_branch."""
1868
 
        format = self.find_branch_format(name=name)
 
1857
        format = self.find_branch_format()
1869
1858
        self._check_supported(format, unsupported)
1870
1859
        return format.open(self, name=name,
1871
1860
            _found=True, ignore_fallbacks=ignore_fallbacks)
1959
1948
            format_string = transport.get_bytes(".bzr/branch-format")
1960
1949
        except errors.NoSuchFile:
1961
1950
            raise errors.NotBranchError(path=transport.base)
 
1951
 
1962
1952
        try:
1963
1953
            return klass._formats[format_string]
1964
1954
        except KeyError:
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):