~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Aaron Bentley
  • Date: 2008-03-03 16:52:41 UTC
  • mfrom: (3144.3.11 fix-conflict-handling)
  • mto: This revision was merged to the branch mainline in revision 3250.
  • Revision ID: aaron@aaronbentley.com-20080303165241-0k2c7ggs6kr9q6hf
Merge with fix-conflict-handling

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):
 
459
        accelerator_tree=None, hardlink=False):
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.
 
751
        Return None for tree if not present or inaccessible.
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):
 
893
               accelerator_tree=None, hardlink=False):
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.
910
912
        """
911
913
        target_transport = get_transport(url, possible_transports)
912
914
        target_transport.ensure_base()
951
953
            result.create_branch()
952
954
        if isinstance(target_transport, LocalTransport) and (
953
955
            result_repo is None or result_repo.make_working_trees()):
954
 
            wt = result.create_workingtree(accelerator_tree=accelerator_tree)
 
956
            wt = result.create_workingtree(accelerator_tree=accelerator_tree,
 
957
                hardlink=hardlink)
955
958
            wt.lock_write()
956
959
            try:
957
960
                if wt.path2id('') is None:
1046
1049
        raise errors.UnsupportedOperation(self.destroy_repository, self)
1047
1050
 
1048
1051
    def create_workingtree(self, revision_id=None, from_branch=None,
1049
 
                           accelerator_tree=None):
 
1052
                           accelerator_tree=None, hardlink=False):
1050
1053
        """See BzrDir.create_workingtree."""
1051
1054
        # this looks buggy but is not -really-
1052
1055
        # because this format creates the workingtree when the bzrdir is
1120
1123
        return format.open(self, _found=True)
1121
1124
 
1122
1125
    def sprout(self, url, revision_id=None, force_new_repo=False,
1123
 
               possible_transports=None, accelerator_tree=None):
 
1126
               possible_transports=None, accelerator_tree=None,
 
1127
               hardlink=False):
1124
1128
        """See BzrDir.sprout()."""
1125
1129
        from bzrlib.workingtree import WorkingTreeFormat2
1126
1130
        self._make_tail(url)
1135
1139
            pass
1136
1140
        # we always want a working tree
1137
1141
        WorkingTreeFormat2().initialize(result,
1138
 
                                        accelerator_tree=accelerator_tree)
 
1142
                                        accelerator_tree=accelerator_tree,
 
1143
                                        hardlink=hardlink)
1139
1144
        return result
1140
1145
 
1141
1146
 
1230
1235
        self.transport.delete_tree('repository')
1231
1236
 
1232
1237
    def create_workingtree(self, revision_id=None, from_branch=None,
1233
 
                           accelerator_tree=None):
 
1238
                           accelerator_tree=None, hardlink=False):
1234
1239
        """See BzrDir.create_workingtree."""
1235
1240
        return self._format.workingtree_format.initialize(
1236
1241
            self, revision_id, from_branch=from_branch,
1237
 
            accelerator_tree=accelerator_tree)
 
1242
            accelerator_tree=accelerator_tree, hardlink=hardlink)
1238
1243
 
1239
1244
    def destroy_workingtree(self):
1240
1245
        """See BzrDir.destroy_workingtree."""
2447
2452
    e.g. BzrDirMeta1 with weave repository.  Also, it's more user-oriented.
2448
2453
    """
2449
2454
 
 
2455
    def __init__(self):
 
2456
        """Create a BzrDirFormatRegistry."""
 
2457
        self._aliases = set()
 
2458
        super(BzrDirFormatRegistry, self).__init__()
 
2459
 
 
2460
    def aliases(self):
 
2461
        """Return a set of the format names which are aliases."""
 
2462
        return frozenset(self._aliases)
 
2463
 
2450
2464
    def register_metadir(self, key,
2451
2465
             repository_format, help, native=True, deprecated=False,
2452
2466
             branch_format=None,
2453
2467
             tree_format=None,
2454
2468
             hidden=False,
2455
 
             experimental=False):
 
2469
             experimental=False,
 
2470
             alias=False):
