~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/pack_repo.py

  • Committer: Jelmer Vernooij
  • Date: 2011-04-05 14:47:30 UTC
  • mto: (5757.7.2 knitpackrepo-6)
  • mto: This revision was merged to the branch mainline in revision 5771.
  • Revision ID: jelmer@samba.org-20110405144730-uq6jmlblh97plv20
Add separate file for knit pack repository formats.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
    transactions,
33
33
    tsort,
34
34
    ui,
35
 
    xml5,
36
 
    xml6,
37
 
    xml7,
38
35
    )
39
36
from bzrlib.index import (
40
37
    CombinedGraphIndex,
47
44
    )
48
45
""")
49
46
from bzrlib import (
50
 
    bzrdir,
51
47
    btree_index,
52
48
    errors,
53
49
    lockable_files,
56
52
    )
57
53
 
58
54
from bzrlib.decorators import needs_write_lock, only_raises
59
 
from bzrlib.index import (
60
 
    GraphIndex,
61
 
    InMemoryGraphIndex,
62
 
    )
63
55
from bzrlib.lock import LogicalLockResult
64
56
from bzrlib.repofmt.knitrepo import KnitRepository
65
57
from bzrlib.repository import (
2601
2593
                              _serializer=self._serializer)
2602
2594
 
2603
2595
 
2604
 
class RepositoryFormatKnitPack1(RepositoryFormatPack):
2605
 
    """A no-subtrees parameterized Pack repository.
2606
 
 
2607
 
    This format was introduced in 0.92.
2608
 
    """
2609
 
 
2610
 
    repository_class = KnitPackRepository
2611
 
    _commit_builder_class = PackCommitBuilder
2612
 
    @property
2613
 
    def _serializer(self):
2614
 
        return xml5.serializer_v5
2615
 
    # What index classes to use
2616
 
    index_builder_class = InMemoryGraphIndex
2617
 
    index_class = GraphIndex
2618
 
 
2619
 
    def _get_matching_bzrdir(self):
2620
 
        return bzrdir.format_registry.make_bzrdir('pack-0.92')
2621
 
 
2622
 
    def _ignore_setting_bzrdir(self, format):
2623
 
        pass
2624
 
 
2625
 
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2626
 
 
2627
 
    def get_format_string(self):
2628
 
        """See RepositoryFormat.get_format_string()."""
2629
 
        return "Bazaar pack repository format 1 (needs bzr 0.92)\n"
2630
 
 
2631
 
    def get_format_description(self):
2632
 
        """See RepositoryFormat.get_format_description()."""
2633
 
        return "Packs containing knits without subtree support"
2634
 
 
2635
 
 
2636
 
class RepositoryFormatKnitPack3(RepositoryFormatPack):
2637
 
    """A subtrees parameterized Pack repository.
2638
 
 
2639
 
    This repository format uses the xml7 serializer to get:
2640
 
     - support for recording full info about the tree root
2641
 
     - support for recording tree-references
2642
 
 
2643
 
    This format was introduced in 0.92.
2644
 
    """
2645
 
 
2646
 
    repository_class = KnitPackRepository
2647
 
    _commit_builder_class = PackRootCommitBuilder
2648
 
    rich_root_data = True
2649
 
    experimental = True
2650
 
    supports_tree_reference = True
2651
 
    @property
2652
 
    def _serializer(self):
2653
 
        return xml7.serializer_v7
2654
 
    # What index classes to use
2655
 
    index_builder_class = InMemoryGraphIndex
2656
 
    index_class = GraphIndex
2657
 
 
2658
 
    def _get_matching_bzrdir(self):
2659
 
        return bzrdir.format_registry.make_bzrdir(
2660
 
            'pack-0.92-subtree')
2661
 
 
2662
 
    def _ignore_setting_bzrdir(self, format):
2663
 
        pass
2664
 
 
2665
 
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2666
 
 
2667
 
    def get_format_string(self):
2668
 
        """See RepositoryFormat.get_format_string()."""
2669
 
        return "Bazaar pack repository format 1 with subtree support (needs bzr 0.92)\n"
2670
 
 
2671
 
    def get_format_description(self):
2672
 
        """See RepositoryFormat.get_format_description()."""
2673
 
        return "Packs containing knits with subtree support\n"
2674
 
 
2675
 
 
2676
 
class RepositoryFormatKnitPack4(RepositoryFormatPack):
2677
 
    """A rich-root, no subtrees parameterized Pack repository.
