~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Alexander Belchenko
  • Date: 2008-02-06 15:33:12 UTC
  • mto: This revision was merged to the branch mainline in revision 3231.
  • Revision ID: bialix@ukr.net-20080206153312-qycs7u05d7fjtwqq
Ian's review

Show diffs side-by-side

added added

removed removed

Lines of Context:
456
456
        return bzrdir.create_workingtree()
457
457
 
458
458
    def create_workingtree(self, revision_id=None, from_branch=None,
459
 
        accelerator_tree=None, hardlink=False):
 
459
        accelerator_tree=None):
460
460
        """Create a working tree at this BzrDir.
461
461
        
462
462
        :param revision_id: create it as of this revision id.
748
748
    def _get_tree_branch(self):
749
749
        """Return the branch and tree, if any, for this bzrdir.
750
750
 
751
 
        Return None for tree if not present or inaccessible.
 
751
        Return None for tree if not present.
752
752
        Raise NotBranchError if no branch is present.
753
753
        :return: (tree, branch)
754
754
        """
890
890
 
891
891
    def sprout(self, url, revision_id=None, force_new_repo=False,
892
892
               recurse='down', possible_transports=None,
893
 
               accelerator_tree=None, hardlink=False):
 
893
               accelerator_tree=None):
894
894
        """Create a copy of this bzrdir prepared for use as a new line of
895
895
        development.
896
896
 
907
907
            contents more quickly than the revision tree, i.e. a workingtree.
908
908
            The revision tree will be used for cases where accelerator_tree's
909
909
            content is different.
910
 
        :param hardlink: If true, hard-link files from accelerator_tree,
911
 
            where possible.
912
910
        """
913
911
        target_transport = get_transport(url, possible_transports)
914
912
        target_transport.ensure_base()
953
951
            result.create_branch()
954
952
        if isinstance(target_transport, LocalTransport) and (
955
953
            result_repo is None or result_repo.make_working_trees()):
956
 
            wt = result.create_workingtree(accelerator_tree=accelerator_tree,
957
 
                hardlink=hardlink)
 
954
            wt = result.create_workingtree(accelerator_tree=accelerator_tree)
958
955
            wt.lock_write()
959
956
            try:
960
957
                if wt.path2id('') is None:
1049
1046
        raise errors.UnsupportedOperation(self.destroy_repository, self)
1050
1047
 
1051
1048
    def create_workingtree(self, revision_id=None, from_branch=None,
1052
 
                           accelerator_tree=None, hardlink=False):
 
1049
                           accelerator_tree=None):
1053
1050
        """See BzrDir.create_workingtree."""
1054
1051
        # this looks buggy but is not -really-
1055
1052
        # because this format creates the workingtree when the bzrdir is
1123
1120
        return format.open(self, _found=True)
1124
1121
 
1125
1122
    def sprout(self, url, revision_id=None, force_new_repo=False,
1126
 
               possible_transports=None, accelerator_tree=None,
1127
 
               hardlink=False):
 
1123
               possible_transports=None, accelerator_tree=None):
1128
1124
        """See BzrDir.sprout()."""
1129
1125
        from bzrlib.workingtree import WorkingTreeFormat2
1130
1126
        self._make_tail(url)
1139
1135
            pass
1140
1136
        # we always want a working tree
1141
1137
        WorkingTreeFormat2().initialize(result,
1142
 
                                        accelerator_tree=accelerator_tree,
1143
 
                                        hardlink=hardlink)
 
1138
                                        accelerator_tree=accelerator_tree)
1144
1139
        return result
1145
1140
 
1146
1141
 
1235
1230
        self.transport.delete_tree('repository')
1236
1231
 
1237
1232
    def create_workingtree(self, revision_id=None, from_branch=None,
1238
 
                           accelerator_tree=None, hardlink=False):
 
1233
                           accelerator_tree=None):
1239
1234
        """See BzrDir.create_workingtree."""
1240
1235
        return self._format.workingtree_format.initialize(
1241
1236
            self, revision_id, from_branch=from_branch,
1242
 
            accelerator_tree=accelerator_tree, hardlink=hardlink)
 
1237
            accelerator_tree=accelerator_tree)
1243
1238
 
1244
1239
    def destroy_workingtree(self):
1245
1240
        """See BzrDir.destroy_workingtree."""
1436
1431
        try:
1437
1432
            return klass._formats[format_string]
1438
1433
        except KeyError:
1439
 
            raise errors.UnknownFormatError(format=format_string, kind='bzrdir')
 
1434
            raise errors.UnknownFormatError(format=format_string)
1440
1435
 
1441
1436
    @classmethod
1442
1437
    def get_default_format(klass):
1491
1486
        mutter('created control directory in ' + transport.base)
1492
1487
        control = transport.clone('.bzr')
1493
1488
        utf8_files = [('README', 
1494
 
                       "This is a Bazaar control directory.\n"
1495
 
                       "Do not change any files in this directory.\n"
1496
 
                       "See http://bazaar-vcs.org/ for more information about Bazaar.\n"),
 
1489
                       "This is a Bazaar-NG control directory.\n"
 
1490
                       "Do not change any files in this directory.\n"),
1497
1491
                      ('branch-format', self.get_format_string()),
1498
1492
                      ]
1499
1493
        # NB: no need to escape relative paths that are url safe.
2453
2447
    e.g. BzrDirMeta1 with weave repository.  Also, it's more user-oriented.
2454
2448
    """
