/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/repofmt/pack_repo.py

  • Committer: John Arbash Meinel
  • Date: 2008-09-05 03:11:40 UTC
  • mfrom: (3691 +trunk)
  • mto: (3697.7.4 1.7)
  • mto: This revision was merged to the branch mainline in revision 3748.
  • Revision ID: john@arbash-meinel.com-20080905031140-hj0adlcf30l7i99v
Merge in bzr.dev 3691

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
from bzrlib.lazy_import import lazy_import
18
18
lazy_import(globals(), """
19
19
from itertools import izip
20
 
import math
21
20
import md5
22
21
import time
23
22
 
24
23
from bzrlib import (
25
 
        debug,
26
 
        graph,
27
 
        pack,
28
 
        ui,
29
 
        )
 
24
    debug,
 
25
    graph,
 
26
    pack,
 
27
    transactions,
 
28
    ui,
 
29
    )
30
30
from bzrlib.index import (
31
31
    GraphIndex,
32
32
    GraphIndexBuilder,
41
41
    _DirectPackAccess,
42
42
    )
43
43
from bzrlib.osutils import rand_chars, split_lines
44
 
from bzrlib.pack import ContainerWriter
45
 
from bzrlib.store import revision
46
44
from bzrlib import tsort
47
45
""")
48
46
from bzrlib import (
50
48
    errors,
51
49
    lockable_files,
52
50
    lockdir,
53
 
    osutils,
54
51
    symbol_versioning,
55
 
    transactions,
56
52
    xml5,
57
53
    xml6,
58
54
    xml7,
59
55
    )
60
56
 
61
 
from bzrlib.decorators import needs_read_lock, needs_write_lock
 
57
from bzrlib.decorators import needs_write_lock
62
58
from bzrlib.repofmt.knitrepo import KnitRepository
63
59
from bzrlib.repository import (
64
60
    CommitBuilder,
65
 
    InterRepository,
66
 
    MetaDirRepository,
67
61
    MetaDirRepositoryFormat,
68
62
    RepositoryFormat,
69
63
    RootCommitBuilder,
70
64
    )
71
65
import bzrlib.revision as _mod_revision
72
 
from bzrlib.store.versioned import VersionedFileStore
73
66
from bzrlib.trace import (
74
67
    mutter,
75
 
    mutter_callsite,
76
 
    note,
77
68
    warning,
78
69
    )
79
70
 
1728
1719
        self._reconcile_does_inventory_gc = True
1729
1720
        self._reconcile_fixes_text_parents = True
1730
1721
        self._reconcile_backsup_inventory = False
 
1722
        self._fetch_order = 'unordered'
 
1723
 
 
1724
    def _warn_if_deprecated(self):
 
1725
        # This class isn't deprecated, but one sub-format is
 
1726
        if isinstance(self._format, RepositoryFormatKnitPack5RichRootBroken):
 
1727
            from bzrlib import repository
 
1728
            if repository._deprecation_warning_done:
 
1729
                return
 
1730
            repository._deprecation_warning_done = True
 
1731
            warning("Format %s for %s is deprecated - please use"
 
1732
                    " 'bzr upgrade --1.6.1-rich-root'"
 
1733
                    % (self._format, self.bzrdir.transport.base))
1731
1734
 
1732
1735
    def _abort_write_group(self):
1733
1736
        self._pack_collection._abort_write_group()
1814
1817
            raise errors.ReadOnlyError(self)
1815
1818
        self._write_lock_count += 1
1816
1819
        if self._write_lock_count == 1:
1817
 
            from bzrlib import transactions
1818
1820
            self._transaction = transactions.WriteTransaction()
1819
1821
            for repo in self._fallback_repositories:
1820
1822
                # Writes don't affect fallback repos
1975
1977
        pass
1976
1978
 
1977
1979
 
1978
 
class RepositoryFormatPack(MetaDirRepositoryFormat):
1979
 
    """Format logic for pack structured repositories.
1980
 
 
1981
 
    This repository format has:
1982
 
     - a list of packs in pack-names
1983
 
     - packs in packs/NAME.pack
1984
 
     - indices in indices/NAME.{iix,six,tix,rix}
1985
 
     - knit deltas in the packs, knit indices mapped to the indices.
1986
 
     - thunk objects to support the knits programming API.
1987
 
     - a format marker of its own
1988
 
     - an optional 'shared-storage' flag
1989
 
     - an optional 'no-working-trees' flag
1990
 
     - a LockDir lock
1991
 
    """
