209
233
errors.UnstackableRepositoryFormat,
210
234
errors.NotStacked):
236
# Bug: We create a metadir without knowing if it can support stacking,
237
# we should look up the policy needs first, or just use it as a hint,
214
# may need to copy content in
215
repository_policy = result.determine_repository_policy(
216
force_new_repo, stacked_on, self.root_transport.base,
217
require_stacking=require_stacking)
218
240
make_working_trees = local_repo.make_working_trees()
219
result_repo = repository_policy.acquire_repository(
220
make_working_trees, local_repo.is_shared())
221
if not require_stacking and repository_policy._require_stacking:
222
require_stacking = True
223
result._format.require_stacking()
224
result_repo.fetch(local_repo, revision_id=revision_id)
241
want_shared = local_repo.is_shared()
242
repo_format_name = format.repository_format.network_name()
244
make_working_trees = False
246
repo_format_name = None
248
result_repo, result, require_stacking, repository_policy = \
249
format.initialize_on_transport_ex(transport,
250
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
251
force_new_repo=force_new_repo, stacked_on=stacked_on,
252
stack_on_pwd=self.root_transport.base,
253
repo_format_name=repo_format_name,
254
make_working_trees=make_working_trees, shared_repo=want_shared)
257
# If the result repository is in the same place as the
258
# resulting bzr dir, it will have no content, further if the
259
# result is not stacked then we know all content should be
260
# copied, and finally if we are copying up to a specific
261
# revision_id then we can use the pending-ancestry-result which
262
# does not require traversing all of history to describe it.
263
if (result_repo.bzrdir.root_transport.base ==
264
result.root_transport.base and not require_stacking and
265
revision_id is not None):
266
fetch_spec = graph.PendingAncestryResult(
267
[revision_id], local_repo)
268
result_repo.fetch(local_repo, fetch_spec=fetch_spec)
270
result_repo.fetch(local_repo, revision_id=revision_id)
274
if result_repo is not None:
275
raise AssertionError('result_repo not None(%r)' % result_repo)
227
276
# 1 if there is a branch present
228
277
# make sure its content is available in the target repository
230
279
if local_branch is not None:
231
result_branch = local_branch.clone(result, revision_id=revision_id)
232
if repository_policy is not None:
233
repository_policy.configure_branch(result_branch)
234
if result_repo is None or result_repo.make_working_trees():
280
result_branch = local_branch.clone(result, revision_id=revision_id,
281
repository_policy=repository_policy)
283
# Cheaper to check if the target is not local, than to try making
285
result.root_transport.local_abspath('.')
286
if result_repo is None or result_repo.make_working_trees():
236
287
self.open_workingtree().clone(result)
237
except (errors.NoWorkingTree, errors.NotLocalUrl):
288
except (errors.NoWorkingTree, errors.NotLocalUrl):
241
292
# TODO: This should be given a Transport, and should chdir up; otherwise
1242
def push_branch(self, source, revision_id=None, overwrite=False,
1243
remember=False, create_prefix=False):
1244
"""Push the source branch into this BzrDir."""
1246
# If we can open a branch, use its direct repository, otherwise see
1247
# if there is a repository without a branch.
1249
br_to = self.open_branch()
1250
except errors.NotBranchError:
1251
# Didn't find a branch, can we find a repository?
1252
repository_to = self.find_repository()
1254
# Found a branch, so we must have found a repository
1255
repository_to = br_to.repository
1257
push_result = PushResult()
1258
push_result.source_branch = source
1260
# We have a repository but no branch, copy the revisions, and then
1262
repository_to.fetch(source.repository, revision_id=revision_id)
1263
br_to = source.clone(self, revision_id=revision_id)
1264
if source.get_push_location() is None or remember:
1265
source.set_push_location(br_to.base)
1266
push_result.stacked_on = None
1267
push_result.branch_push_result = None
1268
push_result.old_revno = None
1269
push_result.old_revid = _mod_revision.NULL_REVISION
1270
push_result.target_branch = br_to
1271
push_result.master_branch = None
1272
push_result.workingtree_updated = False
1274
# We have successfully opened the branch, remember if necessary:
1275
if source.get_push_location() is None or remember:
1276
source.set_push_location(br_to.base)
1278
tree_to = self.open_workingtree()
1279
except errors.NotLocalUrl:
1280
push_result.branch_push_result = source.push(br_to,
1281
overwrite, stop_revision=revision_id)
1282
push_result.workingtree_updated = False
1283
except errors.NoWorkingTree:
1284
push_result.branch_push_result = source.push(br_to,
1285
overwrite, stop_revision=revision_id)
1286
push_result.workingtree_updated = None # Not applicable
1288
tree_to.lock_write()
1290
push_result.branch_push_result = source.push(
1291
tree_to.branch, overwrite, stop_revision=revision_id)
1295
push_result.workingtree_updated = True
1296
push_result.old_revno = push_result.branch_push_result.old_revno
1297
push_result.old_revid = push_result.branch_push_result.old_revid
1298
push_result.target_branch = \
1299
push_result.branch_push_result.target_branch
1303
class BzrDirHooks(hooks.Hooks):
1304
"""Hooks for BzrDir operations."""
1307
"""Create the default hooks."""
1308
hooks.Hooks.__init__(self)
1309
self.create_hook(hooks.HookPoint('pre_open',
1310
"Invoked before attempting to open a BzrDir with the transport "
1311
"that the open will use.", (1, 14), None))
1313
# install the default hooks
1314
BzrDir.hooks = BzrDirHooks()
1182
1317
class BzrDirPreSplitOut(BzrDir):
1183
1318
"""A common class for the all-in-one formats."""
1700
1879
def initialize_on_transport(self, transport):
1701
1880
"""Initialize a new bzrdir in the base directory of a Transport."""
1702
# Since we don't have a .bzr directory, inherit the
1882
# can we hand off the request to the smart server rather than using
1884
client_medium = transport.get_smart_medium()
1885
except errors.NoSmartMedium:
1886
return self._initialize_on_transport_vfs(transport)
1888
# Current RPC's only know how to create bzr metadir1 instances, so
1889
# we still delegate to vfs methods if the requested format is not a
1891
if type(self) != BzrDirMetaFormat1:
1892
return self._initialize_on_transport_vfs(transport)
1893
remote_format = RemoteBzrDirFormat()
1894
self._supply_sub_formats_to(remote_format)
1895
return remote_format.initialize_on_transport(transport)
1897
def initialize_on_transport_ex(self, transport, use_existing_dir=False,
1898
create_prefix=False, force_new_repo=False, stacked_on=None,
1899
stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
1900
shared_repo=False, vfs_only=False):
1901
"""Create this format on transport.
1903
The directory to initialize will be created.
1905
:param force_new_repo: Do not use a shared repository for the target,
1906
even if one is available.
1907
:param create_prefix: Create any missing directories leading up to
1909
:param use_existing_dir: Use an existing directory if one exists.
1910
:param stacked_on: A url to stack any created branch on, None to follow
1911
any target stacking policy.
1912
:param stack_on_pwd: If stack_on is relative, the location it is
1914
:param repo_format_name: If non-None, a repository will be
1915
made-or-found. Should none be found, or if force_new_repo is True
1916
the repo_format_name is used to select the format of repository to
1918
:param make_working_trees: Control the setting of make_working_trees
1919
for a new shared repository when one is made. None to use whatever
1920
default the format has.
1921
:param shared_repo: Control whether made repositories are shared or
1923
:param vfs_only: If True do not attempt to use a smart server
1924
:return: repo, bzrdir, require_stacking, repository_policy. repo is
1925
None if none was created or found, bzrdir is always valid.
1926
require_stacking is the result of examining the stacked_on
1927
parameter and any stacking policy found for the target.
1930
# Try to hand off to a smart server
1932
client_medium = transport.get_smart_medium()
1933
except errors.NoSmartMedium:
1936
# TODO: lookup the local format from a server hint.
1937
remote_dir_format = RemoteBzrDirFormat()
1938
remote_dir_format._network_name = self.network_name()
1939
self._supply_sub_formats_to(remote_dir_format)
1940
return remote_dir_format.initialize_on_transport_ex(transport,
1941
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
1942
force_new_repo=force_new_repo, stacked_on=stacked_on,
1943
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
1944
make_working_trees=make_working_trees, shared_repo=shared_repo)
1945
# XXX: Refactor the create_prefix/no_create_prefix code into a
1946
# common helper function
1947
# The destination may not exist - if so make it according to policy.
1948
def make_directory(transport):
1949
transport.mkdir('.')
1951
def redirected(transport, e, redirection_notice):
1952
note(redirection_notice)
1953
return transport._redirected_to(e.source, e.target)
1955
transport = do_catching_redirections(make_directory, transport,
1957
except errors.FileExists:
1958
if not use_existing_dir:
1960
except errors.NoSuchFile:
1961
if not create_prefix:
1963
transport.create_prefix()
1965
require_stacking = (stacked_on is not None)
1966
# Now the target directory exists, but doesn't have a .bzr
1967
# directory. So we need to create it, along with any work to create
1968
# all of the dependent branches, etc.
1970
result = self.initialize_on_transport(transport)
1971
if repo_format_name:
1973
# use a custom format
1974
result._format.repository_format = \
1975
repository.network_format_registry.get(repo_format_name)
1976
except AttributeError:
1977
# The format didn't permit it to be set.
1979
# A repository is desired, either in-place or shared.
1980
repository_policy = result.determine_repository_policy(
1981
force_new_repo, stacked_on, stack_on_pwd,
1982
require_stacking=require_stacking)
1983
result_repo, is_new_repo = repository_policy.acquire_repository(
1984
make_working_trees, shared_repo)
1985
if not require_stacking and repository_policy._require_stacking:
1986
require_stacking = True
1987
result._format.require_stacking()
1988
result_repo.lock_write()
1991
repository_policy = None
1992
return result_repo, result, require_stacking, repository_policy
1994
def _initialize_on_transport_vfs(self, transport):
1995
"""Initialize a new bzrdir using VFS calls.
1997
:param transport: The transport to create the .bzr directory in.
2000
# Since we are creating a .bzr directory, inherit the
1703
2001
# mode from the root directory
1704
2002
temp_control = lockable_files.LockableFiles(transport,
1705
2003
'', lockable_files.TransportLock)
1880
2208
repository_format = property(__return_repository_format)
1883
class BzrDirFormat5(BzrDirFormat):
2211
class BzrDirFormatAllInOne(BzrDirFormat):
2212
"""Common class for formats before meta-dirs."""
2214
def initialize_on_transport_ex(self, transport, use_existing_dir=False,
2215
create_prefix=False, force_new_repo=False, stacked_on=None,
2216
stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
2218
"""See BzrDirFormat.initialize_on_transport_ex."""
2219
require_stacking = (stacked_on is not None)
2220
# Format 5 cannot stack, but we've been asked to - actually init
2222
if require_stacking:
2223
format = BzrDirMetaFormat1()
2224
return format.initialize_on_transport_ex(transport,
2225
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
2226
force_new_repo=force_new_repo, stacked_on=stacked_on,
2227
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
2228
make_working_trees=make_working_trees, shared_repo=shared_repo)
2229
return BzrDirFormat.initialize_on_transport_ex(self, transport,
2230
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
2231
force_new_repo=force_new_repo, stacked_on=stacked_on,
2232
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
2233
make_working_trees=make_working_trees, shared_repo=shared_repo)
2236
class BzrDirFormat5(BzrDirFormatAllInOne):
1884
2237
"""Bzr control format 5.
1886
2239
This format is a combined format for working tree, branch and repository.
1888
- Format 2 working trees [always]
1889
- Format 4 branches [always]
2241
- Format 2 working trees [always]
2242
- Format 4 branches [always]
1890
2243
- Format 5 repositories [always]
1891
2244
Unhashed stores in the repository.
2033
2393
def set_branch_format(self, format):
2034
2394
self._branch_format = format
2036
def require_stacking(self):
2396
def require_stacking(self, stack_on=None, possible_transports=None,
2398
"""We have a request to stack, try to ensure the formats support it.
2400
:param stack_on: If supplied, it is the URL to a branch that we want to
2401
stack on. Check to see if that format supports stacking before
2404
# Stacking is desired. requested by the target, but does the place it
2405
# points at support stacking? If it doesn't then we should
2406
# not implicitly upgrade. We check this here.
2407
new_repo_format = None
2408
new_branch_format = None
2410
# a bit of state for get_target_branch so that we don't try to open it
2411
# 2 times, for both repo *and* branch
2412
target = [None, False, None] # target_branch, checked, upgrade anyway
2413
def get_target_branch():
2415
# We've checked, don't check again
2417
if stack_on is None:
2418
# No target format, that means we want to force upgrading
2419
target[:] = [None, True, True]
2422
target_dir = BzrDir.open(stack_on,
2423
possible_transports=possible_transports)
2424
except errors.NotBranchError:
2425
# Nothing there, don't change formats
2426
target[:] = [None, True, False]
2428
except errors.JailBreak:
2429
# JailBreak, JFDI and upgrade anyway
2430
target[:] = [None, True, True]
2433
target_branch = target_dir.open_branch()
2434
except errors.NotBranchError:
2435
# No branch, don't upgrade formats
2436
target[:] = [None, True, False]
2438
target[:] = [target_branch, True, False]
2441
if (not _skip_repo and
2442
not self.repository_format.supports_external_lookups):
2443
# We need to upgrade the Repository.
2444
target_branch, _, do_upgrade = get_target_branch()
2445
if target_branch is None:
2446
# We don't have a target branch, should we upgrade anyway?
2448
# stack_on is inaccessible, JFDI.
2449
# TODO: bad monkey, hard-coded formats...
2450
if self.repository_format.rich_root_data:
2451
new_repo_format = pack_repo.RepositoryFormatKnitPack5RichRoot()
2453
new_repo_format = pack_repo.RepositoryFormatKnitPack5()
2455
# If the target already supports stacking, then we know the
2456
# project is already able to use stacking, so auto-upgrade
2458
new_repo_format = target_branch.repository._format
2459
if not new_repo_format.supports_external_lookups:
2460
# target doesn't, source doesn't, so don't auto upgrade
2462
new_repo_format = None
2463
if new_repo_format is not None:
2464
self.repository_format = new_repo_format
2465
note('Source repository format does not support stacking,'
2466
' using format:\n %s',
2467
new_repo_format.get_format_description())
2037
2469
if not self.get_branch_format().supports_stacking():
2038
# We need to make a stacked branch, but the default format for the
2039
# target doesn't support stacking. So force a branch that *can*
2041
from bzrlib.branch import BzrBranchFormat7
2042
self._branch_format = BzrBranchFormat7()
2043
mutter("using %r for stacking" % (self._branch_format,))
2044
from bzrlib.repofmt import pack_repo
2045
if self.repository_format.rich_root_data:
2046
bzrdir_format_name = '1.6.1-rich-root'
2047
repo_format = pack_repo.RepositoryFormatKnitPack5RichRoot()
2470
# We just checked the repo, now lets check if we need to
2471
# upgrade the branch format
2472
target_branch, _, do_upgrade = get_target_branch()
2473
if target_branch is None:
2475
# TODO: bad monkey, hard-coded formats...
2476
new_branch_format = branch.BzrBranchFormat7()
2049
bzrdir_format_name = '1.6'
2050
repo_format = pack_repo.RepositoryFormatKnitPack5()
2051
note('Source format does not support stacking, using format:'
2053
bzrdir_format_name, repo_format.get_format_description())
2054
self.repository_format = repo_format
2478
new_branch_format = target_branch._format
2479
if not new_branch_format.supports_stacking():
2480
new_branch_format = None
2481
if new_branch_format is not None:
2482
# Does support stacking, use its format.
2483
self.set_branch_format(new_branch_format)
2484
note('Source branch format does not support stacking,'
2485
' using format:\n %s',
2486
new_branch_format.get_format_description())
2056
2488
def get_converter(self, format=None):
2057
2489
"""See BzrDirFormat.get_converter()."""
2070
2502
"""See BzrDirFormat.get_format_description()."""
2071
2503
return "Meta directory format 1"
2505
def network_name(self):
2506
return self.get_format_string()
2073
2508
def _open(self, transport):
2074
2509
"""See BzrDirFormat._open."""
2075
return BzrDirMeta1(transport, self)
2510
# Create a new format instance because otherwise initialisation of new
2511
# metadirs share the global default format object leading to alias
2513
format = BzrDirMetaFormat1()
2514
self._supply_sub_formats_to(format)
2515
return BzrDirMeta1(transport, format)
2077
2517
def __return_repository_format(self):
2078
2518
"""Circular import protection."""
2079
if getattr(self, '_repository_format', None):
2519
if self._repository_format:
2080
2520
return self._repository_format
2081
2521
from bzrlib.repository import RepositoryFormat
2082
2522
return RepositoryFormat.get_default_format()
2084
def __set_repository_format(self, value):
2524
def _set_repository_format(self, value):
2085
2525
"""Allow changing the repository format for metadir formats."""
2086
2526
self._repository_format = value
2088
repository_format = property(__return_repository_format, __set_repository_format)
2528
repository_format = property(__return_repository_format,
2529
_set_repository_format)
2531
def _supply_sub_formats_to(self, other_format):
2532
"""Give other_format the same values for sub formats as this has.
2534
This method is expected to be used when parameterising a
2535
RemoteBzrDirFormat instance with the parameters from a
2536
BzrDirMetaFormat1 instance.
2538
:param other_format: other_format is a format which should be
2539
compatible with whatever sub formats are supported by self.
2542
if getattr(self, '_repository_format', None) is not None:
2543
other_format.repository_format = self.repository_format
2544
if self._branch_format is not None:
2545
other_format._branch_format = self._branch_format
2546
if self._workingtree_format is not None:
2547
other_format.workingtree_format = self.workingtree_format
2090
2549
def __get_workingtree_format(self):
2091
2550
if self._workingtree_format is None:
2622
3091
isinstance(self.target_format.workingtree_format,
2623
3092
workingtree_4.WorkingTreeFormat5)):
2624
3093
workingtree_4.Converter4to5().convert(tree)
3094
if (isinstance(tree, workingtree_4.DirStateWorkingTree) and
3095
not isinstance(tree, workingtree_4.WorkingTree6) and
3096
isinstance(self.target_format.workingtree_format,
3097
workingtree_4.WorkingTreeFormat6)):
3098
workingtree_4.Converter4or5to6().convert(tree)
2625
3099
return to_convert
2628
# This is not in remote.py because it's small, and needs to be registered.
2629
# Putting it in remote.py creates a circular import problem.
3102
# This is not in remote.py because it's relatively small, and needs to be
3103
# registered. Putting it in remote.py creates a circular import problem.
2630
3104
# we can make it a lazy object if the control formats is turned into something
2631
3105
# like a registry.
2632
3106
class RemoteBzrDirFormat(BzrDirMetaFormat1):
2633
3107
"""Format representing bzrdirs accessed via a smart server"""
3110
BzrDirMetaFormat1.__init__(self)
3111
# XXX: It's a bit ugly that the network name is here, because we'd
3112
# like to believe that format objects are stateless or at least
3113
# immutable, However, we do at least avoid mutating the name after
3114
# it's returned. See <https://bugs.edge.launchpad.net/bzr/+bug/504102>
3115
self._network_name = None
3118
return "%s(_network_name=%r)" % (self.__class__.__name__,
2635
3121
def get_format_description(self):
3122
if self._network_name:
3123
real_format = network_format_registry.get(self._network_name)
3124
return 'Remote: ' + real_format.get_format_description()
2636
3125
return 'bzr remote bzrdir'
3127
def get_format_string(self):
3128
raise NotImplementedError(self.get_format_string)
3130
def network_name(self):
3131
if self._network_name:
3132
return self._network_name
3134
raise AssertionError("No network name set.")
2639
3137
def probe_transport(klass, transport):
2640
3138
"""Return a RemoteBzrDirFormat object if it looks possible."""
2669
3167
return local_dir_format.initialize_on_transport(transport)
2670
3168
client = _SmartClient(client_medium)
2671
3169
path = client.remote_path_from_transport(transport)
2672
response = client.call('BzrDirFormat.initialize', path)
3171
response = client.call('BzrDirFormat.initialize', path)
3172
except errors.ErrorFromSmartServer, err:
3173
remote._translate_error(err, path=path)
2673
3174
if response[0] != 'ok':
2674
3175
raise errors.SmartProtocolError('unexpected response code %s' % (response,))
2675
return remote.RemoteBzrDir(transport)
3176
format = RemoteBzrDirFormat()
3177
self._supply_sub_formats_to(format)
3178
return remote.RemoteBzrDir(transport, format)
3180
def parse_NoneTrueFalse(self, arg):
3187
raise AssertionError("invalid arg %r" % arg)
3189
def _serialize_NoneTrueFalse(self, arg):
3196
def _serialize_NoneString(self, arg):
3199
def initialize_on_transport_ex(self, transport, use_existing_dir=False,
3200
create_prefix=False, force_new_repo=False, stacked_on=None,
3201
stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
3204
# hand off the request to the smart server
3205
client_medium = transport.get_smart_medium()
3206
except errors.NoSmartMedium:
3209
# Decline to open it if the server doesn't support our required
3210
# version (3) so that the VFS-based transport will do it.
3211
if client_medium.should_probe():
3213
server_version = client_medium.protocol_version()
3214
if server_version != '2':
3218
except errors.SmartProtocolError:
3219
# Apparently there's no usable smart server there, even though
3220
# the medium supports the smart protocol.
3225
client = _SmartClient(client_medium)
3226
path = client.remote_path_from_transport(transport)
3227
if client_medium._is_remote_before((1, 16)):
3230
# TODO: lookup the local format from a server hint.
3231
local_dir_format = BzrDirMetaFormat1()
3232
self._supply_sub_formats_to(local_dir_format)
3233
return local_dir_format.initialize_on_transport_ex(transport,
3234
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
3235
force_new_repo=force_new_repo, stacked_on=stacked_on,
3236
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
3237
make_working_trees=make_working_trees, shared_repo=shared_repo,
3239
return self._initialize_on_transport_ex_rpc(client, path, transport,
3240
use_existing_dir, create_prefix, force_new_repo, stacked_on,
3241
stack_on_pwd, repo_format_name, make_working_trees, shared_repo)
3243
def _initialize_on_transport_ex_rpc(self, client, path, transport,
3244
use_existing_dir, create_prefix, force_new_repo, stacked_on,
3245
stack_on_pwd, repo_format_name, make_working_trees, shared_repo):
3247
args.append(self._serialize_NoneTrueFalse(use_existing_dir))
3248
args.append(self._serialize_NoneTrueFalse(create_prefix))
3249
args.append(self._serialize_NoneTrueFalse(force_new_repo))
3250
args.append(self._serialize_NoneString(stacked_on))
3251
# stack_on_pwd is often/usually our transport
3254
stack_on_pwd = transport.relpath(stack_on_pwd)
3255
if not stack_on_pwd:
3257
except errors.PathNotChild:
3259
args.append(self._serialize_NoneString(stack_on_pwd))
3260
args.append(self._serialize_NoneString(repo_format_name))
3261
args.append(self._serialize_NoneTrueFalse(make_working_trees))
3262
args.append(self._serialize_NoneTrueFalse(shared_repo))
3263
request_network_name = self._network_name or \
3264
BzrDirFormat.get_default_format().network_name()
3266
response = client.call('BzrDirFormat.initialize_ex_1.16',
3267
request_network_name, path, *args)
3268
except errors.UnknownSmartMethod:
3269
client._medium._remember_remote_is_before((1,16))
3270
local_dir_format = BzrDirMetaFormat1()
3271
self._supply_sub_formats_to(local_dir_format)
3272
return local_dir_format.initialize_on_transport_ex(transport,
3273
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
3274
force_new_repo=force_new_repo, stacked_on=stacked_on,
3275
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
3276
make_working_trees=make_working_trees, shared_repo=shared_repo,
3278
except errors.ErrorFromSmartServer, err:
3279
remote._translate_error(err, path=path)
3280
repo_path = response[0]
3281
bzrdir_name = response[6]
3282
require_stacking = response[7]
3283
require_stacking = self.parse_NoneTrueFalse(require_stacking)
3284
format = RemoteBzrDirFormat()
3285
format._network_name = bzrdir_name
3286
self._supply_sub_formats_to(format)
3287
bzrdir = remote.RemoteBzrDir(transport, format, _client=client)
3289
repo_format = remote.response_tuple_to_repo_format(response[1:])
3290
if repo_path == '.':
3293
repo_bzrdir_format = RemoteBzrDirFormat()
3294
repo_bzrdir_format._network_name = response[5]
3295
repo_bzr = remote.RemoteBzrDir(transport.clone(repo_path),
3299
final_stack = response[8] or None
3300
final_stack_pwd = response[9] or None
3302
final_stack_pwd = urlutils.join(
3303
transport.base, final_stack_pwd)
3304
remote_repo = remote.RemoteRepository(repo_bzr, repo_format)
3305
if len(response) > 10:
3306
# Updated server verb that locks remotely.
3307
repo_lock_token = response[10] or None
3308
remote_repo.lock_write(repo_lock_token, _skip_rpc=True)
3310
remote_repo.dont_leave_lock_in_place()
3312
remote_repo.lock_write()
3313
policy = UseExistingRepository(remote_repo, final_stack,
3314
final_stack_pwd, require_stacking)
3315
policy.acquire_repository()
3319
bzrdir._format.set_branch_format(self.get_branch_format())
3320
if require_stacking:
3321
# The repo has already been created, but we need to make sure that
3322
# we'll make a stackable branch.
3323
bzrdir._format.require_stacking(_skip_repo=True)
3324
return remote_repo, bzrdir, require_stacking, policy
2677
3326
def _open(self, transport):
2678
return remote.RemoteBzrDir(transport)
3327
return remote.RemoteBzrDir(transport, self)
2680
3329
def __eq__(self, other):
2681
3330
if not isinstance(other, RemoteBzrDirFormat):
2683
3332
return self.get_format_description() == other.get_format_description()
2686
def repository_format(self):
2687
# Using a property to avoid early loading of remote
2688
return remote.RemoteRepositoryFormat()
3334
def __return_repository_format(self):
3335
# Always return a RemoteRepositoryFormat object, but if a specific bzr
3336
# repository format has been asked for, tell the RemoteRepositoryFormat
3337
# that it should use that for init() etc.
3338
result = remote.RemoteRepositoryFormat()
3339
custom_format = getattr(self, '_repository_format', None)
3341
if isinstance(custom_format, remote.RemoteRepositoryFormat):
3342
return custom_format
3344
# We will use the custom format to create repositories over the
3345
# wire; expose its details like rich_root_data for code to
3347
result._custom_format = custom_format
3350
def get_branch_format(self):
3351
result = BzrDirMetaFormat1.get_branch_format(self)
3352
if not isinstance(result, remote.RemoteBranchFormat):
3353
new_result = remote.RemoteBranchFormat()
3354
new_result._custom_format = result
3356
self.set_branch_format(new_result)
3360
repository_format = property(__return_repository_format,
3361
BzrDirMetaFormat1._set_repository_format) #.im_func)
2691
3364
BzrDirFormat.register_control_server_format(RemoteBzrDirFormat)
3121
3818
format_registry.register_metadir('1.9-rich-root',
3122
3819
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
3123
3820
help='A variant of 1.9 that supports rich-root data '
3124
'(needed for bzr-svn).',
3821
'(needed for bzr-svn and bzr-git).',
3125
3822
branch_format='bzrlib.branch.BzrBranchFormat7',
3126
3823
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3128
format_registry.register_metadir('development-wt5',
3825
format_registry.register_metadir('1.14',
3129
3826
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
3130
help='A working-tree format that supports views and content filtering.',
3827
help='A working-tree format that supports content filtering.',
3131
3828
branch_format='bzrlib.branch.BzrBranchFormat7',
3132
tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
3829
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3135
format_registry.register_metadir('development-wt5-rich-root',
3831
format_registry.register_metadir('1.14-rich-root',
3136
3832
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
3137
help='A variant of development-wt5 that supports rich-root data '
3138
'(needed for bzr-svn).',
3833
help='A variant of 1.14 that supports rich-root data '
3834
'(needed for bzr-svn and bzr-git).',
3139
3835
branch_format='bzrlib.branch.BzrBranchFormat7',
3140
tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
3836
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3143
# The following two formats should always just be aliases.
3144
format_registry.register_metadir('development',
3145
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2',
3146
help='Current development format. Can convert data to and from pack-0.92 '
3147
'(and anything compatible with pack-0.92) format repositories. '
3148
'Repositories and branches in this format can only be read by bzr.dev. '
3838
# The following un-numbered 'development' formats should always just be aliases.
3839
format_registry.register_metadir('development-rich-root',
3840
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK1',
3841
help='Current development format. Supports rich roots. Can convert data '
3842
'to and from rich-root-pack (and anything compatible with '
3843
'rich-root-pack) format repositories. Repositories and branches in '
3844
'this format can only be read by bzr.dev. Please read '
3150
3845
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3152
3847
branch_format='bzrlib.branch.BzrBranchFormat7',
3153
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3848
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3154
3849
experimental=True,
3163
3858
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3165
3860
branch_format='bzrlib.branch.BzrBranchFormat7',
3166
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3861
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3167
3862
experimental=True,
3863
alias=False, # Restore to being an alias when an actual development subtree format is added
3864
# This current non-alias status is simply because we did not introduce a
3865
# chk based subtree format.
3170
3868
# And the development formats above will have aliased one of the following:
3171
format_registry.register_metadir('development2',
3172
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2',
3173
help='1.6.1 with B+Tree based index. '
3175
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3177
branch_format='bzrlib.branch.BzrBranchFormat7',
3178
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3182
format_registry.register_metadir('development2-subtree',
3183
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2Subtree',
3184
help='1.6.1-subtree with B+Tree based index. '
3186
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3188
branch_format='bzrlib.branch.BzrBranchFormat7',
3189
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3869
format_registry.register_metadir('development6-rich-root',
3870
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK1',
3871
help='pack-1.9 with 255-way hashed CHK inv, group compress, rich roots '
3873
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3875
branch_format='bzrlib.branch.BzrBranchFormat7',
3876
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3881
format_registry.register_metadir('development7-rich-root',
3882
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK2',
3883
help='pack-1.9 with 255-way hashed CHK inv, bencode revision, group compress, '
3884
'rich roots. Please read '
3885
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3887
branch_format='bzrlib.branch.BzrBranchFormat7',
3888
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3893
format_registry.register_metadir('2a',
3894
'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2a',
3895
help='First format for bzr 2.0 series.\n'
3896
'Uses group-compress storage.\n'
3897
'Provides rich roots which are a one-way transition.\n',
3898
# 'storage in packs, 255-way hashed CHK inventory, bencode revision, group compress, '
3899
# 'rich roots. Supported by bzr 1.16 and later.',
3900
branch_format='bzrlib.branch.BzrBranchFormat7',
3901
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3905
# The following format should be an alias for the rich root equivalent
3906
# of the default format
3907
format_registry.register_metadir('default-rich-root',
3908
'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2a',
3909
branch_format='bzrlib.branch.BzrBranchFormat7',
3910
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3193
3914
# The current format that is made on 'bzr init'.
3194
format_registry.set_default('pack-0.92')
3915
format_registry.set_default('2a')