745
751
# the redirections.
746
752
base = transport.base
747
753
def find_format(transport):
748
return transport, controldir.ControlDirFormat.find_format(
754
return transport, ControlDirFormat.find_format(
749
755
transport, _server_formats=_server_formats)
751
757
def redirected(transport, e, redirection_notice):
809
815
raise errors.NotBranchError(path=url)
810
816
a_transport = new_t
818
def _get_tree_branch(self, name=None):
819
"""Return the branch and tree, if any, for this bzrdir.
821
:param name: Name of colocated branch to open.
823
Return None for tree if not present or inaccessible.
824
Raise NotBranchError if no branch is present.
825
:return: (tree, branch)
828
tree = self.open_workingtree()
829
except (errors.NoWorkingTree, errors.NotLocalUrl):
831
branch = self.open_branch(name=name)
834
branch = self.open_branch(name=name)
813
840
def open_tree_or_branch(klass, location):
814
841
"""Return the branch and working tree at a location.
938
965
t = get_transport(base, possible_transports)
940
967
if format is None:
941
format = controldir.ControlDirFormat.get_default_format()
968
format = ControlDirFormat.get_default_format()
942
969
return format.initialize_on_transport(t)
1016
1043
def cloning_metadir(self, require_stacking=False):
1017
1044
"""Produce a metadir suitable for cloning with."""
1018
1045
if require_stacking:
1019
return controldir.format_registry.make_bzrdir('1.6')
1046
return format_registry.make_bzrdir('1.6')
1020
1047
return self._format.__class__()
1022
1049
def clone(self, url, revision_id=None, force_new_repo=False,
1486
1513
raise errors.UnknownFormatError(format=format_string, kind='bzrdir')
1489
controldir.ControlDirFormat.register_prober(BzrProber)
1492
class RemoteBzrProber(controldir.Prober):
1516
ControlDirFormat.register_prober(BzrProber)
1519
class RemoteBzrProber(Prober):
1493
1520
"""Prober for remote servers that provide a Bazaar smart server."""
1517
1544
return RemoteBzrDirFormat()
1520
class BzrDirFormat(controldir.ControlDirFormat):
1547
class BzrDirFormat(ControlDirFormat):
1521
1548
"""ControlDirFormat base class for .bzr/ directories.
1523
1550
Formats are placed in a dict by their format string for reference
1697
1724
_found is a private parameter, do not use it.
1700
found_format = controldir.ControlDirFormat.find_format(transport)
1727
found_format = ControlDirFormat.find_format(transport)
1701
1728
if not isinstance(found_format, self.__class__):
1702
1729
raise AssertionError("%s was asked to open %s, but it seems to need "
1720
1747
BzrProber.register_bzrdir_format(format)
1721
1748
# bzr native formats have a network name of their format string.
1722
1749
network_format_registry.register(format.get_format_string(), format.__class__)
1723
controldir.ControlDirFormat.register_format(format)
1750
ControlDirFormat.register_format(format)
1725
1752
def _supply_sub_formats_to(self, other_format):
1726
1753
"""Give other_format the same values for sub formats as this has.
1738
1765
def unregister_format(klass, format):
1739
1766
BzrProber.unregister_bzrdir_format(format)
1740
controldir.ControlDirFormat.unregister_format(format)
1767
ControlDirFormat.unregister_format(format)
1741
1768
network_format_registry.remove(format.get_format_string())
2162
2189
BzrDirFormat.register_format(BzrDirFormat6())
2163
2190
__default_format = BzrDirMetaFormat1()
2164
2191
BzrDirFormat.register_format(__default_format)
2165
controldir.ControlDirFormat._default_format = __default_format
2192
ControlDirFormat._default_format = __default_format
2168
2195
class Converter(object):
2934
2961
BzrDirMetaFormat1._set_repository_format) #.im_func)
2937
controldir.ControlDirFormat.register_server_prober(RemoteBzrProber)
2964
ControlDirFormat.register_server_prober(RemoteBzrProber)
2940
2967
class RepositoryAcquisitionPolicy(object):
3144
3171
# The pre-0.8 formats have their repository format network name registered in
3145
3172
# repository.py. MetaDir formats have their repository format network name
3146
3173
# inferred from their disk format string.
3147
controldir.format_registry.register('weave', BzrDirFormat6,
3174
format_registry.register('weave', BzrDirFormat6,
3148
3175
'Pre-0.8 format. Slower than knit and does not'
3149
3176
' support checkouts or shared repositories.',
3151
3178
deprecated=True)
3152
register_metadir(controldir.format_registry, 'metaweave',
3179
register_metadir(format_registry, 'metaweave',
3153
3180
'bzrlib.repofmt.weaverepo.RepositoryFormat7',
3154
3181
'Transitional format in 0.8. Slower than knit.',
3155
3182
branch_format='bzrlib.branch.BzrBranchFormat5',
3156
3183
tree_format='bzrlib.workingtree.WorkingTreeFormat3',
3158
3185
deprecated=True)
3159
register_metadir(controldir.format_registry, 'knit',
3186
register_metadir(format_registry, 'knit',
3160
3187
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3161
3188
'Format using knits. Recommended for interoperation with bzr <= 0.14.',
3162
3189
branch_format='bzrlib.branch.BzrBranchFormat5',
3163
3190
tree_format='bzrlib.workingtree.WorkingTreeFormat3',
3165
3192
deprecated=True)
3166
register_metadir(controldir.format_registry, 'dirstate',
3193
register_metadir(format_registry, 'dirstate',
3167
3194
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3168
3195
help='New in 0.15: Fast local operations. Compatible with bzr 0.8 and '
3169
3196
'above when accessed over the network.',
3173
3200
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3175
3202
deprecated=True)
3176
register_metadir(controldir.format_registry, 'dirstate-tags',
3203
register_metadir(format_registry, 'dirstate-tags',
3177
3204
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3178
3205
help='New in 0.15: Fast local operations and improved scaling for '
3179
3206
'network operations. Additionally adds support for tags.'
3182
3209
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3184
3211
deprecated=True)
3185
register_metadir(controldir.format_registry, 'rich-root',
3212
register_metadir(format_registry, 'rich-root',
3186
3213
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit4',
3187
3214
help='New in 1.0. Better handling of tree roots. Incompatible with'
3190
3217
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3192
3219
deprecated=True)
3193
register_metadir(controldir.format_registry, 'dirstate-with-subtree',
3220
register_metadir(format_registry, 'dirstate-with-subtree',
3194
3221
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit3',
3195
3222
help='New in 0.15: Fast local operations and improved scaling for '
3196
3223
'network operations. Additionally adds support for versioning nested '
3200
3227
experimental=True,
3203
register_metadir(controldir.format_registry, 'pack-0.92',
3230
register_metadir(format_registry, 'pack-0.92',
3204
3231
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack1',
3205
3232
help='New in 0.92: Pack-based format with data compatible with '
3206
3233
'dirstate-tags format repositories. Interoperates with '
3209
3236
branch_format='bzrlib.branch.BzrBranchFormat6',
3210
3237
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3212
register_metadir(controldir.format_registry, 'pack-0.92-subtree',
3239
register_metadir(format_registry, 'pack-0.92-subtree',
3213
3240
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack3',
3214
3241
help='New in 0.92: Pack-based format with data compatible with '
3215
3242
'dirstate-with-subtree format repositories. Interoperates with '
3221
3248
experimental=True,
3223
register_metadir(controldir.format_registry, 'rich-root-pack',
3250
register_metadir(format_registry, 'rich-root-pack',
3224
3251
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack4',
3225
3252
help='New in 1.0: A variant of pack-0.92 that supports rich-root data '
3226
3253
'(needed for bzr-svn and bzr-git).',
3228
3255
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3231
register_metadir(controldir.format_registry, '1.6',
3258
register_metadir(format_registry, '1.6',
3232
3259
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5',
3233
3260
help='A format that allows a branch to indicate that there is another '
3234
3261
'(stacked) repository that should be used to access data that is '
3237
3264
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3240
register_metadir(controldir.format_registry, '1.6.1-rich-root',
3267
register_metadir(format_registry, '1.6.1-rich-root',
3241
3268
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5RichRoot',
3242
3269
help='A variant of 1.6 that supports rich-root data '
3243
3270
'(needed for bzr-svn and bzr-git).',
3245
3272
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3248
register_metadir(controldir.format_registry, '1.9',
3275
register_metadir(format_registry, '1.9',
3249
3276
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
3250
3277
help='A repository format using B+tree indexes. These indexes '
3251
3278
'are smaller in size, have smarter caching and provide faster '
3254
3281
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3257
register_metadir(controldir.format_registry, '1.9-rich-root',
3284
register_metadir(format_registry, '1.9-rich-root',
3258
3285
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
3259
3286
help='A variant of 1.9 that supports rich-root data '
3260
3287
'(needed for bzr-svn and bzr-git).',
3262
3289
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3265
register_metadir(controldir.format_registry, '1.14',
3292
register_metadir(format_registry, '1.14',
3266
3293
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
3267
3294
help='A working-tree format that supports content filtering.',
3268
3295
branch_format='bzrlib.branch.BzrBranchFormat7',
3269
3296
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3271
register_metadir(controldir.format_registry, '1.14-rich-root',
3298
register_metadir(format_registry, '1.14-rich-root',
3272
3299
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
3273
3300
help='A variant of 1.14 that supports rich-root data '
3274
3301
'(needed for bzr-svn and bzr-git).',
3276
3303
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3278
3305
# The following un-numbered 'development' formats should always just be aliases.
3279
register_metadir(controldir.format_registry, 'development-rich-root',
3306
register_metadir(format_registry, 'development-rich-root',
3280
3307
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK1',
3281
3308
help='Current development format. Supports rich roots. Can convert data '
3282
3309
'to and from rich-root-pack (and anything compatible with '
3293
register_metadir(controldir.format_registry, 'development-subtree',
3320
register_metadir(format_registry, 'development-subtree',
3294
3321
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2Subtree',
3295
3322
help='Current development format, subtree variant. Can convert data to and '
3296
3323
'from pack-0.92-subtree (and anything compatible with '
3310
3337
# And the development formats above will have aliased one of the following:
3311
register_metadir(controldir.format_registry, 'development6-rich-root',
3338
register_metadir(format_registry, 'development6-rich-root',
3312
3339
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK1',
3313
3340
help='pack-1.9 with 255-way hashed CHK inv, group compress, rich roots '
3320
3347
experimental=True,
3323
register_metadir(controldir.format_registry, 'development7-rich-root',
3350
register_metadir(format_registry, 'development7-rich-root',
3324
3351
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK2',
3325
3352
help='pack-1.9 with 255-way hashed CHK inv, bencode revision, group compress, '
3326
3353
'rich roots. Please read '
3332
3359
experimental=True,
3335
register_metadir(controldir.format_registry, '2a',
3362
register_metadir(format_registry, '2a',
3336
3363
'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2a',
3337
3364
help='First format for bzr 2.0 series.\n'
3338
3365
'Uses group-compress storage.\n'
3347
3374
# The following format should be an alias for the rich root equivalent
3348
3375
# of the default format
3349
register_metadir(controldir.format_registry, 'default-rich-root',
3376
register_metadir(format_registry, 'default-rich-root',
3350
3377
'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2a',
3351
3378
branch_format='bzrlib.branch.BzrBranchFormat7',
3352
3379
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3355
3382
help='Same as 2a.')
3357
3384
# The current format that is made on 'bzr init'.
3358
controldir.format_registry.set_default('2a')
3360
# XXX 2010-08-20 JRV: There is still a lot of code relying on
3361
# bzrlib.bzrdir.format_registry existing. When BzrDir.create/BzrDir.open/etc
3362
# get changed to ControlDir.create/ControlDir.open/etc this should be removed.
3363
format_registry = controldir.format_registry
3385
format_registry.set_default('2a')