68
67
from bzrlib.repofmt import pack_repo
69
68
from bzrlib.smart.client import _SmartClient
70
from bzrlib.store.versioned import VersionedFileStore
69
from bzrlib.store.versioned import WeaveStore
71
70
from bzrlib.transactions import WriteTransaction
72
71
from bzrlib.transport import (
73
72
do_catching_redirections,
76
from bzrlib.weave import (
76
from bzrlib.weave import Weave
82
79
from bzrlib.trace import (
190
187
:param create_prefix: Create any missing directories leading up to
192
189
:param use_existing_dir: Use an existing directory if one exists.
193
:param no_tree: If set to true prevents creation of a working tree.
195
191
# Overview: put together a broad description of what we want to end up
196
192
# with; then make as few api calls as possible to do it.
470
466
if force_new_tree:
471
467
# check for non local urls
472
t = _mod_transport.get_transport(base, possible_transports)
468
t = get_transport(base, possible_transports)
473
469
if not isinstance(t, local.LocalTransport):
474
470
raise errors.NotLocalUrl(base)
475
471
bzrdir = BzrDir.create(base, format, possible_transports)
497
493
:param format: Override for the bzrdir format to create.
498
494
:return: The WorkingTree object.
500
t = _mod_transport.get_transport(base)
496
t = get_transport(base)
501
497
if not isinstance(t, local.LocalTransport):
502
498
raise errors.NotLocalUrl(base)
503
499
bzrdir = BzrDir.create_branch_and_repo(base,
718
714
:param _unsupported: a private parameter to the BzrDir class.
720
t = _mod_transport.get_transport(base, possible_transports)
716
t = get_transport(base, possible_transports=possible_transports)
721
717
return BzrDir.open_from_transport(t, _unsupported=_unsupported)
762
758
:param url: url to search from.
763
759
See open_containing_from_transport for more detail.
765
transport = _mod_transport.get_transport(url, possible_transports)
761
transport = get_transport(url, possible_transports)
766
762
return BzrDir.open_containing_from_transport(transport)
924
920
if cls is not BzrDir:
925
921
raise AssertionError("BzrDir.create always creates the"
926
922
"default format, not one of %r" % cls)
927
t = _mod_transport.get_transport(base, possible_transports)
923
t = get_transport(base, possible_transports)
929
925
if format is None:
930
926
format = controldir.ControlDirFormat.get_default_format()
931
927
return format.initialize_on_transport(t)
934
931
class BzrDirHooks(hooks.Hooks):
935
932
"""Hooks for BzrDir operations."""
1030
1027
tree.clone(result)
1033
def create_branch(self, name=None, repository=None):
1030
def create_branch(self, name=None):
1034
1031
"""See BzrDir.create_branch."""
1035
if repository is not None:
1036
raise NotImplementedError(
1037
"create_branch(repository=<not None>) on %r" % (self,))
1038
1032
return self._format.get_branch_format().initialize(self, name=name)
1040
1034
def destroy_branch(self, name=None):
1270
1264
"""See BzrDir.can_convert_format()."""
1273
def create_branch(self, name=None, repository=None):
1267
def create_branch(self, name=None):
1274
1268
"""See BzrDir.create_branch."""
1275
return self._format.get_branch_format().initialize(self, name=name,
1276
repository=repository)
1269
return self._format.get_branch_format().initialize(self, name=name)
1278
1271
def destroy_branch(self, name=None):
1279
1272
"""See BzrDir.create_branch."""
1670
1663
utf8_files = [('README',
1671
1664
"This is a Bazaar control directory.\n"
1672
1665
"Do not change any files in this directory.\n"
1673
"See http://bazaar.canonical.com/ for more information about Bazaar.\n"),
1666
"See http://bazaar-vcs.org/ for more information about Bazaar.\n"),
1674
1667
('branch-format', self.get_format_string()),
1676
1669
# NB: no need to escape relative paths that are url safe.
1847
1840
return ConvertBzrDir5To6()
1849
1842
def _initialize_for_clone(self, url):
1850
return self.initialize_on_transport(
1851
_mod_transport.get_transport(url), _cloning=True)
1843
return self.initialize_on_transport(get_transport(url), _cloning=True)
1853
1845
def initialize_on_transport(self, transport, _cloning=False):
1854
1846
"""Format 5 dirs always have working tree, branch and repository.
1908
1900
return ConvertBzrDir6ToMeta()
1910
1902
def _initialize_for_clone(self, url):
1911
return self.initialize_on_transport(
1912
_mod_transport.get_transport(url), _cloning=True)
1903
return self.initialize_on_transport(get_transport(url), _cloning=True)
1914
1905
def initialize_on_transport(self, transport, _cloning=False):
1915
1906
"""Format 6 dirs always have working tree, branch and repository.
2103
2094
"""Circular import protection."""
2104
2095
if self._repository_format:
2105
2096
return self._repository_format
2106
from bzrlib.repository import format_registry
2107
return format_registry.get_default()
2097
from bzrlib.repository import RepositoryFormat
2098
return RepositoryFormat.get_default_format()
2109
2100
def _set_repository_format(self, value):
2110
2101
"""Allow changing the repository format for metadir formats."""
2258
2249
mode=self.bzrdir._get_file_mode())
2260
2251
def _write_all_weaves(self):
2261
controlweaves = VersionedFileStore(self.bzrdir.transport, prefixed=False,
2262
versionedfile_class=WeaveFile)
2252
controlweaves = WeaveStore(self.bzrdir.transport, prefixed=False)
2263
2253
weave_transport = self.bzrdir.transport.clone('weaves')
2264
weaves = VersionedFileStore(weave_transport, prefixed=False,
2265
versionedfile_class=WeaveFile)
2254
weaves = WeaveStore(weave_transport, prefixed=False)
2266
2255
transaction = WriteTransaction()
3265
3254
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3267
3256
# The following un-numbered 'development' formats should always just be aliases.
3257
register_metadir(controldir.format_registry, 'development-rich-root',
3258
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK1',
3259
help='Current development format. Supports rich roots. Can convert data '
3260
'to and from rich-root-pack (and anything compatible with '
3261
'rich-root-pack) format repositories. Repositories and branches in '
3262
'this format can only be read by bzr.dev. Please read '
3263
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
3265
branch_format='bzrlib.branch.BzrBranchFormat7',
3266
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3271
register_metadir(controldir.format_registry, 'development5-subtree',
3272
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2Subtree',
3273
help='Development format, subtree variant. Can convert data to and '
3274
'from pack-0.92-subtree (and anything compatible with '
3275
'pack-0.92-subtree) format repositories. Repositories and branches in '
3276
'this format can only be read by bzr.dev. Please read '
3277
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
3279
branch_format='bzrlib.branch.BzrBranchFormat7',
3280
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3268
3287
register_metadir(controldir.format_registry, 'development-subtree',
3269
3288
'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2aSubtree',
3270
3289
help='Current development format, subtree variant. Can convert data to and '
3281
3300
# This current non-alias status is simply because we did not introduce a
3282
3301
# chk based subtree format.
3284
register_metadir(controldir.format_registry, 'development5-subtree',
3285
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2Subtree',
3286
help='Development format, subtree variant. Can convert data to and '
3287
'from pack-0.92-subtree (and anything compatible with '
3288
'pack-0.92-subtree) format repositories. Repositories and branches in '
3289
'this format can only be read by bzr.dev. Please read '
3290
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
3292
branch_format='bzrlib.branch.BzrBranchFormat7',
3293
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3299
3304
# And the development formats above will have aliased one of the following:
3301
# Finally, the current format.
3305
register_metadir(controldir.format_registry, 'development6-rich-root',
3306
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK1',
3307
help='pack-1.9 with 255-way hashed CHK inv, group compress, rich roots '
3309
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
3311
branch_format='bzrlib.branch.BzrBranchFormat7',
3312
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3317
register_metadir(controldir.format_registry, 'development7-rich-root',
3318
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK2',
3319
help='pack-1.9 with 255-way hashed CHK inv, bencode revision, group compress, '
3320
'rich roots. Please read '
3321
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
3323
branch_format='bzrlib.branch.BzrBranchFormat7',
3324
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3302
3329
register_metadir(controldir.format_registry, '2a',
3303
3330
'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2a',
3304
3331
help='First format for bzr 2.0 series.\n'