/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Lukáš Lalinský
  • Date: 2007-12-17 17:28:25 UTC
  • mfrom: (3120 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3123.
  • Revision ID: lalinsky@gmail.com-20071217172825-tr3pqm1mhvs3gwnn
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
from cStringIO import StringIO
31
31
import os
 
32
import sys
32
33
 
33
34
from bzrlib.lazy_import import lazy_import
34
35
lazy_import(globals(), """
48
49
    symbol_versioning,
49
50
    ui,
50
51
    urlutils,
 
52
    win32utils,
 
53
    workingtree,
 
54
    workingtree_4,
51
55
    xml4,
52
56
    xml5,
53
 
    workingtree,
54
 
    workingtree_4,
55
57
    )
56
58
from bzrlib.osutils import (
57
59
    sha_strings,
209
211
        except errors.NotBranchError:
210
212
            pass
211
213
        try:
212
 
            self.open_workingtree().clone(result)
213
 
        except (errors.NoWorkingTree, errors.NotLocalUrl):
214
 
            pass
 
214
            result_repo = result.find_repository()
 
215
        except errors.NoRepositoryPresent:
 
216
            result_repo = None
 
217
        if result_repo is None or result_repo.make_working_trees():
 
218
            try:
 
219
                self.open_workingtree().clone(result)
 
220
            except (errors.NoWorkingTree, errors.NotLocalUrl):
 
221
                pass
215
222
        return result
216
223
 
217
224
    # TODO: This should be given a Transport, and should chdir up; otherwise
238
245
            format = BzrDirFormat.get_default_format()
239
246
        return format.initialize_on_transport(t)
240
247
 
 
248
    def destroy_repository(self):
 
249
        """Destroy the repository in this BzrDir"""
 
250
        raise NotImplementedError(self.destroy_repository)
 
251
 
241
252
    def create_branch(self):
242
253
        """Create a branch in this BzrDir.
243
254
 
370
381
                                               format=format).bzrdir
371
382
        return bzrdir.create_workingtree()
372
383
 
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.
375
386
        
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)
377
389
        """
378
390
        raise NotImplementedError(self.create_workingtree)
379
391
 
687
699
        raise NotImplementedError(self.open_repository)
688
700
 
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.
692
704
 
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)
697
710
        """
698
711
        raise NotImplementedError(self.open_workingtree)
699
712
 
922
935
            raise errors.IncompatibleFormat('shared repository', self._format)
923
936
        return self.open_repository()
924
937
 
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)
 
941
 
 
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)
1102
1119
 
1103
 
    def create_workingtree(self, revision_id=None):
 
1120
    def destroy_repository(self):
 
1121
        """See BzrDir.destroy_repository."""
 
1122
        self.transport.delete_tree('repository')
 
1123
 
 
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)
1107
1128
 
1108
1129
    def destroy_workingtree(self):
1109
1130
        """See BzrDir.destroy_workingtree."""
1348
1369
                                      # FIXME: RBC 20060121 don't peek under
1349
1370
                                      # the covers
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()
1711
1734
 
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
1715
1738
 
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',
2482
2505
    )
 
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'
 
2509
        ' bzr < 1.0',
 
2510
    branch_format='bzrlib.branch.BzrBranchFormat6',
 
2511
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
 
2512
    hidden=False,
 
2513
    )
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',
2490
2521
    hidden=True,
2491
2522
    )
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,
2502
2534
    )
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',
 
2545
    hidden=True,
 
2546
    experimental=True,
 
2547
    )
 
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',
2512
 
    hidden=True,
 
2557
    hidden=False,
2513
2558
    experimental=True,
2514
2559
    )
2515
 
format_registry.set_default('dirstate-tags')
 
2560
format_registry.set_default('pack-0.92')