本文整理汇总了Python中bzrlib.bzrdir.BzrDir.open_from_transport方法的典型用法代码示例。如果您正苦于以下问题:Python BzrDir.open_from_transport方法的具体用法?Python BzrDir.open_from_transport怎么用?Python BzrDir.open_from_transport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bzrlib.bzrdir.BzrDir
的用法示例。
在下文中一共展示了BzrDir.open_from_transport方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do
# 需要导入模块: from bzrlib.bzrdir import BzrDir [as 别名]
# 或者: from bzrlib.bzrdir.BzrDir import open_from_transport [as 别名]
def do(self, path, network_name, shared):
"""Create a repository in the bzr dir at path.
This operates precisely like 'bzrdir.create_repository'.
If a bzrdir is not present, an exception is propagated
rather than 'no branch' because these are different conditions (and
this method should only be called after establishing that a bzr dir
exists anyway).
This is the initial version of this method introduced to the smart
server for 1.13.
:param path: The path to the bzrdir.
:param network_name: The network name of the repository type to create.
:param shared: The value to pass create_repository for the shared
parameter.
:return: (ok, rich_root, tree_ref, external_lookup, network_name)
"""
bzrdir = BzrDir.open_from_transport(
self.transport_from_client_path(path))
shared = shared == 'True'
format = repository.network_format_registry.get(network_name)
bzrdir.repository_format = format
result = format.initialize(bzrdir, shared=shared)
rich_root, tree_ref, external_lookup = self._format_to_capabilities(
result._format)
return SuccessfulSmartServerResponse(('ok', rich_root, tree_ref,
external_lookup, result._format.network_name()))
示例2: _find
# 需要导入模块: from bzrlib.bzrdir import BzrDir [as 别名]
# 或者: from bzrlib.bzrdir.BzrDir import open_from_transport [as 别名]
def _find(self, path):
"""try to find a repository from path upwards
This operates precisely like 'bzrdir.find_repository'.
:return: (relpath, rich_root, tree_ref, external_lookup) flags. All are
strings, relpath is a / prefixed path, and the other three are
either 'yes' or 'no'.
:raises errors.NoRepositoryPresent: When there is no repository
present.
"""
bzrdir = BzrDir.open_from_transport(
self.transport_from_client_path(path))
repository = bzrdir.find_repository()
# the relpath of the bzrdir in the found repository gives us the
# path segments to pop-out.
relpath = repository.bzrdir.root_transport.relpath(
bzrdir.root_transport.base)
if len(relpath):
segments = ['..'] * len(relpath.split('/'))
else:
segments = []
rich_root = self._boolean_to_yes_no(repository.supports_rich_root())
tree_ref = self._boolean_to_yes_no(
repository._format.supports_tree_reference)
external_lookup = self._boolean_to_yes_no(
repository._format.supports_external_lookups)
return '/'.join(segments), rich_root, tree_ref, external_lookup
示例3: test_bzr_serve_inet_readwrite
# 需要导入模块: from bzrlib.bzrdir import BzrDir [as 别名]
# 或者: from bzrlib.bzrdir.BzrDir import open_from_transport [as 别名]
def test_bzr_serve_inet_readwrite(self):
# Make a branch
self.make_branch('.')
process, transport = self.start_server_inet(['--allow-writes'])
# We get a working branch
branch = BzrDir.open_from_transport(transport).open_branch()
self.make_read_requests(branch)
self.assertInetServerShutsdownCleanly(process)
示例4: test_commit_readonly_checkout
# 需要导入模块: from bzrlib.bzrdir import BzrDir [as 别名]
# 或者: from bzrlib.bzrdir.BzrDir import open_from_transport [as 别名]
def test_commit_readonly_checkout(self):
# https://bugs.edge.launchpad.net/bzr/+bug/129701
# "UnlockableTransport error trying to commit in checkout of readonly
# branch"
self.make_branch('master')
master = BzrDir.open_from_transport(
self.get_readonly_transport('master')).open_branch()
master.create_checkout('checkout')
out, err = self.run_bzr(['commit', '--unchanged', '-mfoo', 'checkout'],
retcode=3)
self.assertContainsRe(err,
r'^bzr: ERROR: Cannot lock.*readonly transport')
示例5: test_can_open_product_control_dir
# 需要导入模块: from bzrlib.bzrdir import BzrDir [as 别名]
# 或者: from bzrlib.bzrdir.BzrDir import open_from_transport [as 别名]
def test_can_open_product_control_dir(self):
# The stacking policy lives in a bzrdir in the product directory.
# Bazaar needs to be able to open this bzrdir.
product = self.factory.makeProduct()
self.factory.enableDefaultStackingForProduct(product)
transport = self.getTransport().clone(
'~%s/%s' % (self.requester.name, product.name))
found_bzrdir = BzrDir.open_from_transport(transport)
# We really just want to test that the above line doesn't raise an
# exception. However, we'll also check that we get the bzrdir that we
# expected.
expected_url = transport.clone('.bzr').base
self.assertEqual(expected_url, found_bzrdir.transport.base)
示例6: got_path_info
# 需要导入模块: from bzrlib.bzrdir import BzrDir [as 别名]
# 或者: from bzrlib.bzrdir.BzrDir import open_from_transport [as 别名]
def got_path_info((transport_type, data, trailing_path)):
if transport_type != BRANCH_TRANSPORT:
raise NotABranchPath(virtual_url_fragment)
transport, _ = self._transport_dispatch.makeTransport((transport_type, data, trailing_path))
if jail_info.transports:
jail_info.transports.append(transport)
try:
branch = BzrDir.open_from_transport(transport).open_branch(ignore_fallbacks=True)
info = get_branch_info(branch)
info["stacked_on_url"] = self._normalize_stacked_on_url(branch)
finally:
if jail_info.transports:
jail_info.transports.remove(transport)
if info["stacked_on_url"] is None:
info["stacked_on_url"] = ""
return self._branchfs_client.branchChanged(data["id"], **info)
示例7: do
# 需要导入模块: from bzrlib.bzrdir import BzrDir [as 别名]
# 或者: from bzrlib.bzrdir.BzrDir import open_from_transport [as 别名]
def do(self, path):
"""try to open a branch at path and return ok/nobranch.
If a bzrdir is not present, an exception is propogated
rather than 'no branch' because these are different conditions.
"""
bzrdir = BzrDir.open_from_transport(
self.transport_from_client_path(path))
try:
reference_url = bzrdir.get_branch_reference()
if reference_url is None:
return SuccessfulSmartServerResponse(('ok', ''))
else:
return SuccessfulSmartServerResponse(('ok', reference_url))
except errors.NotBranchError:
return FailedSmartServerResponse(('nobranch', ))
示例8: do
# 需要导入模块: from bzrlib.bzrdir import BzrDir [as 别名]
# 或者: from bzrlib.bzrdir.BzrDir import open_from_transport [as 别名]
def do(self, path, *args):
"""Execute a request for a branch at path.
All Branch requests take a path to the branch as their first argument.
If the branch is a branch reference, NotBranchError is raised.
:param path: The path for the repository as received from the
client.
:return: A SmartServerResponse from self.do_with_branch().
"""
transport = self.transport_from_client_path(path)
bzrdir = BzrDir.open_from_transport(transport)
if bzrdir.get_branch_reference() is not None:
raise errors.NotBranchError(transport.base)
branch = bzrdir.open_branch()
return self.do_with_branch(branch, *args)
示例9: do
# 需要导入模块: from bzrlib.bzrdir import BzrDir [as 别名]
# 或者: from bzrlib.bzrdir.BzrDir import open_from_transport [as 别名]
def do(self, path, *args):
"""Execute a repository request.
All Repository requests take a path to the repository as their first
argument. The repository must be at the exact path given by the
client - no searching is done.
The actual logic is delegated to self.do_repository_request.
:param client_path: The path for the repository as received from the
client.
:return: A SmartServerResponse from self.do_repository_request().
"""
transport = self.transport_from_client_path(path)
bzrdir = BzrDir.open_from_transport(transport)
# Save the repository for use with do_body.
self._repository = bzrdir.open_repository()
return self.do_repository_request(self._repository, *args)
示例10: _find
# 需要导入模块: from bzrlib.bzrdir import BzrDir [as 别名]
# 或者: from bzrlib.bzrdir.BzrDir import open_from_transport [as 别名]
def _find(self, path):
"""try to find a repository from path upwards
This operates precisely like 'bzrdir.find_repository'.
:return: (relpath, rich_root, tree_ref, external_lookup, network_name).
All are strings, relpath is a / prefixed path, the next three are
either 'yes' or 'no', and the last is a repository format network
name.
:raises errors.NoRepositoryPresent: When there is no repository
present.
"""
bzrdir = BzrDir.open_from_transport(
self.transport_from_client_path(path))
repository = bzrdir.find_repository()
path = self._repo_relpath(bzrdir.root_transport, repository)
rich_root, tree_ref, external_lookup = self._format_to_capabilities(
repository._format)
network_name = repository._format.network_name()
return path, rich_root, tree_ref, external_lookup, network_name
示例11: pull
# 需要导入模块: from bzrlib.bzrdir import BzrDir [as 别名]
# 或者: from bzrlib.bzrdir.BzrDir import open_from_transport [as 别名]
def pull(self, db_branch_id, target_path, required_format,
needs_tree=False, stacked_on_url=None):
"""Pull down the Bazaar branch of an import to `target_path`.
:return: A Bazaar branch for the code import corresponding to the
database branch with id `db_branch_id`.
"""
remote_url = self._getMirrorURL(db_branch_id)
try:
remote_bzr_dir = BzrDir.open(remote_url)
except NotBranchError:
local_branch = BzrDir.create_branch_and_repo(
target_path, format=required_format)
if needs_tree:
local_branch.bzrdir.create_workingtree()
if stacked_on_url:
local_branch.set_stacked_on_url(stacked_on_url)
return local_branch
# The proper thing to do here would be to call
# "remote_bzr_dir.sprout()". But 2a fetch slowly checks which
# revisions are in the ancestry of the tip of the remote branch, which
# we strictly don't care about, so we just copy the whole thing down
# at the vfs level.
control_dir = remote_bzr_dir.root_transport.relpath(
remote_bzr_dir.transport.abspath('.'))
target = get_transport_from_path(target_path)
target_control = target.clone(control_dir)
target_control.create_prefix()
remote_bzr_dir.transport.copy_tree_to_transport(target_control)
local_bzr_dir = BzrDir.open_from_transport(target)
if local_bzr_dir.needs_format_conversion(format=required_format):
try:
local_bzr_dir.root_transport.delete_tree('backup.bzr')
except NoSuchFile:
pass
upgrade(target_path, required_format, clean_up=True)
if needs_tree:
local_bzr_dir.create_workingtree()
return local_bzr_dir.open_branch()
示例12: readonly_repository
# 需要导入模块: from bzrlib.bzrdir import BzrDir [as 别名]
# 或者: from bzrlib.bzrdir.BzrDir import open_from_transport [as 别名]
def readonly_repository(self, relpath):
return BzrDir.open_from_transport(
self.get_readonly_transport(relpath)).open_repository()
示例13: t
# 需要导入模块: from bzrlib.bzrdir import BzrDir [as 别名]
# 或者: from bzrlib.bzrdir.BzrDir import open_from_transport [as 别名]
def t():
BzrDir.open_from_transport(transport)
thread_result.append('ok')