1992
 
 
1993
 
    # Set this attribute in derived classes to control the repository class
1994
 
    # created by open and initialize.
1995
 
    repository_class = None
1996
 
    # Set this attribute in derived classes to control the
1997
 
    # _commit_builder_class that the repository objects will have passed to
1998
 
    # their constructor.
1999
 
    _commit_builder_class = None
2000
 
    # Set this attribute in derived clases to control the _serializer that the
2001
 
    # repository objects will have passed to their constructor.
2002
 
    _serializer = None
2003
 
    # External references are not supported in pack repositories yet.
2004
 
    supports_external_lookups = False
2005
 
 
2006
 
    def initialize(self, a_bzrdir, shared=False):
2007
 
        """Create a pack based repository.
2008
 
 
2009
 
        :param a_bzrdir: bzrdir to contain the new repository; must already
2010
 
            be initialized.
2011
 
        :param shared: If true the repository will be initialized as a shared
2012
 
                       repository.
2013
 
        """
2014
 
        mutter('creating repository in %s.', a_bzrdir.transport.base)
2015
 
        dirs = ['indices', 'obsolete_packs', 'packs', 'upload']
2016
 
        builder = GraphIndexBuilder()
2017
 
        files = [('pack-names', builder.finish())]
2018
 
        utf8_files = [('format', self.get_format_string())]
2019
 
        
2020
 
        self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
2021
 
        return self.open(a_bzrdir=a_bzrdir, _found=True)
2022
 
 
2023
 
    def open(self, a_bzrdir, _found=False, _override_transport=None):
2024
 
        """See RepositoryFormat.open().
2025
 
        
2026
 
        :param _override_transport: INTERNAL USE ONLY. Allows opening the
2027
 
                                    repository at a slightly different url
2028
 
                                    than normal. I.e. during 'upgrade'.
2029
 
        """
2030
 
        if not _found:
2031
 
            format = RepositoryFormat.find_format(a_bzrdir)
2032
 
        if _override_transport is not None:
2033
 
            repo_transport = _override_transport
2034
 
        else:
2035
 
            repo_transport = a_bzrdir.get_repository_transport(None)
2036
 
        control_files = lockable_files.LockableFiles(repo_transport,
2037
 
                                'lock', lockdir.LockDir)
2038
 
        return self.repository_class(_format=self,
2039
 
                              a_bzrdir=a_bzrdir,
2040
 
                              control_files=control_files,
2041
 
                              _commit_builder_class=self._commit_builder_class,
2042
 
                              _serializer=self._serializer)
2043
 
 
2044
 
 
2045
 
class RepositoryFormatKnitPack1(RepositoryFormatPack):
2046
 
    """A no-subtrees parameterized Pack repository.
2047
 
 
2048
 
    This format was introduced in 0.92.
2049
 
    """
2050
 
 
2051
 
    repository_class = KnitPackRepository
2052
 
    _commit_builder_class = PackCommitBuilder
2053
 
    _serializer = xml5.serializer_v5
2054
 
 
2055
 
    def _get_matching_bzrdir(self):
2056
 
        return bzrdir.format_registry.make_bzrdir('pack-0.92')
2057
 
 
2058
 
    def _ignore_setting_bzrdir(self, format):
2059
 
        pass
2060
 
 
2061
 
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2062
 
 
2063
 
    def get_format_string(self):
2064
 
        """See RepositoryFormat.get_format_string()."""
2065
 
        return "Bazaar pack repository format 1 (needs bzr 0.92)\n"
2066
 
 
2067
 
    def get_format_description(self):
2068
 
        """See RepositoryFormat.get_format_description()."""
2069
 
        return "Packs containing knits without subtree support"
2070
 
 
2071
 
    def check_conversion_target(self, target_format):
2072
 
        pass