2678
 
 
2679
 
    This repository format uses the xml6 serializer to get:
2680
 
     - support for recording full info about the tree root
2681
 
 
2682
 
    This format was introduced in 1.0.
2683
 
    """
2684
 
 
2685
 
    repository_class = KnitPackRepository
2686
 
    _commit_builder_class = PackRootCommitBuilder
2687
 
    rich_root_data = True
2688
 
    supports_tree_reference = False
2689
 
    @property
2690
 
    def _serializer(self):
2691
 
        return xml6.serializer_v6
2692
 
    # What index classes to use
2693
 
    index_builder_class = InMemoryGraphIndex
2694
 
    index_class = GraphIndex
2695
 
 
2696
 
    def _get_matching_bzrdir(self):
2697
 
        return bzrdir.format_registry.make_bzrdir(
2698
 
            'rich-root-pack')
2699
 
 
2700
 
    def _ignore_setting_bzrdir(self, format):
2701
 
        pass
2702
 
 
2703
 
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2704
 
 
2705
 
    def get_format_string(self):
2706
 
        """See RepositoryFormat.get_format_string()."""
2707
 
        return ("Bazaar pack repository format 1 with rich root"
2708
 
                " (needs bzr 1.0)\n")
2709
 
 
2710
 
    def get_format_description(self):
2711
 
        """See RepositoryFormat.get_format_description()."""
2712
 
        return "Packs containing knits with rich root support\n"
2713
 
 
2714
 
 
2715
 
class RepositoryFormatKnitPack5(RepositoryFormatPack):
2716
 
    """Repository that supports external references to allow stacking.
2717
 
 
2718
 
    New in release 1.6.
2719
 
 
2720
 
    Supports external lookups, which results in non-truncated ghosts after
2721
 
    reconcile compared to pack-0.92 formats.
2722
 
    """
2723
 
 
2724
 
    repository_class = KnitPackRepository
2725
 
    _commit_builder_class = PackCommitBuilder
2726
 
    supports_external_lookups = True
2727
 
    # What index classes to use
2728
 
    index_builder_class = InMemoryGraphIndex
2729
 
    index_class = GraphIndex
2730
 
 
2731
 
    @property
2732
 
    def _serializer(self):
2733
 
        return xml5.serializer_v5
2734
 
 
2735
 
    def _get_matching_bzrdir(self):
2736
 
        return bzrdir.format_registry.make_bzrdir('1.6')
2737
 
 
2738
 
    def _ignore_setting_bzrdir(self, format):
2739
 
        pass
2740
 
 
2741
 
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2742
 
 
2743
 
    def get_format_string(self):
2744
 
        """See RepositoryFormat.get_format_string()."""
2745
 
        return "Bazaar RepositoryFormatKnitPack5 (bzr 1.6)\n"
2746
 
 
2747
 
    def get_format_description(self):
2748
 
        """See RepositoryFormat.get_format_description()."""
2749
 
        return "Packs 5 (adds stacking support, requires bzr 1.6)"
2750
 
 
2751
 
 
2752
 
class RepositoryFormatKnitPack5RichRoot(RepositoryFormatPack):
2753
 
    """A repository with rich roots and stacking.
2754
 
 
2755
 
    New in release 1.6.1.
2756
 
 
2757
 
    Supports stacking on other repositories, allowing data to be accessed
2758
 
    without being stored locally.