2456
2471
        """Register a metadir subformat.
2457
2472
 
2458
2473
        These all use a BzrDirMetaFormat1 bzrdir, but can be parameterized
2491
2506
                bd.repository_format = _load(repository_format)
2492
2507
            return bd
2493
2508
        self.register(key, helper, help, native, deprecated, hidden,
2494
 
            experimental)
 
2509
            experimental, alias)
2495
2510
 
2496
2511
    def register(self, key, factory, help, native=True, deprecated=False,
2497
 
                 hidden=False, experimental=False):
 
2512
                 hidden=False, experimental=False, alias=False):
2498
2513
        """Register a BzrDirFormat factory.
2499
2514
        
2500
2515
        The factory must be a callable that takes one parameter: the key.
2503
2518
        This function mainly exists to prevent the info object from being
2504
2519
        supplied directly.
2505
2520
        """
2506
 
        registry.Registry.register(self, key, factory, help, 
 
2521
        registry.Registry.register(self, key, factory, help,
2507
2522
            BzrDirFormatInfo(native, deprecated, hidden, experimental))
 
2523
        if alias:
 
2524
            self._aliases.add(key)
2508
2525
 
2509
2526
    def register_lazy(self, key, module_name, member_name, help, native=True,
2510
 
                      deprecated=False, hidden=False, experimental=False):
2511
 
        registry.Registry.register_lazy(self, key, module_name, member_name, 
 
2527
        deprecated=False, hidden=False, experimental=False, alias=False):
 
2528
        registry.Registry.register_lazy(self, key, module_name, member_name,
2512
2529
            help, BzrDirFormatInfo(native, deprecated, hidden, experimental))
 
2530
        if alias:
 
2531
            self._aliases.add(key)
2513
2532
 
2514
2533
    def set_default(self, key):
2515
2534
        """Set the 'default' key to be a clone of the supplied key.
2516
2535
        
2517
2536
        This method must be called once and only once.
2518
2537
        """
2519
 
        registry.Registry.register(self, 'default', self.get(key), 
 
2538
        registry.Registry.register(self, 'default', self.get(key),
2520
2539
            self.get_help(key), info=self.get_info(key))
 
2540
        self._aliases.add('default')
2521
2541
 
2522
2542
    def set_default_repository(self, key):
2523
2543
        """Set the FormatRegistry default and Repository default.
2669
2689
    branch_format='bzrlib.branch.BzrBranchFormat6',
2670
2690
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
2671
2691
    )
 
2692
# The following two formats should always just be aliases.
 
2693
format_registry.register_metadir('development',
 
2694
    'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment0',
 
2695
    help='Current development format. Can convert data to and from pack-0.92 '
 
2696
        '(and anything compatible with pack-0.92) format repositories. '
 
2697
        'Repositories in this format can only be read by bzr.dev. '
 
2698
        'Please read '
 
2699
        'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
 
2700
        'before use.',
 
2701
    branch_format='bzrlib.branch.BzrBranchFormat6',
 
2702
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
 
2703
    experimental=True,
 
2704
    alias=True,
 
2705
    )
 
2706
format_registry.register_metadir('development-subtree',
 
2707
    'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment0Subtree',
 
2708
    help='Current development format, subtree variant. Can convert data to and '
 
2709
        'from pack-0.92 (and anything compatible with pack-0.92) format '
 
2710
        'repositories. Repositories in this format can only be read by '
 
2711
        'bzr.dev. Please read '
 
2712
        'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
 
2713
        'before use.',
 
2714
    branch_format='bzrlib.branch.BzrBranchFormat6',
 
2715
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
 
2716
    experimental=True,
 
2717
    alias=True,
 
2718
    )
 
2719
# And the development formats which the will have aliased one of follow:
 
2720
format_registry.register_metadir('development0',
 
2721
    'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment0',
 
2722
    help='Trivial rename of pack-0.92 to provide a development format. '
 
2723
        'Please read '
 
2724
        'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
 
2725
        'before use.',
 
2726
    branch_format='bzrlib.branch.BzrBranchFormat6',
 
2727
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
 
2728
    hidden=True,
 
2729
    experimental=True,
 
2730
    )
 
2731
format_registry.register_metadir('development0-subtree',
 
2732
    'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment0Subtree',
 
2733
    help='Trivial rename of pack-0.92-subtree to provide a development format. '
 
2734
        'Please read '
 
2735
        'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
 
2736
        'before use.',
 
2737
    branch_format='bzrlib.branch.BzrBranchFormat6',
 
2738
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
 
2739
    hidden=True,
 
2740
    experimental=True,
 
2741
    )
2672
2742
format_registry.set_default('pack-0.92')