2073
 
 
2074
 
 
2075
1980
class RepositoryFormatKnitPack3(RepositoryFormatPack):
2076
1981
    """A subtrees parameterized Pack repository.
2077
1982
 
2153
2058
        return "Packs containing knits with rich root support\n"
2154
2059
 
2155
2060
 
2156
 
class RepositoryFormatPackDevelopment0(RepositoryFormatPack):
2157
 
    """A no-subtrees development repository.
2158
 
 
2159
 
    This format should be retained until the second release after bzr 1.0.
2160
 
 
2161
 
    No changes to the disk behaviour from pack-0.92.
 
2061
class RepositoryFormatKnitPack5(RepositoryFormatPack):
 
2062
    """Repository that supports external references to allow stacking.
 
2063
 
 
2064
    New in release 1.6.
 
2065
 
 
2066
    Supports external lookups, which results in non-truncated ghosts after
 
2067
    reconcile compared to pack-0.92 formats.
2162
2068
    """
2163
2069
 
2164
2070
    repository_class = KnitPackRepository
2165
2071
    _commit_builder_class = PackCommitBuilder
2166
2072
    _serializer = xml5.serializer_v5
 
2073
    supports_external_lookups = True
2167
2074
 
2168
2075
    def _get_matching_bzrdir(self):
2169
 
        return bzrdir.format_registry.make_bzrdir('development0')
 
2076
        return bzrdir.format_registry.make_bzrdir('development1')
2170
2077
 
2171
2078
    def _ignore_setting_bzrdir(self, format):
2172
2079
        pass
2175
2082
 
2176
2083
    def get_format_string(self):
2177
2084
        """See RepositoryFormat.get_format_string()."""
2178
 
        return "Bazaar development format 0 (needs bzr.dev from before 1.3)\n"
 
2085
        return "Bazaar RepositoryFormatKnitPack5 (bzr 1.6)\n"
2179
2086
 
2180
2087
    def get_format_description(self):
2181
2088
        """See RepositoryFormat.get_format_description()."""
2182
 
        return ("Development repository format, currently the same as "
2183
 
            "pack-0.92\n")
2184
 
 
2185
 
    def check_conversion_target(self, target_format):
2186
 
        pass
2187
 
 
2188
 
 
2189
 
class RepositoryFormatPackDevelopment0Subtree(RepositoryFormatPack):
2190
 
    """A subtrees development repository.
2191
 
 
2192
 
    This format should be retained until the second release after bzr 1.0.
2193
 
 
2194
 
    No changes to the disk behaviour from pack-0.92-subtree.
2195
 
    """
2196
 
 
2197
 
    repository_class = KnitPackRepository
2198
 
    _commit_builder_class = PackRootCommitBuilder
2199
 
    rich_root_data = True
2200
 
    supports_tree_reference = True
 
2089
        return "Packs 5 (adds stacking support, requires bzr 1.6)"
 
2090
 
 
2091
    def check_conversion_target(self, target_format):
 
2092
        pass
 
2093
 
 
2094
 
 
2095
class RepositoryFormatKnitPack5RichRoot(RepositoryFormatPack):
 
2096
    """A repository with rich roots and stacking.
 
2097
 
 
2098
    New in release 1.6.1.
 
2099
 
 
2100
    Supports stacking on other repositories, allowing data to be accessed
 
2101
    without being stored locally.
 
2102
    """
 
2103
 
 
2104
    repository_class = KnitPackRepository
 
2105
    _commit_builder_class = PackRootCommitBuilder
 
2106
    rich_root_data = True
 
2107
    supports_tree_reference = False # no subtrees
 
2108
    _serializer = xml6.serializer_v6
 
2109
    supports_external_lookups = True
 
2110
 
 
2111
    def _get_matching_bzrdir(self):
 
2112
        return bzrdir.format_registry.make_bzrdir(
 
2113
            '1.6.1-rich-root')
 
2114
 
 
2115
    def _ignore_setting_bzrdir(self, format):
 
2116
        pass
 
2117
 
 
2118
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
2119
 
 
2120
    def check_conversion_target(self, target_format):
 
2121
        if not target_format.rich_root_data:
 
2122
            raise errors.BadConversionTarget(
 
2123
                'Does not support rich root data.', target_format)
 
2124
 
 
2125
    def get_format_string(self):
 
2126
        """See RepositoryFormat.get_format_string()."""
 
2127
        return "Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6.1)\n"
 
