209
211
except errors.NotBranchError:
212
self.open_workingtree().clone(result)
213
except (errors.NoWorkingTree, errors.NotLocalUrl):
214
result_repo = result.find_repository()
215
except errors.NoRepositoryPresent:
217
if result_repo is None or result_repo.make_working_trees():
219
self.open_workingtree().clone(result)
220
except (errors.NoWorkingTree, errors.NotLocalUrl):
217
224
# TODO: This should be given a Transport, and should chdir up; otherwise
370
381
format=format).bzrdir
371
382
return bzrdir.create_workingtree()
373
def create_workingtree(self, revision_id=None):
384
def create_workingtree(self, revision_id=None, from_branch=None):
374
385
"""Create a working tree at this BzrDir.
376
revision_id: create it as of this revision id.
387
:param revision_id: create it as of this revision id.
388
:param from_branch: override bzrdir branch (for lightweight checkouts)
378
390
raise NotImplementedError(self.create_workingtree)
687
699
raise NotImplementedError(self.open_repository)
689
701
def open_workingtree(self, _unsupported=False,
690
recommend_upgrade=True):
702
recommend_upgrade=True, from_branch=None):
691
703
"""Open the workingtree object at this BzrDir if one is present.
693
705
:param recommend_upgrade: Optional keyword parameter, when True (the
694
706
default), emit through the ui module a recommendation that the user
695
707
upgrade the working tree when the workingtree being opened is old
696
708
(but still fully supported).
709
:param from_branch: override bzrdir branch (for lightweight checkouts)
698
711
raise NotImplementedError(self.open_workingtree)
922
935
raise errors.IncompatibleFormat('shared repository', self._format)
923
936
return self.open_repository()
925
def create_workingtree(self, revision_id=None):
938
def destroy_repository(self):
939
"""See BzrDir.destroy_repository."""
940
raise errors.UnsupportedOperation(self.destroy_repository, self)
942
def create_workingtree(self, revision_id=None, from_branch=None):
926
943
"""See BzrDir.create_workingtree."""
927
944
# this looks buggy but is not -really-
928
945
# because this format creates the workingtree when the bzrdir is
1100
1117
"""See BzrDir.create_repository."""
1101
1118
return self._format.repository_format.initialize(self, shared)
1103
def create_workingtree(self, revision_id=None):
1120
def destroy_repository(self):
1121
"""See BzrDir.destroy_repository."""
1122
self.transport.delete_tree('repository')
1124
def create_workingtree(self, revision_id=None, from_branch=None):
1104
1125
"""See BzrDir.create_workingtree."""
1105
from bzrlib.workingtree import WorkingTreeFormat
1106
return self._format.workingtree_format.initialize(self, revision_id)
1126
return self._format.workingtree_format.initialize(
1127
self, revision_id, from_branch=from_branch)
1108
1129
def destroy_workingtree(self):
1109
1130
"""See BzrDir.destroy_workingtree."""
1348
1369
# FIXME: RBC 20060121 don't peek under
1350
1371
mode=temp_control._dir_mode)
1372
if sys.platform == 'win32' and isinstance(transport, LocalTransport):
1373
win32utils.set_file_attr_hidden(transport._abspath('.bzr'))
1351
1374
file_mode = temp_control._file_mode
1352
1375
del temp_control
1353
1376
mutter('created control directory in ' + transport.base)
1710
1733
return RepositoryFormat.get_default_format()
1712
1735
def __set_repository_format(self, value):
1713
"""Allow changint the repository format for metadir formats."""
1736
"""Allow changing the repository format for metadir formats."""
1714
1737
self._repository_format = value
1716
1739
repository_format = property(__return_repository_format, __set_repository_format)
2480
2503
branch_format='bzrlib.branch.BzrBranchFormat6',
2481
2504
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2506
format_registry.register_metadir('rich-root',
2507
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit4',
2508
help='New in 1.0. Better handling of tree roots. Incompatible with'
2510
branch_format='bzrlib.branch.BzrBranchFormat6',
2511
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2483
2514
format_registry.register_metadir('dirstate-with-subtree',
2484
2515
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit3',
2485
2516
help='New in 0.15: Fast local operations and improved scaling for '
2489
2520
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2492
format_registry.register_metadir('knitpack-experimental',
2523
format_registry.register_metadir('pack-0.92',
2493
2524
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack1',
2494
2525
help='New in 0.92: Pack-based format with data compatible with '
2495
2526
'dirstate-tags format repositories. Interoperates with '
2496
2527
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
2497
'NOTE: This format is experimental. Before using it, please read '
2498
'http://doc.bazaar-vcs.org/latest/developers/knitpack.html.',
2528
'Previously called knitpack-experimental. '
2529
'For more information, see '
2530
'http://doc.bazaar-vcs.org/latest/developers/packrepo.html.',
2499
2531
branch_format='bzrlib.branch.BzrBranchFormat6',
2500
2532
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2501
2533
experimental=True,
2503
format_registry.register_metadir('knitpack-subtree-experimental',
2535
format_registry.register_metadir('pack-0.92-subtree',
2504
2536
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack3',
2505
2537
help='New in 0.92: Pack-based format with data compatible with '
2506
2538
'dirstate-with-subtree format repositories. Interoperates with '
2507
2539
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
2540
'Previously called knitpack-experimental. '
2541
'For more information, see '
2542
'http://doc.bazaar-vcs.org/latest/developers/packrepo.html.',
2543
branch_format='bzrlib.branch.BzrBranchFormat6',
2544
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2548
format_registry.register_metadir('rich-root-pack',
2549
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack4',
2550
help='New in 1.0: Pack-based format with data compatible with '
2551
'rich-root format repositories. Interoperates with '
2552
'bzr repositories before 0.92 but cannot be read by bzr < 1.0. '
2508
2553
'NOTE: This format is experimental. Before using it, please read '
2509
'http://doc.bazaar-vcs.org/latest/developers/knitpack.html.',
2554
'http://doc.bazaar-vcs.org/latest/developers/packrepo.html.',
2510
2555
branch_format='bzrlib.branch.BzrBranchFormat6',
2511
2556
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2513
2558
experimental=True,
2515
format_registry.set_default('dirstate-tags')
2560
format_registry.set_default('pack-0.92')