Merge lp:~jelmer/bzr/branch-names into lp:bzr

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Martin Pool
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~jelmer/bzr/branch-names
Merge into: lp:bzr
Diff against target: 61 lines (+11/-5)
1 file modified
bzrlib/branch.py (+11/-5)
To merge this branch: bzr merge lp:~jelmer/bzr/branch-names
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+21197@code.launchpad.net

Description of the change

This lets Branch objects keep track of their name (if any) in their control directory.

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/branch.py'
--- bzrlib/branch.py 2010-03-06 17:49:26 +0000
+++ bzrlib/branch.py 2010-03-11 23:35:22 +0000
@@ -1759,14 +1759,13 @@
17591759
1760 def open(self, a_bzrdir, name=None, _found=False, ignore_fallbacks=False):1760 def open(self, a_bzrdir, name=None, _found=False, ignore_fallbacks=False):
1761 """See BranchFormat.open()."""1761 """See BranchFormat.open()."""
1762 if name is not None:
1763 raise errors.NoColocatedBranchSupport(a_bzrdir)
1764 if not _found:1762 if not _found:
1765 # we are being called directly and must probe.1763 # we are being called directly and must probe.
1766 raise NotImplementedError1764 raise NotImplementedError
1767 return BzrBranch(_format=self,1765 return BzrBranch(_format=self,
1768 _control_files=a_bzrdir._control_files,1766 _control_files=a_bzrdir._control_files,
1769 a_bzrdir=a_bzrdir,1767 a_bzrdir=a_bzrdir,
1768 name=name,
1770 _repository=a_bzrdir.open_repository())1769 _repository=a_bzrdir.open_repository())
17711770
1772 def __str__(self):1771 def __str__(self):
@@ -1800,6 +1799,7 @@
1800 lockdir.LockDir)1799 lockdir.LockDir)
1801 return self._branch_class()(_format=self,1800 return self._branch_class()(_format=self,
1802 _control_files=control_files,1801 _control_files=control_files,
1802 name=name,
1803 a_bzrdir=a_bzrdir,1803 a_bzrdir=a_bzrdir,
1804 _repository=a_bzrdir.find_repository(),1804 _repository=a_bzrdir.find_repository(),
1805 ignore_fallbacks=ignore_fallbacks)1805 ignore_fallbacks=ignore_fallbacks)
@@ -2100,17 +2100,20 @@
2100 :ivar repository: Repository for this branch.2100 :ivar repository: Repository for this branch.
2101 :ivar base: The url of the base directory for this branch; the one2101 :ivar base: The url of the base directory for this branch; the one
2102 containing the .bzr directory.2102 containing the .bzr directory.
2103 :ivar name: Optional colocated branch name as it exists in the control
2104 directory.
2103 """2105 """
21042106
2105 def __init__(self, _format=None,2107 def __init__(self, _format=None,
2106 _control_files=None, a_bzrdir=None, _repository=None,2108 _control_files=None, a_bzrdir=None, name=None,
2107 ignore_fallbacks=False):2109 _repository=None, ignore_fallbacks=False):
2108 """Create new branch object at a particular location."""2110 """Create new branch object at a particular location."""
2109 if a_bzrdir is None:2111 if a_bzrdir is None:
2110 raise ValueError('a_bzrdir must be supplied')2112 raise ValueError('a_bzrdir must be supplied')
2111 else:2113 else:
2112 self.bzrdir = a_bzrdir2114 self.bzrdir = a_bzrdir
2113 self._base = self.bzrdir.transport.clone('..').base2115 self._base = self.bzrdir.transport.clone('..').base
2116 self.name = name
2114 # XXX: We should be able to just do2117 # XXX: We should be able to just do
2115 # self.base = self.bzrdir.root_transport.base2118 # self.base = self.bzrdir.root_transport.base
2116 # but this does not quite work yet -- mbp 200805222119 # but this does not quite work yet -- mbp 20080522
@@ -2123,7 +2126,10 @@
2123 Branch.__init__(self)2126 Branch.__init__(self)
21242127
2125 def __str__(self):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)
21272133
2128 __repr__ = __str__2134 __repr__ = __str__
21292135