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
1=== modified file 'bzrlib/branch.py'
2--- bzrlib/branch.py 2010-03-06 17:49:26 +0000
3+++ bzrlib/branch.py 2010-03-11 23:35:22 +0000
4@@ -1759,14 +1759,13 @@
5
6 def open(self, a_bzrdir, name=None, _found=False, ignore_fallbacks=False):
7 """See BranchFormat.open()."""
8- if name is not None:
9- raise errors.NoColocatedBranchSupport(a_bzrdir)
10 if not _found:
11 # we are being called directly and must probe.
12 raise NotImplementedError
13 return BzrBranch(_format=self,
14 _control_files=a_bzrdir._control_files,
15 a_bzrdir=a_bzrdir,
16+ name=name,
17 _repository=a_bzrdir.open_repository())
18
19 def __str__(self):
20@@ -1800,6 +1799,7 @@
21 lockdir.LockDir)
22 return self._branch_class()(_format=self,
23 _control_files=control_files,
24+ name=name,
25 a_bzrdir=a_bzrdir,
26 _repository=a_bzrdir.find_repository(),
27 ignore_fallbacks=ignore_fallbacks)
28@@ -2100,17 +2100,20 @@
29 :ivar repository: Repository for this branch.
30 :ivar base: The url of the base directory for this branch; the one
31 containing the .bzr directory.
32+ :ivar name: Optional colocated branch name as it exists in the control
33+ directory.
34 """
35
36 def __init__(self, _format=None,
37- _control_files=None, a_bzrdir=None, _repository=None,
38- ignore_fallbacks=False):
39+ _control_files=None, a_bzrdir=None, name=None,
40+ _repository=None, ignore_fallbacks=False):
41 """Create new branch object at a particular location."""
42 if a_bzrdir is None:
43 raise ValueError('a_bzrdir must be supplied')
44 else:
45 self.bzrdir = a_bzrdir
46 self._base = self.bzrdir.transport.clone('..').base
47+ self.name = name
48 # XXX: We should be able to just do
49 # self.base = self.bzrdir.root_transport.base
50 # but this does not quite work yet -- mbp 20080522
51@@ -2123,7 +2126,10 @@
52 Branch.__init__(self)
53
54 def __str__(self):
55- return '%s(%r)' % (self.__class__.__name__, self.base)
56+ if self.name is None:
57+ return '%s(%r)' % (self.__class__.__name__, self.base)
58+ else:
59+ return '%s(%r,%r)' % (self.__class__.__name__, self.base, self.name)
60
61 __repr__ = __str__
62