2759
 
    """
2760
 
 
2761
 
    repository_class = KnitPackRepository
2762
 
    _commit_builder_class = PackRootCommitBuilder
2763
 
    rich_root_data = True
2764
 
    supports_tree_reference = False # no subtrees
2765
 
    supports_external_lookups = True
2766
 
    # What index classes to use
2767
 
    index_builder_class = InMemoryGraphIndex
2768
 
    index_class = GraphIndex
2769
 
 
2770
 
    @property
2771
 
    def _serializer(self):
2772
 
        return xml6.serializer_v6
2773
 
 
2774
 
    def _get_matching_bzrdir(self):
2775
 
        return bzrdir.format_registry.make_bzrdir(
2776
 
            '1.6.1-rich-root')
2777
 
 
2778
 
    def _ignore_setting_bzrdir(self, format):
2779
 
        pass
2780
 
 
2781
 
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2782
 
 
2783
 
    def get_format_string(self):
2784
 
        """See RepositoryFormat.get_format_string()."""
2785
 
        return "Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6.1)\n"
2786
 
 
2787
 
    def get_format_description(self):
2788
 
        return "Packs 5 rich-root (adds stacking support, requires bzr 1.6.1)"
2789
 
 
2790
 
 
2791
 
class RepositoryFormatKnitPack5RichRootBroken(RepositoryFormatPack):
2792
 
    """A repository with rich roots and external references.
2793
 
 
2794
 
    New in release 1.6.
2795
 
 
2796
 
    Supports external lookups, which results in non-truncated ghosts after
2797
 
    reconcile compared to pack-0.92 formats.
2798
 
 
2799
 
    This format was deprecated because the serializer it uses accidentally
2800
 
    supported subtrees, when the format was not intended to. This meant that
2801
 
    someone could accidentally fetch from an incorrect repository.
2802
 
    """
2803
 
 
2804
 
    repository_class = KnitPackRepository
2805
 
    _commit_builder_class = PackRootCommitBuilder
2806
 
    rich_root_data = True
2807
 
    supports_tree_reference = False # no subtrees
2808
 
 
2809
 
    supports_external_lookups = True
2810
 
    # What index classes to use
2811
 
    index_builder_class = InMemoryGraphIndex
2812
 
    index_class = GraphIndex
2813
 
 
2814
 
    @property
2815
 
    def _serializer(self):
2816
 
        return xml7.serializer_v7
2817
 
 
2818
 
    def _get_matching_bzrdir(self):
2819
 
        matching = bzrdir.format_registry.make_bzrdir(
2820
 
            '1.6.1-rich-root')
2821
 
        matching.repository_format = self
2822
 
        return matching
2823
 
 
2824
 
    def _ignore_setting_bzrdir(self, format):
2825
 
        pass
2826
 
 
2827
 
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2828
 
 
2829
 
    def get_format_string(self):
2830
 
        """See RepositoryFormat.get_format_string()."""
2831
 
        return "Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6)\n"
2832
 
 
2833
 
    def get_format_description(self):
2834
 
        return ("Packs 5 rich-root (adds stacking support, requires bzr 1.6)"
2835
 
                " (deprecated)")
2836
 
 
2837
 
    def is_deprecated(self):
2838
 
        return True
2839
 
 
2840
 
 
2841
 
class RepositoryFormatKnitPack6(RepositoryFormatPack):
2842
 
    """A repository with stacking and btree indexes,
2843
 
    without rich roots or subtrees.
2844
 
 
2845
 
    This is equivalent to pack-1.6 with B+Tree indices.
2846
 
    """
2847
 
 
2848
 
    repository_class = KnitPackRepository
2849
 
    _commit_builder_class = PackCommitBuilder
2850
 
    supports_external_lookups = True
2851
 
    # What index classes to use
2852
 
    index_builder_class = btree_index.BTreeBuilder
2853
 
    index_class = btree_index.BTreeGraphIndex
2854
 
 
2855
 
    @property
2856
 
    def _serializer(self):
2857
 
        return xml5.serializer_v5
2858
 
 
2859
 
    def _get_matching_bzrdir(self):
2860
 
        return bzrdir.format_registry.make_bzrdir('1.9')
2861
 
 
2862
 
    def _ignore_setting_bzrdir(self, format):
2863
 
        pass
2864
 
 
2865
 
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2866
 
 
2867
 
    def get_format_string(self):
2868
 
        """See RepositoryFormat.get_format_string()."""
2869
 
        return "Bazaar RepositoryFormatKnitPack6 (bzr 1.9)\n"
2870
 
 
2871
 
    def get_format_description(self):
2872
 
        """See RepositoryFormat.get_format_description()."""
2873
 
        return "Packs 6 (uses btree indexes, requires bzr 1.9)"
2874
 
 
2875
 
 
2876
 
class RepositoryFormatKnitPack6RichRoot(RepositoryFormatPack):
2877
 
    """A repository with rich roots, no subtrees, stacking and btree indexes.
