225
209
errors.UnstackableRepositoryFormat,
226
210
errors.NotStacked):
228
# Bug: We create a metadir without knowing if it can support stacking,
229
# 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)
232
218
make_working_trees = local_repo.make_working_trees()
233
want_shared = local_repo.is_shared()
234
repo_format_name = format.repository_format.network_name()
236
make_working_trees = False
238
repo_format_name = None
240
result_repo, result, require_stacking, repository_policy = \
241
format.initialize_on_transport_ex(transport,
242
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
243
force_new_repo=force_new_repo, stacked_on=stacked_on,
244
stack_on_pwd=self.root_transport.base,
245
repo_format_name=repo_format_name,
246
make_working_trees=make_working_trees, shared_repo=want_shared)
249
# If the result repository is in the same place as the
250
# resulting bzr dir, it will have no content, further if the
251
# result is not stacked then we know all content should be
252
# copied, and finally if we are copying up to a specific
253
# revision_id then we can use the pending-ancestry-result which
254
# does not require traversing all of history to describe it.
255
if (result_repo.bzrdir.root_transport.base ==
256
result.root_transport.base and not require_stacking and
257
revision_id is not None):
258
fetch_spec = graph.PendingAncestryResult(
259
[revision_id], local_repo)
260
result_repo.fetch(local_repo, fetch_spec=fetch_spec)
262
result_repo.fetch(local_repo, revision_id=revision_id)
266
if result_repo is not None:
267
raise AssertionError('result_repo not None(%r)' % result_repo)
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)
268
227
# 1 if there is a branch present
269
228
# make sure its content is available in the target repository
271
230
if local_branch is not None:
272
result_branch = local_branch.clone(result, revision_id=revision_id,
273
repository_policy=repository_policy)
275
# Cheaper to check if the target is not local, than to try making
277
result.root_transport.local_abspath('.')
278
if result_repo is None or result_repo.make_working_trees():
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():
279
236
self.open_workingtree().clone(result)
280
except (errors.NoWorkingTree, errors.NotLocalUrl):
237
except (errors.NoWorkingTree, errors.NotLocalUrl):
284
241
# TODO: This should be given a Transport, and should chdir up; otherwise
1235
def push_branch(self, source, revision_id=None, overwrite=False,
1237
"""Push the source branch into this BzrDir."""
1239
# If we can open a branch, use its direct repository, otherwise see
1240
# if there is a repository without a branch.
1242
br_to = self.open_branch()
1243
except errors.NotBranchError:
1244
# Didn't find a branch, can we find a repository?
1245
repository_to = self.find_repository()
1247
# Found a branch, so we must have found a repository
1248
repository_to = br_to.repository
1250
push_result = PushResult()
1251
push_result.source_branch = source
1253
# We have a repository but no branch, copy the revisions, and then
1255
repository_to.fetch(source.repository, revision_id=revision_id)
1256
br_to = source.clone(self, revision_id=revision_id)
1257
if source.get_push_location() is None or remember:
1258
source.set_push_location(br_to.base)
1259
push_result.stacked_on = None
1260
push_result.branch_push_result = None
1261
push_result.old_revno = None
1262
push_result.old_revid = _mod_revision.NULL_REVISION
1263
push_result.target_branch = br_to
1264
push_result.master_branch = None
1265
push_result.workingtree_updated = False
1267
# We have successfully opened the branch, remember if necessary:
1268
if source.get_push_location() is None or remember:
1269
source.set_push_location(br_to.base)
1271
tree_to = self.open_workingtree()
1272
except errors.NotLocalUrl:
1273
push_result.branch_push_result = source.push(br_to,
1274
overwrite, stop_revision=revision_id)
1275
push_result.workingtree_updated = False
1276
except errors.NoWorkingTree:
1277
push_result.branch_push_result = source.push(br_to,
1278
overwrite, stop_revision=revision_id)
1279
push_result.workingtree_updated = None # Not applicable
1281
tree_to.lock_write()
1283
push_result.branch_push_result = source.push(
1284
tree_to.branch, overwrite, stop_revision=revision_id)
1288
push_result.workingtree_updated = True
1289
push_result.old_revno = push_result.branch_push_result.old_revno
1290
push_result.old_revid = push_result.branch_push_result.old_revid
1291
push_result.target_branch = \
1292
push_result.branch_push_result.target_branch
1296
class BzrDirHooks(hooks.Hooks):
1297
"""Hooks for BzrDir operations."""
1300
"""Create the default hooks."""
1301
hooks.Hooks.__init__(self)
1302
self.create_hook(hooks.HookPoint('pre_open',
1303
"Invoked before attempting to open a BzrDir with the transport "
1304
"that the open will use.", (1, 14), None))
1306
# install the default hooks
1307
BzrDir.hooks = BzrDirHooks()
1310
1169
class BzrDirPreSplitOut(BzrDir):
1311
1170
"""A common class for the all-in-one formats."""
1843
1679
def initialize_on_transport(self, transport):
1844
1680
"""Initialize a new bzrdir in the base directory of a Transport."""
1846
# can we hand off the request to the smart server rather than using
1848
client_medium = transport.get_smart_medium()
1849
except errors.NoSmartMedium:
1850
return self._initialize_on_transport_vfs(transport)
1852
# Current RPC's only know how to create bzr metadir1 instances, so
1853
# we still delegate to vfs methods if the requested format is not a
1855
if type(self) != BzrDirMetaFormat1:
1856
return self._initialize_on_transport_vfs(transport)
1857
remote_format = RemoteBzrDirFormat()
1858
self._supply_sub_formats_to(remote_format)
1859
return remote_format.initialize_on_transport(transport)
1861
def initialize_on_transport_ex(self, transport, use_existing_dir=False,
1862
create_prefix=False, force_new_repo=False, stacked_on=None,
1863
stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
1864
shared_repo=False, vfs_only=False):
1865
"""Create this format on transport.
1867
The directory to initialize will be created.
1869
:param force_new_repo: Do not use a shared repository for the target,
1870
even if one is available.
1871
:param create_prefix: Create any missing directories leading up to
1873
:param use_existing_dir: Use an existing directory if one exists.
1874
:param stacked_on: A url to stack any created branch on, None to follow
1875
any target stacking policy.
1876
:param stack_on_pwd: If stack_on is relative, the location it is
1878
:param repo_format_name: If non-None, a repository will be
1879
made-or-found. Should none be found, or if force_new_repo is True
1880
the repo_format_name is used to select the format of repository to
1882
:param make_working_trees: Control the setting of make_working_trees
1883
for a new shared repository when one is made. None to use whatever
1884
default the format has.
1885
:param shared_repo: Control whether made repositories are shared or
1887
:param vfs_only: If True do not attempt to use a smart server
1888
:return: repo, bzrdir, require_stacking, repository_policy. repo is
1889
None if none was created or found, bzrdir is always valid.
1890
require_stacking is the result of examining the stacked_on
1891
parameter and any stacking policy found for the target.
1894
# Try to hand off to a smart server
1896
client_medium = transport.get_smart_medium()
1897
except errors.NoSmartMedium:
1900
# TODO: lookup the local format from a server hint.
1901
remote_dir_format = RemoteBzrDirFormat()
1902
remote_dir_format._network_name = self.network_name()
1903
self._supply_sub_formats_to(remote_dir_format)
1904
return remote_dir_format.initialize_on_transport_ex(transport,
1905
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
1906
force_new_repo=force_new_repo, stacked_on=stacked_on,
1907
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
1908
make_working_trees=make_working_trees, shared_repo=shared_repo)
1909
# XXX: Refactor the create_prefix/no_create_prefix code into a
1910
# common helper function
1911
# The destination may not exist - if so make it according to policy.
1912
def make_directory(transport):
1913
transport.mkdir('.')
1915
def redirected(transport, e, redirection_notice):
1916
note(redirection_notice)
1917
return transport._redirected_to(e.source, e.target)
1919
transport = do_catching_redirections(make_directory, transport,
1921
except errors.FileExists:
1922
if not use_existing_dir:
1924
except errors.NoSuchFile:
1925
if not create_prefix:
1927
transport.create_prefix()
1929
require_stacking = (stacked_on is not None)
1930
# Now the target directory exists, but doesn't have a .bzr
1931
# directory. So we need to create it, along with any work to create
1932
# all of the dependent branches, etc.
1934
result = self.initialize_on_transport(transport)
1935
if repo_format_name:
1937
# use a custom format
1938
result._format.repository_format = \
1939
repository.network_format_registry.get(repo_format_name)
1940
except AttributeError:
1941
# The format didn't permit it to be set.
1943
# A repository is desired, either in-place or shared.
1944
repository_policy = result.determine_repository_policy(
1945
force_new_repo, stacked_on, stack_on_pwd,
1946
require_stacking=require_stacking)
1947
result_repo, is_new_repo = repository_policy.acquire_repository(
1948
make_working_trees, shared_repo)
1949
if not require_stacking and repository_policy._require_stacking:
1950
require_stacking = True
1951
result._format.require_stacking()
1952
result_repo.lock_write()
1955
repository_policy = None
1956
return result_repo, result, require_stacking, repository_policy
1958
def _initialize_on_transport_vfs(self, transport):
1959
"""Initialize a new bzrdir using VFS calls.
1961
:param transport: The transport to create the .bzr directory in.
1964
# Since we are creating a .bzr directory, inherit the
1681
# Since we don't have a .bzr directory, inherit the
1965
1682
# mode from the root directory
1966
1683
temp_control = lockable_files.LockableFiles(transport,
1967
1684
'', lockable_files.TransportLock)
2172
1859
repository_format = property(__return_repository_format)
2175
class BzrDirFormatAllInOne(BzrDirFormat):
2176
"""Common class for formats before meta-dirs."""
2178
def initialize_on_transport_ex(self, transport, use_existing_dir=False,
2179
create_prefix=False, force_new_repo=False, stacked_on=None,
2180
stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
2182
"""See BzrDirFormat.initialize_on_transport_ex."""
2183
require_stacking = (stacked_on is not None)
2184
# Format 5 cannot stack, but we've been asked to - actually init
2186
if require_stacking:
2187
format = BzrDirMetaFormat1()
2188
return format.initialize_on_transport_ex(transport,
2189
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
2190
force_new_repo=force_new_repo, stacked_on=stacked_on,
2191
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
2192
make_working_trees=make_working_trees, shared_repo=shared_repo)
2193
return BzrDirFormat.initialize_on_transport_ex(self, transport,
2194
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
2195
force_new_repo=force_new_repo, stacked_on=stacked_on,
2196
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
2197
make_working_trees=make_working_trees, shared_repo=shared_repo)
2200
class BzrDirFormat5(BzrDirFormatAllInOne):
1862
class BzrDirFormat5(BzrDirFormat):
2201
1863
"""Bzr control format 5.
2203
1865
This format is a combined format for working tree, branch and repository.
2205
- Format 2 working trees [always]
2206
- Format 4 branches [always]
1867
- Format 2 working trees [always]
1868
- Format 4 branches [always]
2207
1869
- Format 5 repositories [always]
2208
1870
Unhashed stores in the repository.
2357
2012
def set_branch_format(self, format):
2358
2013
self._branch_format = format
2360
def require_stacking(self, stack_on=None, possible_transports=None,
2362
"""We have a request to stack, try to ensure the formats support it.
2364
:param stack_on: If supplied, it is the URL to a branch that we want to
2365
stack on. Check to see if that format supports stacking before
2368
# Stacking is desired. requested by the target, but does the place it
2369
# points at support stacking? If it doesn't then we should
2370
# not implicitly upgrade. We check this here.
2371
new_repo_format = None
2372
new_branch_format = None
2374
# a bit of state for get_target_branch so that we don't try to open it
2375
# 2 times, for both repo *and* branch
2376
target = [None, False, None] # target_branch, checked, upgrade anyway
2377
def get_target_branch():
2379
# We've checked, don't check again
2381
if stack_on is None:
2382
# No target format, that means we want to force upgrading
2383
target[:] = [None, True, True]
2386
target_dir = BzrDir.open(stack_on,
2387
possible_transports=possible_transports)
2388
except errors.NotBranchError:
2389
# Nothing there, don't change formats
2390
target[:] = [None, True, False]
2392
except errors.JailBreak:
2393
# JailBreak, JFDI and upgrade anyway
2394
target[:] = [None, True, True]
2397
target_branch = target_dir.open_branch()
2398
except errors.NotBranchError:
2399
# No branch, don't upgrade formats
2400
target[:] = [None, True, False]
2402
target[:] = [target_branch, True, False]
2405
if (not _skip_repo and
2406
not self.repository_format.supports_external_lookups):
2407
# We need to upgrade the Repository.
2408
target_branch, _, do_upgrade = get_target_branch()
2409
if target_branch is None:
2410
# We don't have a target branch, should we upgrade anyway?
2412
# stack_on is inaccessible, JFDI.
2413
# TODO: bad monkey, hard-coded formats...
2414
if self.repository_format.rich_root_data:
2415
new_repo_format = pack_repo.RepositoryFormatKnitPack5RichRoot()
2417
new_repo_format = pack_repo.RepositoryFormatKnitPack5()
2419
# If the target already supports stacking, then we know the
2420
# project is already able to use stacking, so auto-upgrade
2422
new_repo_format = target_branch.repository._format
2423
if not new_repo_format.supports_external_lookups:
2424
# target doesn't, source doesn't, so don't auto upgrade
2426
new_repo_format = None
2427
if new_repo_format is not None:
2428
self.repository_format = new_repo_format
2429
note('Source repository format does not support stacking,'
2430
' using format:\n %s',
2431
new_repo_format.get_format_description())
2015
def require_stacking(self):
2433
2016
if not self.get_branch_format().supports_stacking():
2434
# We just checked the repo, now lets check if we need to
2435
# upgrade the branch format
2436
target_branch, _, do_upgrade = get_target_branch()
2437
if target_branch is None:
2439
# TODO: bad monkey, hard-coded formats...
2440
new_branch_format = branch.BzrBranchFormat7()
2017
# We need to make a stacked branch, but the default format for the
2018
# target doesn't support stacking. So force a branch that *can*
2020
from bzrlib.branch import BzrBranchFormat7
2021
self._branch_format = BzrBranchFormat7()
2022
mutter("using %r for stacking" % (self._branch_format,))
2023
from bzrlib.repofmt import pack_repo
2024
if self.repository_format.rich_root_data:
2025
bzrdir_format_name = '1.6.1-rich-root'
2026
repo_format = pack_repo.RepositoryFormatKnitPack5RichRoot()
2442
new_branch_format = target_branch._format
2443
if not new_branch_format.supports_stacking():
2444
new_branch_format = None
2445
if new_branch_format is not None:
2446
# Does support stacking, use its format.
2447
self.set_branch_format(new_branch_format)
2448
note('Source branch format does not support stacking,'
2449
' using format:\n %s',
2450
new_branch_format.get_format_description())
2028
bzrdir_format_name = '1.6'
2029
repo_format = pack_repo.RepositoryFormatKnitPack5()
2030
note('Source format does not support stacking, using format:'
2032
bzrdir_format_name, repo_format.get_format_description())
2033
self.repository_format = repo_format
2452
2035
def get_converter(self, format=None):
2453
2036
"""See BzrDirFormat.get_converter()."""
2466
2049
"""See BzrDirFormat.get_format_description()."""
2467
2050
return "Meta directory format 1"
2469
def network_name(self):
2470
return self.get_format_string()
2472
2052
def _open(self, transport):
2473
2053
"""See BzrDirFormat._open."""
2474
# Create a new format instance because otherwise initialisation of new
2475
# metadirs share the global default format object leading to alias
2477
format = BzrDirMetaFormat1()
2478
self._supply_sub_formats_to(format)
2479
return BzrDirMeta1(transport, format)
2054
return BzrDirMeta1(transport, self)
2481
2056
def __return_repository_format(self):
2482
2057
"""Circular import protection."""
2483
if self._repository_format:
2058
if getattr(self, '_repository_format', None):
2484
2059
return self._repository_format
2485
2060
from bzrlib.repository import RepositoryFormat
2486
2061
return RepositoryFormat.get_default_format()
2488
def _set_repository_format(self, value):
2063
def __set_repository_format(self, value):
2489
2064
"""Allow changing the repository format for metadir formats."""
2490
2065
self._repository_format = value
2492
repository_format = property(__return_repository_format,
2493
_set_repository_format)
2495
def _supply_sub_formats_to(self, other_format):
2496
"""Give other_format the same values for sub formats as this has.
2498
This method is expected to be used when parameterising a
2499
RemoteBzrDirFormat instance with the parameters from a
2500
BzrDirMetaFormat1 instance.
2502
:param other_format: other_format is a format which should be
2503
compatible with whatever sub formats are supported by self.
2506
if getattr(self, '_repository_format', None) is not None:
2507
other_format.repository_format = self.repository_format
2508
if self._branch_format is not None:
2509
other_format._branch_format = self._branch_format
2510
if self._workingtree_format is not None:
2511
other_format.workingtree_format = self.workingtree_format
2067
repository_format = property(__return_repository_format, __set_repository_format)
2513
2069
def __get_workingtree_format(self):
2514
2070
if self._workingtree_format is None:
3119
2648
return local_dir_format.initialize_on_transport(transport)
3120
2649
client = _SmartClient(client_medium)
3121
2650
path = client.remote_path_from_transport(transport)
3123
response = client.call('BzrDirFormat.initialize', path)
3124
except errors.ErrorFromSmartServer, err:
3125
remote._translate_error(err, path=path)
2651
response = client.call('BzrDirFormat.initialize', path)
3126
2652
if response[0] != 'ok':
3127
2653
raise errors.SmartProtocolError('unexpected response code %s' % (response,))
3128
format = RemoteBzrDirFormat()
3129
self._supply_sub_formats_to(format)
3130
return remote.RemoteBzrDir(transport, format)
3132
def parse_NoneTrueFalse(self, arg):
3139
raise AssertionError("invalid arg %r" % arg)
3141
def _serialize_NoneTrueFalse(self, arg):
3148
def _serialize_NoneString(self, arg):
3151
def initialize_on_transport_ex(self, transport, use_existing_dir=False,
3152
create_prefix=False, force_new_repo=False, stacked_on=None,
3153
stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
3156
# hand off the request to the smart server
3157
client_medium = transport.get_smart_medium()
3158
except errors.NoSmartMedium:
3161
# Decline to open it if the server doesn't support our required
3162
# version (3) so that the VFS-based transport will do it.
3163
if client_medium.should_probe():
3165
server_version = client_medium.protocol_version()
3166
if server_version != '2':
3170
except errors.SmartProtocolError:
3171
# Apparently there's no usable smart server there, even though
3172
# the medium supports the smart protocol.
3177
client = _SmartClient(client_medium)
3178
path = client.remote_path_from_transport(transport)
3179
if client_medium._is_remote_before((1, 16)):
3182
# TODO: lookup the local format from a server hint.
3183
local_dir_format = BzrDirMetaFormat1()
3184
self._supply_sub_formats_to(local_dir_format)
3185
return local_dir_format.initialize_on_transport_ex(transport,
3186
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
3187
force_new_repo=force_new_repo, stacked_on=stacked_on,
3188
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
3189
make_working_trees=make_working_trees, shared_repo=shared_repo,
3191
return self._initialize_on_transport_ex_rpc(client, path, transport,
3192
use_existing_dir, create_prefix, force_new_repo, stacked_on,
3193
stack_on_pwd, repo_format_name, make_working_trees, shared_repo)
3195
def _initialize_on_transport_ex_rpc(self, client, path, transport,
3196
use_existing_dir, create_prefix, force_new_repo, stacked_on,
3197
stack_on_pwd, repo_format_name, make_working_trees, shared_repo):
3199
args.append(self._serialize_NoneTrueFalse(use_existing_dir))
3200
args.append(self._serialize_NoneTrueFalse(create_prefix))
3201
args.append(self._serialize_NoneTrueFalse(force_new_repo))
3202
args.append(self._serialize_NoneString(stacked_on))
3203
# stack_on_pwd is often/usually our transport
3206
stack_on_pwd = transport.relpath(stack_on_pwd)
3207
if not stack_on_pwd:
3209
except errors.PathNotChild:
3211
args.append(self._serialize_NoneString(stack_on_pwd))
3212
args.append(self._serialize_NoneString(repo_format_name))
3213
args.append(self._serialize_NoneTrueFalse(make_working_trees))
3214
args.append(self._serialize_NoneTrueFalse(shared_repo))
3215
if self._network_name is None:
3216
self._network_name = \
3217
BzrDirFormat.get_default_format().network_name()
3219
response = client.call('BzrDirFormat.initialize_ex_1.16',
3220
self.network_name(), path, *args)
3221
except errors.UnknownSmartMethod:
3222
client._medium._remember_remote_is_before((1,16))
3223
local_dir_format = BzrDirMetaFormat1()
3224
self._supply_sub_formats_to(local_dir_format)
3225
return local_dir_format.initialize_on_transport_ex(transport,
3226
use_existing_dir=use_existing_dir, create_prefix=create_prefix,
3227
force_new_repo=force_new_repo, stacked_on=stacked_on,
3228
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
3229
make_working_trees=make_working_trees, shared_repo=shared_repo,
3231
except errors.ErrorFromSmartServer, err:
3232
remote._translate_error(err, path=path)
3233
repo_path = response[0]
3234
bzrdir_name = response[6]
3235
require_stacking = response[7]
3236
require_stacking = self.parse_NoneTrueFalse(require_stacking)
3237
format = RemoteBzrDirFormat()
3238
format._network_name = bzrdir_name
3239
self._supply_sub_formats_to(format)
3240
bzrdir = remote.RemoteBzrDir(transport, format, _client=client)
3242
repo_format = remote.response_tuple_to_repo_format(response[1:])
3243
if repo_path == '.':
3246
repo_bzrdir_format = RemoteBzrDirFormat()
3247
repo_bzrdir_format._network_name = response[5]
3248
repo_bzr = remote.RemoteBzrDir(transport.clone(repo_path),
3252
final_stack = response[8] or None
3253
final_stack_pwd = response[9] or None
3255
final_stack_pwd = urlutils.join(
3256
transport.base, final_stack_pwd)
3257
remote_repo = remote.RemoteRepository(repo_bzr, repo_format)
3258
if len(response) > 10:
3259
# Updated server verb that locks remotely.
3260
repo_lock_token = response[10] or None
3261
remote_repo.lock_write(repo_lock_token, _skip_rpc=True)
3263
remote_repo.dont_leave_lock_in_place()
3265
remote_repo.lock_write()
3266
policy = UseExistingRepository(remote_repo, final_stack,
3267
final_stack_pwd, require_stacking)
3268
policy.acquire_repository()
3272
if require_stacking:
3273
# The repo has already been created, but we need to make sure that
3274
# we'll make a stackable branch.
3275
bzrdir._format.require_stacking(_skip_repo=True)
3276
return remote_repo, bzrdir, require_stacking, policy
2654
return remote.RemoteBzrDir(transport)
3278
2656
def _open(self, transport):
3279
return remote.RemoteBzrDir(transport, self)
2657
return remote.RemoteBzrDir(transport)
3281
2659
def __eq__(self, other):
3282
2660
if not isinstance(other, RemoteBzrDirFormat):
3284
2662
return self.get_format_description() == other.get_format_description()
3286
def __return_repository_format(self):
3287
# Always return a RemoteRepositoryFormat object, but if a specific bzr
3288
# repository format has been asked for, tell the RemoteRepositoryFormat
3289
# that it should use that for init() etc.
3290
result = remote.RemoteRepositoryFormat()
3291
custom_format = getattr(self, '_repository_format', None)
3293
if isinstance(custom_format, remote.RemoteRepositoryFormat):
3294
return custom_format
3296
# We will use the custom format to create repositories over the
3297
# wire; expose its details like rich_root_data for code to
3299
result._custom_format = custom_format
3302
def get_branch_format(self):
3303
result = BzrDirMetaFormat1.get_branch_format(self)
3304
if not isinstance(result, remote.RemoteBranchFormat):
3305
new_result = remote.RemoteBranchFormat()
3306
new_result._custom_format = result
3308
self.set_branch_format(new_result)
3312
repository_format = property(__return_repository_format,
3313
BzrDirMetaFormat1._set_repository_format) #.im_func)
2665
def repository_format(self):
2666
# Using a property to avoid early loading of remote
2667
return remote.RemoteRepositoryFormat()
3316
2670
BzrDirFormat.register_control_server_format(RemoteBzrDirFormat)
3766
3097
format_registry.register_metadir('1.9-rich-root',
3767
3098
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
3768
3099
help='A variant of 1.9 that supports rich-root data '
3769
'(needed for bzr-svn and bzr-git).',
3100
'(needed for bzr-svn).',
3770
3101
branch_format='bzrlib.branch.BzrBranchFormat7',
3771
3102
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3773
format_registry.register_metadir('1.14',
3104
format_registry.register_metadir('1.12-preview',
3774
3105
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
3775
help='A working-tree format that supports content filtering.',
3106
help='A working-tree format that supports views and content filtering.',
3776
3107
branch_format='bzrlib.branch.BzrBranchFormat7',
3777
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3108
tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
3779
format_registry.register_metadir('1.14-rich-root',
3111
format_registry.register_metadir('1.12-preview-rich-root',
3780
3112
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
3781
help='A variant of 1.14 that supports rich-root data '
3782
'(needed for bzr-svn and bzr-git).',
3113
help='A variant of 1.12-preview that supports rich-root data '
3114
'(needed for bzr-svn).',
3783
3115
branch_format='bzrlib.branch.BzrBranchFormat7',
3784
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3116
tree_format='bzrlib.workingtree_4.WorkingTreeFormat5',
3786
# The following un-numbered 'development' formats should always just be aliases.
3787
format_registry.register_metadir('development-rich-root',
3788
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK1',
3789
help='Current development format. Supports rich roots. Can convert data '
3790
'to and from rich-root-pack (and anything compatible with '
3791
'rich-root-pack) format repositories. Repositories and branches in '
3792
'this format can only be read by bzr.dev. Please read '
3119
# The following two formats should always just be aliases.
3120
format_registry.register_metadir('development',
3121
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2',
3122
help='Current development format. Can convert data to and from pack-0.92 '
3123
'(and anything compatible with pack-0.92) format repositories. '
3124
'Repositories and branches in this format can only be read by bzr.dev. '
3793
3126
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3795
3128
branch_format='bzrlib.branch.BzrBranchFormat7',
3796
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3129
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3797
3130
experimental=True,
3806
3139
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3808
3141
branch_format='bzrlib.branch.BzrBranchFormat7',
3809
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3142
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3810
3143
experimental=True,
3811
alias=False, # Restore to being an alias when an actual development subtree format is added
3812
# This current non-alias status is simply because we did not introduce a
3813
# chk based subtree format.
3816
3146
# And the development formats above will have aliased one of the following:
3817
format_registry.register_metadir('development6-rich-root',
3818
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK1',
3819
help='pack-1.9 with 255-way hashed CHK inv, group compress, rich roots '
3821
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3823
branch_format='bzrlib.branch.BzrBranchFormat7',
3824
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3829
format_registry.register_metadir('development7-rich-root',
3830
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK2',
3831
help='pack-1.9 with 255-way hashed CHK inv, bencode revision, group compress, '
3832
'rich roots. Please read '
3833
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3835
branch_format='bzrlib.branch.BzrBranchFormat7',
3836
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3841
format_registry.register_metadir('2a',
3842
'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2a',
3843
help='First format for bzr 2.0 series.\n'
3844
'Uses group-compress storage.\n'
3845
'Provides rich roots which are a one-way transition.\n',
3846
# 'storage in packs, 255-way hashed CHK inventory, bencode revision, group compress, '
3847
# 'rich roots. Supported by bzr 1.16 and later.',
3848
branch_format='bzrlib.branch.BzrBranchFormat7',
3849
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3853
# The following format should be an alias for the rich root equivalent
3854
# of the default format
3855
format_registry.register_metadir('default-rich-root',
3856
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack4',
3857
help='Default format, rich root variant. (needed for bzr-svn and bzr-git).',
3858
branch_format='bzrlib.branch.BzrBranchFormat6',
3859
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3147
format_registry.register_metadir('development2',
3148
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2',
3149
help='1.6.1 with B+Tree based index. '
3151
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3153
branch_format='bzrlib.branch.BzrBranchFormat7',
3154
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3158
format_registry.register_metadir('development2-subtree',
3159
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2Subtree',
3160
help='1.6.1-subtree with B+Tree based index. '
3162
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3164
branch_format='bzrlib.branch.BzrBranchFormat7',
3165
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3862
3169
# The current format that is made on 'bzr init'.
3863
3170
format_registry.set_default('pack-0.92')