2128
 
 
2129
    def get_format_description(self):
 
2130
        return "Packs 5 rich-root (adds stacking support, requires bzr 1.6.1)"
 
2131
 
 
2132
 
 
2133
class RepositoryFormatKnitPack5RichRootBroken(RepositoryFormatPack):
 
2134
    """A repository with rich roots and external references.
 
2135
 
 
2136
    New in release 1.6.
 
2137
 
 
2138
    Supports external lookups, which results in non-truncated ghosts after
 
2139
    reconcile compared to pack-0.92 formats.
 
2140
 
 
2141
    This format was deprecated because the serializer it uses accidentally
 
2142
    supported subtrees, when the format was not intended to. This meant that
 
2143
    someone could accidentally fetch from an incorrect repository.
 
2144
    """
 
2145
 
 
2146
    repository_class = KnitPackRepository
 
2147
    _commit_builder_class = PackRootCommitBuilder
 
2148
    rich_root_data = True
 
2149
    supports_tree_reference = False # no subtrees
2201
2150
    _serializer = xml7.serializer_v7
2202
2151
 
 
2152
    supports_external_lookups = True
 
2153
 
2203
2154
    def _get_matching_bzrdir(self):
2204
2155
        return bzrdir.format_registry.make_bzrdir(
2205
 
            'development0-subtree')
 
2156
            'development1-subtree')
2206
2157
 
2207
2158
    def _ignore_setting_bzrdir(self, format):
2208
2159
        pass
2213
2164
        if not target_format.rich_root_data:
2214
2165
            raise errors.BadConversionTarget(
2215
2166
                'Does not support rich root data.', target_format)
2216
 
        if not getattr(target_format, 'supports_tree_reference', False):
2217
 
            raise errors.BadConversionTarget(
2218
 
                'Does not support nested trees', target_format)
2219
 
            
 
2167
 
2220
2168
    def get_format_string(self):
2221
2169
        """See RepositoryFormat.get_format_string()."""
2222
 
        return ("Bazaar development format 0 with subtree support "
2223
 
            "(needs bzr.dev from before 1.3)\n")
 
2170
        return "Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6)\n"
2224
2171
 
2225
2172
    def get_format_description(self):
2226
 
        """See RepositoryFormat.get_format_description()."""
2227
 
        return ("Development repository format, currently the same as "
2228
 
            "pack-0.92-subtree\n")
2229
 
 
2230
 
 
2231
 
class RepositoryFormatPackDevelopment1(RepositoryFormatPackDevelopment0):
 
2173
        return ("Packs 5 rich-root (adds stacking support, requires bzr 1.6)"
 
2174
                " (deprecated)")
 
2175
 
 
2176
 
 
2177
class RepositoryFormatPackDevelopment1(RepositoryFormatPack):
2232
2178
    """A no-subtrees development repository.
2233
2179
 
2234
2180
    This format should be retained until the second release after bzr 1.5.
2237
2183
    reconcile compared to pack-0.92 formats.
2238
2184
    """
2239
2185
 
 
2186
    repository_class = KnitPackRepository
 
2187
    _commit_builder_class = PackCommitBuilder
 
2188
    _serializer = xml5.serializer_v5
2240
2189
    supports_external_lookups = True
2241
2190
 
2242
2191
    def _get_matching_bzrdir(self):
2260
2209
        pass
2261
2210
 
2262
2211
 
2263
 
class RepositoryFormatPackDevelopment1Subtree(RepositoryFormatPackDevelopment0Subtree):
 
2212
class RepositoryFormatPackDevelopment1Subtree(RepositoryFormatPack):
2264
2213
    """A subtrees development repository.
2265
2214
 
2266
2215
    This format should be retained until the second release after bzr 1.5.
2269
2218
    reconcile compared to pack-0.92 formats.
2270
2219
    """
2271
2220
 
 
2221
    repository_class = KnitPackRepository
 
2222
    _commit_builder_class = PackRootCommitBuilder
 
2223
    rich_root_data = True
 
2224
    supports_tree_reference = True
 
2225
    _serializer = xml7.serializer_v7
2272
2226
    supports_external_lookups = True
2273
2227
 
2274
2228
    def _get_matching_bzrdir(self):