168
173
def clone_on_transport(self, transport, revision_id=None,
169
174
force_new_repo=False, preserve_stacking=False, stacked_on=None,
170
create_prefix=False, use_existing_dir=True):
175
create_prefix=False, use_existing_dir=True, no_tree=False):
171
176
"""Clone this bzrdir and its contents to transport verbatim.
173
178
:param transport: The transport for the location to produce the clone
215
220
# we should look up the policy needs first, or just use it as a hint,
218
make_working_trees = local_repo.make_working_trees()
223
make_working_trees = local_repo.make_working_trees() and not no_tree
219
224
want_shared = local_repo.is_shared()
220
225
repo_format_name = format.repository_format.network_name()
496
501
format=format).bzrdir
497
502
return bzrdir.create_workingtree()
504
@deprecated_method(deprecated_in((2, 3, 0)))
499
505
def generate_backup_name(self, base):
500
"""Generate a non-existing backup file name based on base."""
502
name = "%s.~%d~" % (base, counter)
503
while self.root_transport.has(name):
505
name = "%s.~%d~" % (base, counter)
506
return self._available_backup_name(base)
508
def _available_backup_name(self, base):
509
"""Find a non-existing backup file name based on base.
511
See bzrlib.osutils.available_backup_name about race conditions.
513
return osutils.available_backup_name(base, self.root_transport.has)
508
515
def backup_bzrdir(self):
509
516
"""Backup this bzr control directory.
511
518
:return: Tuple with old path name and new path name
514
backup_dir=self.generate_backup_name('backup.bzr')
515
521
pb = ui.ui_factory.nested_progress_bar()
517
# FIXME: bug 300001 -- the backup fails if the backup directory
518
# already exists, but it should instead either remove it or make
519
# a new backup directory.
521
523
old_path = self.root_transport.abspath('.bzr')
524
backup_dir = self._available_backup_name('backup.bzr')
522
525
new_path = self.root_transport.abspath(backup_dir)
523
ui.ui_factory.note('making backup of %s\n to %s' % (old_path, new_path,))
526
ui.ui_factory.note('making backup of %s\n to %s'
527
% (old_path, new_path,))
524
528
self.root_transport.copy_tree('.bzr', backup_dir)
525
529
return (old_path, new_path)
1290
1294
wt = self.open_workingtree(recommend_upgrade=False)
1291
1295
repository = wt.branch.repository
1292
1296
empty = repository.revision_tree(_mod_revision.NULL_REVISION)
1293
wt.revert(old_tree=empty)
1297
# We ignore the conflicts returned by wt.revert since we're about to
1298
# delete the wt metadata anyway, all that should be left here are
1299
# detritus. But see bug #634470 about subtree .bzr dirs.
1300
conflicts = wt.revert(old_tree=empty)
1294
1301
self.destroy_workingtree_metadata()
1296
1303
def destroy_workingtree_metadata(self):
3092
3099
def _load(full_name):
3093
3100
mod_name, factory_name = full_name.rsplit('.', 1)
3095
mod = __import__(mod_name, globals(), locals(),
3102
factory = pyutils.get_named_object(mod_name, factory_name)
3097
3103
except ImportError, e:
3098
3104
raise ImportError('failed to load %s: %s' % (full_name, e))
3100
factory = getattr(mod, factory_name)
3101
3105
except AttributeError:
3102
3106
raise AttributeError('no factory %s in module %r'
3107
% (full_name, sys.modules[mod_name]))
3104
3108
return factory()
3250
3254
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3252
3256
# The following un-numbered 'development' formats should always just be aliases.
3253
register_metadir(controldir.format_registry, 'development-rich-root',
3254
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK1',
3255
help='Current development format. Supports rich roots. Can convert data '
3256
'to and from rich-root-pack (and anything compatible with '
3257
'rich-root-pack) format repositories. Repositories and branches in '
3258
'this format can only be read by bzr.dev. Please read '
3259
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
3261
branch_format='bzrlib.branch.BzrBranchFormat7',
3262
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3267
register_metadir(controldir.format_registry, 'development5-subtree',
3268
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2Subtree',
3269
help='Development format, subtree variant. Can convert data to and '
3270
'from pack-0.92-subtree (and anything compatible with '
3271
'pack-0.92-subtree) format repositories. Repositories and branches in '
3272
'this format can only be read by bzr.dev. Please read '
3273
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
3275
branch_format='bzrlib.branch.BzrBranchFormat7',
3276
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3283
3257
register_metadir(controldir.format_registry, 'development-subtree',
3284
3258
'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2aSubtree',
3285
3259
help='Current development format, subtree variant. Can convert data to and '
3296
3270
# This current non-alias status is simply because we did not introduce a
3297
3271
# chk based subtree format.
3273
register_metadir(controldir.format_registry, 'development5-subtree',
3274
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2Subtree',
3275
help='Development format, subtree variant. Can convert data to and '
3276
'from pack-0.92-subtree (and anything compatible with '
3277
'pack-0.92-subtree) format repositories. Repositories and branches in '
3278
'this format can only be read by bzr.dev. Please read '
3279
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
3281
branch_format='bzrlib.branch.BzrBranchFormat7',
3282
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3300
3288
# And the development formats above will have aliased one of the following:
3301
register_metadir(controldir.format_registry, 'development6-rich-root',
3302
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK1',
3303
help='pack-1.9 with 255-way hashed CHK inv, group compress, rich roots '
3305
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
3307
branch_format='bzrlib.branch.BzrBranchFormat7',
3308
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3313
register_metadir(controldir.format_registry, 'development7-rich-root',
3314
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK2',
3315
help='pack-1.9 with 255-way hashed CHK inv, bencode revision, group compress, '
3316
'rich roots. Please read '
3317
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
3319
branch_format='bzrlib.branch.BzrBranchFormat7',
3320
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3290
# Finally, the current format.
3325
3291
register_metadir(controldir.format_registry, '2a',
3326
3292
'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2a',
3327
3293
help='First format for bzr 2.0 series.\n'
3345
3311
help='Same as 2a.')
3347
3313
# The current format that is made on 'bzr init'.
3348
controldir.format_registry.set_default('2a')
3314
format_name = config.GlobalConfig().get_user_option('default_format')
3315
if format_name is None:
3316
controldir.format_registry.set_default('2a')
3318
controldir.format_registry.set_default(format_name)
3350
3320
# XXX 2010-08-20 JRV: There is still a lot of code relying on
3351
3321
# bzrlib.bzrdir.format_registry existing. When BzrDir.create/BzrDir.open/etc