~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-03-19 03:03:27 UTC
  • mfrom: (5085.1.1 use-branch-open)
  • Revision ID: pqm@pqm.ubuntu.com-20100319030327-b972l4hg4azzeaqf
(Jelmer) Let Branch objects keep track of the name (if any) they have
        in their control directory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1759
1759
 
1760
1760
    def open(self, a_bzrdir, name=None, _found=False, ignore_fallbacks=False):
1761
1761
        """See BranchFormat.open()."""
1762
 
        if name is not None:
1763
 
            raise errors.NoColocatedBranchSupport(a_bzrdir)
1764
1762
        if not _found:
1765
1763
            # we are being called directly and must probe.
1766
1764
            raise NotImplementedError
1767
1765
        return BzrBranch(_format=self,
1768
1766
                         _control_files=a_bzrdir._control_files,
1769
1767
                         a_bzrdir=a_bzrdir,
 
1768
                         name=name,
1770
1769
                         _repository=a_bzrdir.open_repository())
1771
1770
 
1772
1771
    def __str__(self):
1800
1799
                                                         lockdir.LockDir)
1801
1800
            return self._branch_class()(_format=self,
1802
1801
                              _control_files=control_files,
 
1802
                              name=name,
1803
1803
                              a_bzrdir=a_bzrdir,
1804
1804
                              _repository=a_bzrdir.find_repository(),
1805
1805
                              ignore_fallbacks=ignore_fallbacks)
2100
2100
    :ivar repository: Repository for this branch.
2101
2101
    :ivar base: The url of the base directory for this branch; the one
2102
2102
        containing the .bzr directory.
 
2103
    :ivar name: Optional colocated branch name as it exists in the control
 
2104
        directory.
2103
2105
    """
2104
2106
 
2105
2107
    def __init__(self, _format=None,
2106
 
                 _control_files=None, a_bzrdir=None, _repository=None,
2107
 
                 ignore_fallbacks=False):
 
2108
                 _control_files=None, a_bzrdir=None, name=None,
 
2109
                 _repository=None, ignore_fallbacks=False):
2108
2110
        """Create new branch object at a particular location."""
2109
2111
        if a_bzrdir is None:
2110
2112
            raise ValueError('a_bzrdir must be supplied')
2111
2113
        else:
2112
2114
            self.bzrdir = a_bzrdir
2113
2115
        self._base = self.bzrdir.transport.clone('..').base
 
2116
        self.name = name
2114
2117
        # XXX: We should be able to just do
2115
2118
        #   self.base = self.bzrdir.root_transport.base
2116
2119
        # but this does not quite work yet -- mbp 20080522
2123
2126
        Branch.__init__(self)
2124
2127
 
2125
2128
    def __str__(self):
2126
 
        return '%s(%r)' % (self.__class__.__name__, self.base)
 
2129
        if self.name is None:
 
2130
            return '%s(%r)' % (self.__class__.__name__, self.base)
 
2131
        else:
 
2132
            return '%s(%r,%r)' % (self.__class__.__name__, self.base, self.name)
2127
2133
 
2128
2134
    __repr__ = __str__
2129
2135