2455
2449
 
2456
 
    def __init__(self):
2457
 
        """Create a BzrDirFormatRegistry."""
2458
 
        self._aliases = set()
2459
 
        super(BzrDirFormatRegistry, self).__init__()
2460
 
 
2461
 
    def aliases(self):
2462
 
        """Return a set of the format names which are aliases."""
2463
 
        return frozenset(self._aliases)
2464
 
 
2465
2450
    def register_metadir(self, key,
2466
2451
             repository_format, help, native=True, deprecated=False,
2467
2452
             branch_format=None,
2468
2453
             tree_format=None,
2469
2454
             hidden=False,
2470
 
             experimental=False,
2471
 
             alias=False):
 
2455
             experimental=False):
2472
2456
        """Register a metadir subformat.
2473
2457
 
2474
2458
        These all use a BzrDirMetaFormat1 bzrdir, but can be parameterized
2507
2491
                bd.repository_format = _load(repository_format)
2508
2492
            return bd
2509
2493
        self.register(key, helper, help, native, deprecated, hidden,
2510
 
            experimental, alias)
 
2494
            experimental)
2511
2495
 
2512
2496
    def register(self, key, factory, help, native=True, deprecated=False,
2513
 
                 hidden=False, experimental=False, alias=False):
 
2497
                 hidden=False, experimental=False):
2514
2498
        """Register a BzrDirFormat factory.
2515
2499
        
2516
2500
        The factory must be a callable that takes one parameter: the key.
2519
2503
        This function mainly exists to prevent the info object from being
2520
2504
        supplied directly.
2521
2505
        """
2522
 
        registry.Registry.register(self, key, factory, help,
 
2506
        registry.Registry.register(self, key, factory, help, 
2523
2507
            BzrDirFormatInfo(native, deprecated, hidden, experimental))
2524
 
        if alias:
2525
 
            self._aliases.add(key)
2526
2508
 
2527
2509
    def register_lazy(self, key, module_name, member_name, help, native=True,
2528
 
        deprecated=False, hidden=False, experimental=False, alias=False):
2529
 
        registry.Registry.register_lazy(self, key, module_name, member_name,
 
2510
                      deprecated=False, hidden=False, experimental=False):
 
2511
        registry.Registry.register_lazy(self, key, module_name, member_name, 
2530
2512
            help, BzrDirFormatInfo(native, deprecated, hidden, experimental))
2531
 
        if alias:
2532
 
            self._aliases.add(key)
2533
2513
 
2534
2514
    def set_default(self, key):
2535
2515
        """Set the 'default' key to be a clone of the supplied key.
2536
2516
        
2537
2517
        This method must be called once and only once.
2538
2518
        """
2539
 
        registry.Registry.register(self, 'default', self.get(key),
 
2519
        registry.Registry.register(self, 'default', self.get(key), 
2540
2520
            self.get_help(key), info=self.get_info(key))
2541
 
        self._aliases.add('default')
2542
2521
 
2543
2522
    def set_default_repository(self, key):
2544
2523
        """Set the FormatRegistry default and Repository default.
2690
2669
    branch_format='bzrlib.branch.BzrBranchFormat6',
2691
2670
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2692
2671
    )
2693
 
# The following two formats should always just be aliases.
2694
 
format_registry.register_metadir('development',
2695
 
    'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment0',
2696
 
    help='Current development format. Can convert data to and from pack-0.92 '
2697
 
        '(and anything compatible with pack-0.92) format repositories. '
2698
 
        'Repositories in this format can only be read by bzr.dev. '
2699
 
        'Please read '
2700
 
        'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
2701
 
        'before use.',
2702
 
    branch_format='bzrlib.branch.BzrBranchFormat6',
2703
 
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2704
 
    experimental=True,
2705
 
    alias=True,
2706
 
    )
2707
 
format_registry.register_metadir('development-subtree',
2708
 
    'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment0Subtree',
2709
 
    help='Current development format, subtree variant. Can convert data to and '
2710
 
        'from pack-0.92 (and anything compatible with pack-0.92) format '
2711
 
        'repositories. Repositories in this format can only be read by '
2712
 
        'bzr.dev. Please read '
2713
 
        'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
2714
 
        'before use.',
2715
 
    branch_format='bzrlib.branch.BzrBranchFormat6',
2716
 
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2717
 
    experimental=True,
2718
 
    alias=True,
2719
 
    )
2720
 
# And the development formats which the will have aliased one of follow:
2721
 
format_registry.register_metadir('development0',
2722
 
    'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment0',
2723
 
    help='Trivial rename of pack-0.92 to provide a development format. '
2724
 
        'Please read '
2725
 
        'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
2726
 
        'before use.',
2727
 
    branch_format='bzrlib.branch.BzrBranchFormat6',
2728
 
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2729
 
    hidden=True,
2730
 
    experimental=True,
2731
 
    )
2732
 
format_registry.register_metadir('development0-subtree',
2733
 
    'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment0Subtree',
2734
 
    help='Trivial rename of pack-0.92-subtree to provide a development format. '
2735
 
        'Please read '
2736
 
        'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
2737
 
        'before use.',
2738
 
    branch_format='bzrlib.branch.BzrBranchFormat6',
2739
 
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2740
 
    hidden=True,
2741
 
    experimental=True,
2742
 
    )
2743
2672
format_registry.set_default('pack-0.92')