2878
 
 
2879
 
    1.6-rich-root with B+Tree indices.
2880
 
    """
2881
 
 
2882
 
    repository_class = KnitPackRepository
2883
 
    _commit_builder_class = PackRootCommitBuilder
2884
 
    rich_root_data = True
2885
 
    supports_tree_reference = False # no subtrees
2886
 
    supports_external_lookups = True
2887
 
    # What index classes to use
2888
 
    index_builder_class = btree_index.BTreeBuilder
2889
 
    index_class = btree_index.BTreeGraphIndex
2890
 
 
2891
 
    @property
2892
 
    def _serializer(self):
2893
 
        return xml6.serializer_v6
2894
 
 
2895
 
    def _get_matching_bzrdir(self):
2896
 
        return bzrdir.format_registry.make_bzrdir(
2897
 
            '1.9-rich-root')
2898
 
 
2899
 
    def _ignore_setting_bzrdir(self, format):
2900
 
        pass
2901
 
 
2902
 
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2903
 
 
2904
 
    def get_format_string(self):
2905
 
        """See RepositoryFormat.get_format_string()."""
2906
 
        return "Bazaar RepositoryFormatKnitPack6RichRoot (bzr 1.9)\n"
2907
 
 
2908
 
    def get_format_description(self):
2909
 
        return "Packs 6 rich-root (uses btree indexes, requires bzr 1.9)"
2910
 
 
2911
 
 
2912
 
class RepositoryFormatPackDevelopment2Subtree(RepositoryFormatPack):
2913
 
    """A subtrees development repository.
2914
 
 
2915
 
    This format should be retained in 2.3, to provide an upgrade path from this
2916
 
    to RepositoryFormat2aSubtree.  It can be removed in later releases.
2917
 
 
2918
 
    1.6.1-subtree[as it might have been] with B+Tree indices.
2919
 
    """
2920
 
 
2921
 
    repository_class = KnitPackRepository
2922
 
    _commit_builder_class = PackRootCommitBuilder
2923
 
    rich_root_data = True
2924
 
    experimental = True
2925
 
    supports_tree_reference = True
2926
 
    supports_external_lookups = True
2927
 
    # What index classes to use
2928
 
    index_builder_class = btree_index.BTreeBuilder
2929
 
    index_class = btree_index.BTreeGraphIndex
2930
 
 
2931
 
    @property
2932
 
    def _serializer(self):
2933
 
        return xml7.serializer_v7
2934
 
 
2935
 
    def _get_matching_bzrdir(self):
2936
 
        return bzrdir.format_registry.make_bzrdir(
2937
 
            'development5-subtree')
2938
 
 
2939
 
    def _ignore_setting_bzrdir(self, format):
2940
 
        pass
2941
 
 
2942
 
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2943
 
 
2944
 
    def get_format_string(self):
2945
 
        """See RepositoryFormat.get_format_string()."""
2946
 
        return ("Bazaar development format 2 with subtree support "
2947
 
            "(needs bzr.dev from before 1.8)\n")
2948
 
 
2949
 
    def get_format_description(self):
2950
 
        """See RepositoryFormat.get_format_description()."""
2951
 
        return ("Development repository format, currently the same as "
2952
 
            "1.6.1-subtree with B+Tree indices.\n")
2953
 
 
2954
 
 
2955
2596
class RetryPackOperations(errors.RetryWithNewPacks):
2956
2597
    """Raised when we are packing and we find a missing file.
2957
2598