Rev 5085: (Jelmer) Pass colocated branch names further down the call stack. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Mar 11 13:47:09 GMT 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5085 [merge]
revision-id: pqm at pqm.ubuntu.com-20100311134706-kaerqhx3lf7xn6rh
parent: pqm at pqm.ubuntu.com-20100311095645-31r1d2xx0ez23lku
parent: jelmer at samba.org-20100311131437-446uk7f1bc07z11m
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2010-03-11 13:47:06 +0000
message:
(Jelmer) Pass colocated branch names further down the call stack.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/benchmarks/tree_creator/kernel_like.py kernel_like.py-20060815024128-b16a7pn542u6b13k-1
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/bzrdir.py bzrdir.py-20060131065624-156dfea39c4387cb
bzrlib/reconfigure.py reconfigure.py-20070908040425-6ykgo7escxhyrg9p-1
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/tests/blackbox/test_break_lock.py test_break_lock.py-20060303014503-a90e07d38d042d1d
bzrlib/tests/blackbox/test_info.py test_info.py-20060215045507-bbdd2d34efab9e0a
bzrlib/tests/blackbox/test_status.py teststatus.py-20050712014354-508855eb9f29f7dc
bzrlib/tests/blackbox/test_update.py test_update.py-20060212125639-c4dad1a5c56d5919
bzrlib/tests/per_branch/test_branch.py testbranch.py-20050711070244-121d632bc37d7253
bzrlib/tests/per_bzrdir/test_bzrdir.py test_bzrdir.py-20060131065642-0ebeca5e30e30866
bzrlib/tests/per_workingtree/test_workingtree.py test_workingtree.py-20060203003124-817757d3e31444fb
bzrlib/tests/test_branch.py test_branch.py-20060116013032-97819aa07b8ab3b5
bzrlib/tests/test_bzrdir.py test_bzrdir.py-20060131065654-deba40eef51cf220
bzrlib/tests/test_foreign.py test_foreign.py-20081125004048-ywb901edgp9lluxo-1
bzrlib/tests/test_smart.py test_smart.py-20061122024551-ol0l0o0oofsu9b3t-2
bzrlib/workingtree.py workingtree.py-20050511021032-29b6ec0a681e02e3
=== modified file 'NEWS'
--- a/NEWS 2010-03-11 08:41:28 +0000
+++ b/NEWS 2010-03-11 11:07:32 +0000
@@ -30,6 +30,10 @@
``bzrlib.tests.test_server``.
(Vincent Ladeuil)
+* ``BranchReferenceFormat.initialize()`` now takes an optional name argument
+ as its second parameter, for consistency with the initialize() method of
+ other formats. (Jelmer Vernooij)
+
New Features
************
@@ -127,6 +131,12 @@
API Changes
***********
+* ``BranchFormat.initialize`` now takes an optional ``name`` of the colocated
+ branch to create. (Jelmer Vernooij)
+
+* ``BzrDir.get_branch_transport`` now takes an optional ``name`` of the
+ colocated branch to open. (Jelmer Vernooij)
+
* Added ``bzrlib.osutils.set_signal_handler``, a convenience function that
can set a signal handler and call ``signal.siginterrupt(signum,
False)`` for it, if the platform and Python version supports it.
=== modified file 'bzrlib/benchmarks/tree_creator/kernel_like.py'
--- a/bzrlib/benchmarks/tree_creator/kernel_like.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/benchmarks/tree_creator/kernel_like.py 2010-03-02 22:25:58 +0000
@@ -48,7 +48,8 @@
if self._url is not None:
b = bzrdir.BzrDir.create_branch_convenience(self._url)
d = bzrdir.BzrDir.create(root)
- bzrlib.branch.BranchReferenceFormat().initialize(d, b)
+ bzrlib.branch.BranchReferenceFormat().initialize(d,
+ target_branch=b)
tree = d.create_workingtree()
else:
tree = bzrdir.BzrDir.create_standalone_workingtree(root)
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2010-03-02 19:50:18 +0000
+++ b/bzrlib/branch.py 2010-03-06 17:49:26 +0000
@@ -170,10 +170,10 @@
return control.open_branch(unsupported=_unsupported)
@staticmethod
- def open_from_transport(transport, _unsupported=False):
+ def open_from_transport(transport, name=None, _unsupported=False):
"""Open the branch rooted at transport"""
control = bzrdir.BzrDir.open_from_transport(transport, _unsupported)
- return control.open_branch(unsupported=_unsupported)
+ return control.open_branch(name=name, unsupported=_unsupported)
@staticmethod
def open_containing(url, possible_transports=None):
@@ -217,9 +217,9 @@
def _get_fallback_repository(self, url):
"""Get the repository we fallback to at url."""
url = urlutils.join(self.base, url)
- a_bzrdir = bzrdir.BzrDir.open(url,
+ a_branch = Branch.open(url,
possible_transports=[self.bzrdir.root_transport])
- return a_bzrdir.open_branch().repository
+ return a_branch.repository
def _get_tags_bytes(self):
"""Get the bytes of a serialised tags dict.
@@ -1317,7 +1317,8 @@
if lightweight:
format = self._get_checkout_format()
checkout = format.initialize_on_transport(t)
- from_branch = BranchReferenceFormat().initialize(checkout, self)
+ from_branch = BranchReferenceFormat().initialize(checkout,
+ target_branch=self)
else:
format = self._get_checkout_format()
checkout_branch = bzrdir.BzrDir.create_branch_convenience(
@@ -1434,10 +1435,10 @@
return not (self == other)
@classmethod
- def find_format(klass, a_bzrdir):
+ def find_format(klass, a_bzrdir, name=None):
"""Return the format for the branch object in a_bzrdir."""
try:
- transport = a_bzrdir.get_branch_transport(None)
+ transport = a_bzrdir.get_branch_transport(None, name=name)
format_string = transport.get_bytes("format")
return klass._formats[format_string]
except errors.NoSuchFile:
@@ -1483,20 +1484,21 @@
"""Return the short format description for this format."""
raise NotImplementedError(self.get_format_description)
- def _initialize_helper(self, a_bzrdir, utf8_files, lock_type='metadir',
- set_format=True):
+ def _initialize_helper(self, a_bzrdir, utf8_files, name=None,
+ lock_type='metadir', set_format=True):
"""Initialize a branch in a bzrdir, with specified files
:param a_bzrdir: The bzrdir to initialize the branch in
:param utf8_files: The files to create as a list of
(filename, content) tuples
+ :param name: Name of colocated branch to create, if any
:param set_format: If True, set the format with
self.get_format_string. (BzrBranch4 has its format set
elsewhere)
:return: a branch in this format
"""
mutter('creating branch %r in %s', self, a_bzrdir.transport.base)
- branch_transport = a_bzrdir.get_branch_transport(self)
+ branch_transport = a_bzrdir.get_branch_transport(self, name=name)
lock_map = {
'metadir': ('lock', lockdir.LockDir),
'branch4': ('branch-lock', lockable_files.TransportLock),
@@ -1523,10 +1525,13 @@
finally:
if lock_taken:
control_files.unlock()
- return self.open(a_bzrdir, _found=True)
+ return self.open(a_bzrdir, name, _found=True)
- def initialize(self, a_bzrdir):
- """Create a branch of this format in a_bzrdir."""
+ def initialize(self, a_bzrdir, name=None):
+ """Create a branch of this format in a_bzrdir.
+
+ :param name: Name of the colocated branch to create.
+ """
raise NotImplementedError(self.initialize)
def is_supported(self):
@@ -1562,10 +1567,11 @@
"""
raise NotImplementedError(self.network_name)
- def open(self, a_bzrdir, _found=False, ignore_fallbacks=False):
+ def open(self, a_bzrdir, name=None, _found=False, ignore_fallbacks=False):
"""Return the branch object for a_bzrdir
:param a_bzrdir: A BzrDir that contains a branch.
+ :param name: Name of colocated branch to open
:param _found: a private parameter, do not use it. It is used to
indicate if format probing has already be done.
:param ignore_fallbacks: when set, no fallback branches will be opened
@@ -1735,12 +1741,12 @@
"""See BranchFormat.get_format_description()."""
return "Branch format 4"
- def initialize(self, a_bzrdir):
+ def initialize(self, a_bzrdir, name=None):
"""Create a branch of this format in a_bzrdir."""
utf8_files = [('revision-history', ''),
('branch-name', ''),
]
- return self._initialize_helper(a_bzrdir, utf8_files,
+ return self._initialize_helper(a_bzrdir, utf8_files, name=name,
lock_type='branch4', set_format=False)
def __init__(self):
@@ -1751,8 +1757,10 @@
"""The network name for this format is the control dirs disk label."""
return self._matchingbzrdir.get_format_string()
- def open(self, a_bzrdir, _found=False, ignore_fallbacks=False):
+ def open(self, a_bzrdir, name=None, _found=False, ignore_fallbacks=False):
"""See BranchFormat.open()."""
+ if name is not None:
+ raise errors.NoColocatedBranchSupport(a_bzrdir)
if not _found:
# we are being called directly and must probe.
raise NotImplementedError
@@ -1779,15 +1787,15 @@
"""
return self.get_format_string()
- def open(self, a_bzrdir, _found=False, ignore_fallbacks=False):
+ def open(self, a_bzrdir, name=None, _found=False, ignore_fallbacks=False):
"""See BranchFormat.open()."""
if not _found:
- format = BranchFormat.find_format(a_bzrdir)
+ format = BranchFormat.find_format(a_bzrdir, name=name)
if format.__class__ != self.__class__:
raise AssertionError("wrong format %r found for %r" %
(format, self))
try:
- transport = a_bzrdir.get_branch_transport(None)
+ transport = a_bzrdir.get_branch_transport(None, name=name)
control_files = lockable_files.LockableFiles(transport, 'lock',
lockdir.LockDir)
return self._branch_class()(_format=self,
@@ -1831,12 +1839,12 @@
"""See BranchFormat.get_format_description()."""
return "Branch format 5"
- def initialize(self, a_bzrdir):
+ def initialize(self, a_bzrdir, name=None):
"""Create a branch of this format in a_bzrdir."""
utf8_files = [('revision-history', ''),
('branch-name', ''),
]
- return self._initialize_helper(a_bzrdir, utf8_files)
+ return self._initialize_helper(a_bzrdir, utf8_files, name)
def supports_tags(self):
return False
@@ -1864,13 +1872,13 @@
"""See BranchFormat.get_format_description()."""
return "Branch format 6"
- def initialize(self, a_bzrdir):
+ def initialize(self, a_bzrdir, name=None):
"""Create a branch of this format in a_bzrdir."""
utf8_files = [('last-revision', '0 null:\n'),
('branch.conf', ''),
('tags', ''),
]
- return self._initialize_helper(a_bzrdir, utf8_files)
+ return self._initialize_helper(a_bzrdir, utf8_files, name)
def make_tags(self, branch):
"""See bzrlib.branch.BranchFormat.make_tags()."""
@@ -1894,14 +1902,14 @@
"""See BranchFormat.get_format_description()."""
return "Branch format 8"
- def initialize(self, a_bzrdir):
+ def initialize(self, a_bzrdir, name=None):
"""Create a branch of this format in a_bzrdir."""
utf8_files = [('last-revision', '0 null:\n'),
('branch.conf', ''),
('tags', ''),
('references', '')
]
- return self._initialize_helper(a_bzrdir, utf8_files)
+ return self._initialize_helper(a_bzrdir, utf8_files, name)
def __init__(self):
super(BzrBranchFormat8, self).__init__()
@@ -1930,13 +1938,13 @@
This format was introduced in bzr 1.6.
"""
- def initialize(self, a_bzrdir):
+ def initialize(self, a_bzrdir, name=None):
"""Create a branch of this format in a_bzrdir."""
utf8_files = [('last-revision', '0 null:\n'),
('branch.conf', ''),
('tags', ''),
]
- return self._initialize_helper(a_bzrdir, utf8_files)
+ return self._initialize_helper(a_bzrdir, utf8_files, name)
def _branch_class(self):
return BzrBranch7
@@ -1984,19 +1992,19 @@
transport = a_bzrdir.get_branch_transport(None)
location = transport.put_bytes('location', to_branch.base)
- def initialize(self, a_bzrdir, target_branch=None):
+ def initialize(self, a_bzrdir, name=None, target_branch=None):
"""Create a branch of this format in a_bzrdir."""
if target_branch is None:
# this format does not implement branch itself, thus the implicit
# creation contract must see it as uninitializable
raise errors.UninitializableFormat(self)
mutter('creating branch reference in %s', a_bzrdir.transport.base)
- branch_transport = a_bzrdir.get_branch_transport(self)
+ branch_transport = a_bzrdir.get_branch_transport(self, name=name)
branch_transport.put_bytes('location',
target_branch.bzrdir.root_transport.base)
branch_transport.put_bytes('format', self.get_format_string())
return self.open(
- a_bzrdir, _found=True,
+ a_bzrdir, name, _found=True,
possible_transports=[target_branch.bzrdir.root_transport])
def __init__(self):
@@ -2009,17 +2017,18 @@
def clone(to_bzrdir, revision_id=None,
repository_policy=None):
"""See Branch.clone()."""
- return format.initialize(to_bzrdir, a_branch)
+ return format.initialize(to_bzrdir, target_branch=a_branch)
# cannot obey revision_id limits when cloning a reference ...
# FIXME RBC 20060210 either nuke revision_id for clone, or
# emit some sort of warning/error to the caller ?!
return clone
- def open(self, a_bzrdir, _found=False, location=None,
+ def open(self, a_bzrdir, name=None, _found=False, location=None,
possible_transports=None, ignore_fallbacks=False):
"""Return the branch that the branch reference in a_bzrdir points at.
:param a_bzrdir: A BzrDir that contains a branch.
+ :param name: Name of colocated branch to open, if any
:param _found: a private parameter, do not use it. It is used to
indicate if format probing has already be done.
:param ignore_fallbacks: when set, no fallback branches will be opened
@@ -2030,7 +2039,7 @@
:param possible_transports: An optional reusable transports list.
"""
if not _found:
- format = BranchFormat.find_format(a_bzrdir)
+ format = BranchFormat.find_format(a_bzrdir, name=name)
if format.__class__ != self.__class__:
raise AssertionError("wrong format %r found for %r" %
(format, self))
@@ -2038,7 +2047,8 @@
location = self.get_reference(a_bzrdir)
real_bzrdir = bzrdir.BzrDir.open(
location, possible_transports=possible_transports)
- result = real_bzrdir.open_branch(ignore_fallbacks=ignore_fallbacks)
+ result = real_bzrdir.open_branch(name=name,
+ ignore_fallbacks=ignore_fallbacks)
# this changes the behaviour of result.clone to create a new reference
# rather than a copy of the content of the branch.
# I did not use a proxy object because that needs much more extensive
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py 2010-03-05 23:17:03 +0000
+++ b/bzrlib/bzrdir.py 2010-03-11 11:07:32 +0000
@@ -715,7 +715,7 @@
"""
return None
- def get_branch_transport(self, branch_format):
+ def get_branch_transport(self, branch_format, name=None):
"""Get the transport for use by branch format in this BzrDir.
Note that bzr dirs that do not support format strings will raise
@@ -1383,9 +1383,7 @@
def create_branch(self, name=None):
"""See BzrDir.create_branch."""
- if name is not None:
- raise errors.NoColocatedBranchSupport(self)
- return self._format.get_branch_format().initialize(self)
+ return self._format.get_branch_format().initialize(self, name=name)
def destroy_branch(self, name=None):
"""See BzrDir.destroy_branch."""
@@ -1449,8 +1447,10 @@
raise errors.UnsupportedOperation(self.destroy_workingtree_metadata,
self)
- def get_branch_transport(self, branch_format):
+ def get_branch_transport(self, branch_format, name=None):
"""See BzrDir.get_branch_transport()."""
+ if name is not None:
+ raise errors.NoColocatedBranchSupport(self)
if branch_format is None:
return self.transport
try:
@@ -1492,12 +1492,10 @@
def open_branch(self, name=None, unsupported=False,
ignore_fallbacks=False):
"""See BzrDir.open_branch."""
- if name is not None:
- raise errors.NoColocatedBranchSupport(self)
from bzrlib.branch import BzrBranchFormat4
format = BzrBranchFormat4()
self._check_supported(format, unsupported)
- return format.open(self, _found=True)
+ return format.open(self, name, _found=True)
def sprout(self, url, revision_id=None, force_new_repo=False,
possible_transports=None, accelerator_tree=None,
@@ -1622,9 +1620,7 @@
def create_branch(self, name=None):
"""See BzrDir.create_branch."""
- if name is not None:
- raise errors.NoColocatedBranchSupport(self)
- return self._format.get_branch_format().initialize(self)
+ return self._format.get_branch_format().initialize(self, name=name)
def destroy_branch(self, name=None):
"""See BzrDir.create_branch."""
@@ -1678,8 +1674,10 @@
format = BranchFormat.find_format(self)
return format.get_reference(self)
- def get_branch_transport(self, branch_format):
+ def get_branch_transport(self, branch_format, name=None):
"""See BzrDir.get_branch_transport()."""
+ if name is not None:
+ raise errors.NoColocatedBranchSupport(self)
# XXX: this shouldn't implicitly create the directory if it's just
# promising to get a transport -- mbp 20090727
if branch_format is None:
@@ -1774,11 +1772,10 @@
def open_branch(self, name=None, unsupported=False,
ignore_fallbacks=False):
"""See BzrDir.open_branch."""
- if name is not None:
- raise errors.NoColocatedBranchSupport(self)
format = self.find_branch_format()
self._check_supported(format, unsupported)
- return format.open(self, _found=True, ignore_fallbacks=ignore_fallbacks)
+ return format.open(self, name=name,
+ _found=True, ignore_fallbacks=ignore_fallbacks)
def open_repository(self, unsupported=False):
"""See BzrDir.open_repository."""
=== modified file 'bzrlib/reconfigure.py'
--- a/bzrlib/reconfigure.py 2009-10-06 14:40:37 +0000
+++ b/bzrlib/reconfigure.py 2010-03-02 22:25:58 +0000
@@ -368,7 +368,7 @@
local_branch = self.local_branch
if self._create_reference:
format = branch.BranchReferenceFormat().initialize(self.bzrdir,
- reference_branch)
+ target_branch=reference_branch)
if self._destroy_tree:
self.bzrdir.destroy_workingtree()
if self._create_tree:
=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py 2010-03-09 23:48:40 +0000
+++ b/bzrlib/remote.py 2010-03-11 11:07:32 +0000
@@ -243,13 +243,13 @@
self._real_bzrdir.destroy_repository()
def create_branch(self, name=None):
- if name is not None:
- raise errors.NoColocatedBranchSupport(self)
# as per meta1 formats - just delegate to the format object which may
# be parameterised.
- real_branch = self._format.get_branch_format().initialize(self)
+ real_branch = self._format.get_branch_format().initialize(self,
+ name=name)
if not isinstance(real_branch, RemoteBranch):
- result = RemoteBranch(self, self.find_repository(), real_branch)
+ result = RemoteBranch(self, self.find_repository(), real_branch,
+ name=name)
else:
result = real_branch
# BzrDir.clone_on_transport() uses the result of create_branch but does
@@ -324,8 +324,6 @@
ignore_fallbacks=False):
if unsupported:
raise NotImplementedError('unsupported flag support not implemented yet.')
- if name is not None:
- raise errors.NoColocatedBranchSupport(self)
if self._next_open_branch_result is not None:
# See create_branch for details.
result = self._next_open_branch_result
@@ -335,14 +333,14 @@
if response[0] == 'ref':
# a branch reference, use the existing BranchReference logic.
format = BranchReferenceFormat()
- return format.open(self, _found=True, location=response[1],
- ignore_fallbacks=ignore_fallbacks)
+ return format.open(self, name=name, _found=True,
+ location=response[1], ignore_fallbacks=ignore_fallbacks)
branch_format_name = response[1]
if not branch_format_name:
branch_format_name = None
format = RemoteBranchFormat(network_name=branch_format_name)
return RemoteBranch(self, self.find_repository(), format=format,
- setup_stacking=not ignore_fallbacks)
+ setup_stacking=not ignore_fallbacks, name=name)
def _open_repo_v1(self, path):
verb = 'BzrDir.find_repository'
@@ -425,9 +423,9 @@
"""Return the path to be used for this bzrdir in a remote call."""
return client.remote_path_from_transport(self.root_transport)
- def get_branch_transport(self, branch_format):
+ def get_branch_transport(self, branch_format, name=None):
self._ensure_real()
- return self._real_bzrdir.get_branch_transport(branch_format)
+ return self._real_bzrdir.get_branch_transport(branch_format, name=name)
def get_repository_transport(self, repository_format):
self._ensure_real()
@@ -2027,26 +2025,29 @@
def network_name(self):
return self._network_name
- def open(self, a_bzrdir, ignore_fallbacks=False):
- return a_bzrdir.open_branch(ignore_fallbacks=ignore_fallbacks)
+ def open(self, a_bzrdir, name=None, ignore_fallbacks=False):
+ return a_bzrdir.open_branch(name=name,
+ ignore_fallbacks=ignore_fallbacks)
- def _vfs_initialize(self, a_bzrdir):
+ def _vfs_initialize(self, a_bzrdir, name):
# Initialisation when using a local bzrdir object, or a non-vfs init
# method is not available on the server.
# self._custom_format is always set - the start of initialize ensures
# that.
if isinstance(a_bzrdir, RemoteBzrDir):
a_bzrdir._ensure_real()
- result = self._custom_format.initialize(a_bzrdir._real_bzrdir)
+ result = self._custom_format.initialize(a_bzrdir._real_bzrdir,
+ name)
else:
# We assume the bzrdir is parameterised; it may not be.
- result = self._custom_format.initialize(a_bzrdir)
+ result = self._custom_format.initialize(a_bzrdir, name)
if (isinstance(a_bzrdir, RemoteBzrDir) and
not isinstance(result, RemoteBranch)):
- result = RemoteBranch(a_bzrdir, a_bzrdir.find_repository(), result)
+ result = RemoteBranch(a_bzrdir, a_bzrdir.find_repository(), result,
+ name=name)
return result
- def initialize(self, a_bzrdir):
+ def initialize(self, a_bzrdir, name=None):
# 1) get the network name to use.
if self._custom_format:
network_name = self._custom_format.network_name()
@@ -2058,20 +2059,23 @@
network_name = reference_format.network_name()
# Being asked to create on a non RemoteBzrDir:
if not isinstance(a_bzrdir, RemoteBzrDir):
- return self._vfs_initialize(a_bzrdir)
+ return self._vfs_initialize(a_bzrdir, name=name)
medium = a_bzrdir._client._medium
if medium._is_remote_before((1, 13)):
- return self._vfs_initialize(a_bzrdir)
+ return self._vfs_initialize(a_bzrdir, name=name)
# Creating on a remote bzr dir.
# 2) try direct creation via RPC
path = a_bzrdir._path_for_remote_call(a_bzrdir._client)
+ if name is not None:
+ # XXX JRV20100304: Support creating colocated branches
+ raise errors.NoColocatedBranchSupport(self)
verb = 'BzrDir.create_branch'
try:
response = a_bzrdir._call(verb, path, network_name)
except errors.UnknownSmartMethod:
# Fallback - use vfs methods
medium._remember_remote_is_before((1, 13))
- return self._vfs_initialize(a_bzrdir)
+ return self._vfs_initialize(a_bzrdir, name=name)
if response[0] != 'ok':
raise errors.UnexpectedSmartServerResponse(response)
# Turn the response into a RemoteRepository object.
@@ -2085,7 +2089,7 @@
a_bzrdir._client)
remote_repo = RemoteRepository(repo_bzrdir, repo_format)
remote_branch = RemoteBranch(a_bzrdir, remote_repo,
- format=format, setup_stacking=False)
+ format=format, setup_stacking=False, name=name)
# XXX: We know this is a new branch, so it must have revno 0, revid
# NULL_REVISION. Creating the branch locked would make this be unable
# to be wrong; here its simply very unlikely to be wrong. RBC 20090225
@@ -2118,7 +2122,7 @@
"""
def __init__(self, remote_bzrdir, remote_repository, real_branch=None,
- _client=None, format=None, setup_stacking=True):
+ _client=None, format=None, setup_stacking=True, name=None):
"""Create a RemoteBranch instance.
:param real_branch: An optional local implementation of the branch
@@ -2130,6 +2134,7 @@
:param setup_stacking: If True make an RPC call to determine the
stacked (or not) status of the branch. If False assume the branch
is not stacked.
+ :param name: Colocated branch name
"""
# We intentionally don't call the parent class's __init__, because it
# will try to assign to self.tags, which is a property in this subclass.
@@ -2155,6 +2160,7 @@
# Fill out expected attributes of branch for bzrlib API users.
self._clear_cached_state()
self.base = self.bzrdir.root_transport.base
+ self._name = name
self._control_files = None
self._lock_mode = None
self._lock_token = None
@@ -2225,7 +2231,7 @@
'to use vfs implementation')
self.bzrdir._ensure_real()
self._real_branch = self.bzrdir._real_bzrdir.open_branch(
- ignore_fallbacks=self._real_ignore_fallbacks)
+ ignore_fallbacks=self._real_ignore_fallbacks, name=self._name)
if self.repository._real_repository is None:
# Give the remote repository the matching real repo.
real_repo = self._real_branch.repository
=== modified file 'bzrlib/tests/blackbox/test_break_lock.py'
--- a/bzrlib/tests/blackbox/test_break_lock.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/blackbox/test_break_lock.py 2010-03-02 22:25:58 +0000
@@ -60,7 +60,7 @@
local_branch.bind(self.master_branch)
checkoutdir = bzrlib.bzrdir.BzrDir.create('checkout')
bzrlib.branch.BranchReferenceFormat().initialize(
- checkoutdir, local_branch)
+ checkoutdir, target_branch=local_branch)
self.wt = checkoutdir.create_workingtree()
def test_break_lock_help(self):
=== modified file 'bzrlib/tests/blackbox/test_info.py'
--- a/bzrlib/tests/blackbox/test_info.py 2010-02-23 07:43:11 +0000
+++ b/bzrlib/tests/blackbox/test_info.py 2010-03-02 22:25:58 +0000
@@ -1228,7 +1228,8 @@
# Do a light checkout of the heavy one
transport.mkdir('tree/lightcheckout')
lco_dir = bzrdir.BzrDirMetaFormat1().initialize('tree/lightcheckout')
- branch.BranchReferenceFormat().initialize(lco_dir, co_branch)
+ branch.BranchReferenceFormat().initialize(lco_dir,
+ target_branch=co_branch)
lco_dir.create_workingtree()
lco_tree = lco_dir.open_workingtree()
=== modified file 'bzrlib/tests/blackbox/test_status.py'
--- a/bzrlib/tests/blackbox/test_status.py 2009-07-08 14:37:25 +0000
+++ b/bzrlib/tests/blackbox/test_status.py 2010-03-02 22:25:58 +0000
@@ -498,7 +498,8 @@
def make_branch_and_tree(self, relpath):
source = self.make_branch(pathjoin('..', relpath))
checkout = bzrdir.BzrDirMetaFormat1().initialize(relpath)
- bzrlib.branch.BranchReferenceFormat().initialize(checkout, source)
+ bzrlib.branch.BranchReferenceFormat().initialize(checkout,
+ target_branch=source)
return checkout.create_workingtree()
=== modified file 'bzrlib/tests/blackbox/test_update.py'
--- a/bzrlib/tests/blackbox/test_update.py 2010-03-05 08:55:12 +0000
+++ b/bzrlib/tests/blackbox/test_update.py 2010-03-11 11:07:32 +0000
@@ -195,7 +195,8 @@
self.build_tree(['checkout1/'])
checkout_dir = bzrdir.BzrDirMetaFormat1().initialize('checkout1')
- branch.BranchReferenceFormat().initialize(checkout_dir, master.branch)
+ branch.BranchReferenceFormat().initialize(checkout_dir,
+ target_branch=master.branch)
checkout1 = checkout_dir.create_workingtree('m1')
# Create a second branch, with an extra commit
=== modified file 'bzrlib/tests/per_branch/test_branch.py'
--- a/bzrlib/tests/per_branch/test_branch.py 2010-02-11 09:27:55 +0000
+++ b/bzrlib/tests/per_branch/test_branch.py 2010-03-02 22:25:58 +0000
@@ -379,6 +379,23 @@
self.assertEqual(committed.properties["branch-nick"],
"My happy branch")
+ def test_create_colocated(self):
+ try:
+ repo = self.make_repository('.', shared=True)
+ except errors.IncompatibleFormat:
+ return
+ self.assertEquals(0, len(repo.bzrdir.list_branches()))
+ try:
+ child_branch1 = self.branch_format.initialize(repo.bzrdir,
+ name='branch1')
+ except (errors.UninitializableFormat, errors.NoColocatedBranchSupport):
+ # branch references are not default init'able and
+ # not all bzrdirs support colocated branches.
+ return
+ self.assertEquals(1, len(repo.bzrdir.list_branches()))
+ self.branch_format.initialize(repo.bzrdir, name='branch2')
+ self.assertEquals(2, len(repo.bzrdir.list_branches()))
+
def test_create_open_branch_uses_repository(self):
try:
repo = self.make_repository('.', shared=True)
=== modified file 'bzrlib/tests/per_bzrdir/test_bzrdir.py'
--- a/bzrlib/tests/per_bzrdir/test_bzrdir.py 2010-03-02 19:50:18 +0000
+++ b/bzrlib/tests/per_bzrdir/test_bzrdir.py 2010-03-02 22:25:58 +0000
@@ -534,7 +534,7 @@
dir = self.make_bzrdir('source')
try:
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
- referenced_branch)
+ target_branch=referenced_branch)
except errors.IncompatibleFormat:
# this is ok too, not all formats have to support references.
return
@@ -637,7 +637,7 @@
dir = self.make_bzrdir('source')
try:
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
- referenced_branch)
+ target_branch=referenced_branch)
except errors.IncompatibleFormat:
# this is ok too, not all formats have to support references.
return
@@ -702,7 +702,7 @@
dir = self.make_bzrdir('source')
try:
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
- referenced_branch)
+ target_branch=referenced_branch)
except errors.IncompatibleFormat:
# this is ok too, not all formats have to support references.
return
@@ -977,7 +977,7 @@
dir = self.make_bzrdir('source')
try:
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
- referenced_branch)
+ target_branch=referenced_branch)
except errors.IncompatibleFormat:
# this is ok too, not all formats have to support references.
return
@@ -997,7 +997,7 @@
dir = self.make_bzrdir('source')
try:
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
- referenced_tree.branch)
+ target_branch=referenced_tree.branch)
except errors.IncompatibleFormat:
# this is ok too, not all formats have to support references.
return
@@ -1023,7 +1023,7 @@
dir = self.make_bzrdir('source')
try:
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
- referenced_tree.branch)
+ target_branch=referenced_tree.branch)
except errors.IncompatibleFormat:
# this is ok too, not all formats have to support references.
return
@@ -1088,7 +1088,7 @@
dir = self.make_bzrdir('source')
try:
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
- referenced_branch)
+ target_branch=referenced_branch)
except errors.IncompatibleFormat:
# this is ok too, not all formats have to support references.
return
@@ -1114,7 +1114,7 @@
dir = self.make_bzrdir('source')
try:
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
- referenced_branch)
+ target_branch=referenced_branch)
except errors.IncompatibleFormat:
# this is ok too, not all formats have to support references.
return
@@ -1886,7 +1886,7 @@
thisdir = self.make_bzrdir('this')
try:
bzrlib.branch.BranchReferenceFormat().initialize(
- thisdir, master)
+ thisdir, target_branch=master)
except errors.IncompatibleFormat:
return
unused_repo = thisdir.create_repository()
=== modified file 'bzrlib/tests/per_workingtree/test_workingtree.py'
--- a/bzrlib/tests/per_workingtree/test_workingtree.py 2010-02-13 01:50:29 +0000
+++ b/bzrlib/tests/per_workingtree/test_workingtree.py 2010-03-02 22:25:58 +0000
@@ -423,7 +423,8 @@
made_control = self.bzrdir_format.initialize('new')
source.branch.repository.clone(made_control)
source.branch.clone(made_control)
- made_tree = self.workingtree_format.initialize(made_control, revision_id='a')
+ made_tree = self.workingtree_format.initialize(made_control,
+ revision_id='a')
self.assertEqual(['a'], made_tree.get_parent_ids())
def test_update_sets_last_revision(self):
@@ -447,7 +448,8 @@
# current format
self.build_tree(['checkout/', 'tree/file'])
checkout = bzrdir.BzrDirMetaFormat1().initialize('checkout')
- branch.BranchReferenceFormat().initialize(checkout, main_branch)
+ branch.BranchReferenceFormat().initialize(checkout,
+ target_branch=main_branch)
old_tree = self.workingtree_format.initialize(checkout)
# now commit to 'tree'
wt.add('file')
@@ -514,7 +516,8 @@
# current format
self.build_tree(['checkout/', 'tree/file'])
checkout = bzrdir.BzrDirMetaFormat1().initialize('checkout')
- branch.BranchReferenceFormat().initialize(checkout, main_branch)
+ branch.BranchReferenceFormat().initialize(checkout,
+ target_branch=main_branch)
old_tree = self.workingtree_format.initialize(checkout)
# now commit to 'tree'
wt.add('file')
=== modified file 'bzrlib/tests/test_branch.py'
--- a/bzrlib/tests/test_branch.py 2010-02-10 17:52:08 +0000
+++ b/bzrlib/tests/test_branch.py 2010-03-11 13:14:37 +0000
@@ -123,16 +123,16 @@
"""See BzrBranchFormat.get_format_string()."""
return "Sample branch format."
- def initialize(self, a_bzrdir):
+ def initialize(self, a_bzrdir, name=None):
"""Format 4 branches cannot be created."""
- t = a_bzrdir.get_branch_transport(self)
+ t = a_bzrdir.get_branch_transport(self, name=name)
t.put_bytes('format', self.get_format_string())
return 'A branch'
def is_supported(self):
return False
- def open(self, transport, _found=False, ignore_fallbacks=False):
+ def open(self, transport, name=None, _found=False, ignore_fallbacks=False):
return "opened branch."
@@ -438,7 +438,7 @@
t.mkdir('branch')
branch_dir = bzrdirformat.initialize(self.get_url('branch'))
made_branch = _mod_branch.BranchReferenceFormat().initialize(
- branch_dir, target_branch)
+ branch_dir, target_branch=target_branch)
self.assertEqual(made_branch.base, target_branch.base)
opened_branch = branch_dir.open_branch()
self.assertEqual(opened_branch.base, target_branch.base)
=== modified file 'bzrlib/tests/test_bzrdir.py'
--- a/bzrlib/tests/test_bzrdir.py 2010-03-02 19:50:18 +0000
+++ b/bzrlib/tests/test_bzrdir.py 2010-03-02 22:25:58 +0000
@@ -471,7 +471,8 @@
# Make stackable source branch with an unstackable repo format.
source_bzrdir = self.make_bzrdir('source')
pack_repo.RepositoryFormatKnitPack1().initialize(source_bzrdir)
- source_branch = bzrlib.branch.BzrBranchFormat7().initialize(source_bzrdir)
+ source_branch = bzrlib.branch.BzrBranchFormat7().initialize(
+ source_bzrdir)
# Make a directory with a default stacking policy
parent_bzrdir = self.make_bzrdir('parent')
stacked_on = self.make_branch('parent/stacked-on', format='pack-0.92')
=== modified file 'bzrlib/tests/test_foreign.py'
--- a/bzrlib/tests/test_foreign.py 2010-03-02 19:50:18 +0000
+++ b/bzrlib/tests/test_foreign.py 2010-03-02 22:25:58 +0000
@@ -171,11 +171,11 @@
super(DummyForeignVcsBranchFormat, self).__init__()
self._matchingbzrdir = DummyForeignVcsDirFormat()
- def open(self, a_bzrdir, _found=False):
+ def open(self, a_bzrdir, name=None, _found=False):
if not _found:
raise NotImplementedError
try:
- transport = a_bzrdir.get_branch_transport(None)
+ transport = a_bzrdir.get_branch_transport(None, name=name)
control_files = lockable_files.LockableFiles(transport, 'lock',
lockdir.LockDir)
return DummyForeignVcsBranch(_format=self,
=== modified file 'bzrlib/tests/test_smart.py'
--- a/bzrlib/tests/test_smart.py 2010-02-23 07:43:11 +0000
+++ b/bzrlib/tests/test_smart.py 2010-03-02 22:25:58 +0000
@@ -214,7 +214,7 @@
dir = self.make_bzrdir('.')
local_result = dir.cloning_metadir()
reference = _mod_branch.BranchReferenceFormat().initialize(
- dir, referenced_branch)
+ dir, target_branch=referenced_branch)
reference_url = _mod_branch.BranchReferenceFormat().get_reference(dir)
# The server shouldn't try to follow the branch reference, so it's fine
# if the referenced branch isn't reachable.
=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py 2010-02-10 15:46:03 +0000
+++ b/bzrlib/workingtree.py 2010-03-02 22:25:58 +0000
@@ -1094,7 +1094,8 @@
tree_transport = self.bzrdir.root_transport.clone(sub_path)
if tree_transport.base != branch_transport.base:
tree_bzrdir = format.initialize_on_transport(tree_transport)
- branch.BranchReferenceFormat().initialize(tree_bzrdir, new_branch)
+ branch.BranchReferenceFormat().initialize(tree_bzrdir,
+ target_branch=new_branch)
else:
tree_bzrdir = branch_bzrdir
wt = tree_bzrdir.create_workingtree(_mod_revision.NULL_REVISION)
More information about the bazaar-commits
mailing list