/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: Martin Pool
  • Date: 2008-07-07 10:31:06 UTC
  • mfrom: (3221.11.29 reconfigure.shallow)
  • mto: This revision was merged to the branch mainline in revision 3537.
  • Revision ID: mbp@sourcefrog.net-20080707103106-jpch6tczx7x2yuq0
merge all stacking threads; some tests currently failing

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
from bzrlib.repofmt.knitrepo import KnitRepository
63
63
from bzrlib.repository import (
64
64
    CommitBuilder,
 
65
    InterRepository,
65
66
    MetaDirRepository,
66
67
    MetaDirRepositoryFormat,
67
68
    RepositoryFormat,
208
209
 
209
210
    def __repr__(self):
210
211
        return "<bzrlib.repofmt.pack_repo.Pack object at 0x%x, %s, %s" % (
211
 
            id(self), self.transport, self.name)
 
212
            id(self), self.pack_transport, self.name)
212
213
 
213
214
 
214
215
class NewPack(Pack):
1849
1850
        if self._write_lock_count == 1:
1850
1851
            from bzrlib import transactions
1851
1852
            self._transaction = transactions.WriteTransaction()
 
1853
            for repo in self._fallback_repositories:
 
1854
                # Writes don't affect fallback repos
 
1855
                repo.lock_read()
1852
1856
        self._refresh_data()
1853
1857
 
1854
1858
    def lock_read(self):
1856
1860
            self._write_lock_count += 1
1857
1861
        else:
1858
1862
            self.control_files.lock_read()
 
1863
            for repo in self._fallback_repositories:
 
1864
                # Writes don't affect fallback repos
 
1865
                repo.lock_read()
1859
1866
        self._refresh_data()
1860
1867
 
1861
1868
    def leave_lock_in_place(self):
1897
1904
                transaction = self._transaction
1898
1905
                self._transaction = None
1899
1906
                transaction.finish()
 
1907
                for repo in self._fallback_repositories:
 
1908
                    repo.unlock()
1900
1909
        else:
1901
1910
            self.control_files.unlock()
 
1911
            for repo in self._fallback_repositories:
 
1912
                repo.unlock()
 
1913
 
 
1914
 
 
1915
class RepositoryFormatPack(MetaDirRepositoryFormat):
 
1916
    """Format logic for pack structured repositories.
 
1917
 
 
1918
    This repository format has:
 
1919
     - a list of packs in pack-names
 
1920
     - packs in packs/NAME.pack
 
1921
     - indices in indices/NAME.{iix,six,tix,rix}
 
1922
     - knit deltas in the packs, knit indices mapped to the indices.
 
1923
     - thunk objects to support the knits programming API.
 
1924
     - a format marker of its own
 
1925
     - an optional 'shared-storage' flag
 
1926
     - an optional 'no-working-trees' flag
 
1927
     - a LockDir lock
 
1928
    """
 
1929
 
 
1930
    # Set this attribute in derived classes to control the repository class
 
1931
    # created by open and initialize.
 
1932
    repository_class = None
 
1933
    # Set this attribute in derived classes to control the
 
1934
    # _commit_builder_class that the repository objects will have passed to
 
1935
    # their constructor.
 
1936
    _commit_builder_class = None
 
1937
    # Set this attribute in derived clases to control the _serializer that the
 
1938
    # repository objects will have passed to their constructor.
 
1939
    _serializer = None
 
1940
    # External references are not supported in pack repositories yet.
 
1941
    supports_external_lookups = False
 
1942
 
 
1943
    def initialize(self, a_bzrdir, shared=False):
 
1944
        """Create a pack based repository.
 
1945
 
 
1946
        :param a_bzrdir: bzrdir to contain the new repository; must already
 
1947
            be initialized.
 
1948
        :param shared: If true the repository will be initialized as a shared
 
1949
                       repository.
 
1950
        """
 
1951
        mutter('creating repository in %s.', a_bzrdir.transport.base)
 
1952
        dirs = ['indices', 'obsolete_packs', 'packs', 'upload']
 
1953
        builder = GraphIndexBuilder()
 
1954
        files = [('pack-names', builder.finish())]
 
1955
        utf8_files = [('format', self.get_format_string())]
 
1956
        
 
1957
        self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
 
1958
        return self.open(a_bzrdir=a_bzrdir, _found=True)
 
1959
 
 
1960
    def open(self, a_bzrdir, _found=False, _override_transport=None):
 
1961
        """See RepositoryFormat.open().
 
1962
        
 
1963
        :param _override_transport: INTERNAL USE ONLY. Allows opening the
 
1964
                                    repository at a slightly different url
 
1965
                                    than normal. I.e. during 'upgrade'.
 
1966
        """
 
1967
        if not _found:
 
1968
            format = RepositoryFormat.find_format(a_bzrdir)
 
1969
        if _override_transport is not None:
 
1970
            repo_transport = _override_transport
 
1971
        else:
 
1972
            repo_transport = a_bzrdir.get_repository_transport(None)
 
1973
        control_files = lockable_files.LockableFiles(repo_transport,
 
1974
                                'lock', lockdir.LockDir)
 
1975
        return self.repository_class(_format=self,
 
1976
                              a_bzrdir=a_bzrdir,
 
1977
                              control_files=control_files,
 
1978
                              _commit_builder_class=self._commit_builder_class,
 
1979
                              _serializer=self._serializer)
 
1980
 
 
1981
 
 
1982
class RepositoryFormatKnitPack1(RepositoryFormatPack):
 
1983
    """A no-subtrees parameterized Pack repository.
 
1984
 
 
1985
    This format was introduced in 0.92.
 
1986
    """
 
1987
 
 
1988
    repository_class = KnitPackRepository
 
1989
    _commit_builder_class = PackCommitBuilder
 
1990
    _serializer = xml5.serializer_v5
 
1991
 
 
1992
    def _get_matching_bzrdir(self):
 
1993
        return bzrdir.format_registry.make_bzrdir('pack-0.92')
 
1994
 
 
1995
    def _ignore_setting_bzrdir(self, format):
 
1996
        pass
 
1997
 
 
1998
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
1999
 
 
2000
    def get_format_string(self):
 
2001
        """See RepositoryFormat.get_format_string()."""
 
2002
        return "Bazaar pack repository format 1 (needs bzr 0.92)\n"
 
2003
 
 
2004
    def get_format_description(self):
 
2005
        """See RepositoryFormat.get_format_description()."""
 
2006
        return "Packs containing knits without subtree support"
 
2007
 
 
2008
    def check_conversion_target(self, target_format):
 
2009
        pass
1902
2010
 
1903
2011
 
1904
2012
class RepositoryFormatPack(MetaDirRepositoryFormat):
2154
2262
            "pack-0.92-subtree\n")
2155
2263
 
2156
2264
 
 
2265
class RepositoryFormatPackDevelopment1(RepositoryFormatPackDevelopment0):
 
2266
    """A no-subtrees development repository.
 
2267
 
 
2268
    This format should be retained until the second release after bzr 1.5.
 
2269
 
 
2270
    Supports external lookups, which results in non-truncated ghosts after
 
2271
    reconcile compared to pack-0.92 formats.
 
2272
    """
 
2273
 
 
2274
    supports_external_lookups = True
 
2275
 
 
2276
    def _get_matching_bzrdir(self):
 
2277
        return bzrdir.format_registry.make_bzrdir('development1')
 
2278
 
 
2279
    def _ignore_setting_bzrdir(self, format):
 
2280
        pass
 
2281
 
 
2282
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
2283
 
 
2284
    def get_format_string(self):
 
2285
        """See RepositoryFormat.get_format_string()."""
 
2286
        return "Bazaar development format 1 (needs bzr.dev from before 1.6)\n"
 
2287
 
 
2288
    def get_format_description(self):
 
2289
        """See RepositoryFormat.get_format_description()."""
 
2290
        return ("Development repository format, currently the same as "
 
2291
            "pack-0.92 with external reference support.\n")
 
2292
 
 
2293
    def check_conversion_target(self, target_format):
 
2294
        pass
 
2295
 
 
2296
 
 
2297
class RepositoryFormatPackDevelopment1Subtree(RepositoryFormatPackDevelopment0Subtree):
 
2298
    """A subtrees development repository.
 
2299
 
 
2300
    This format should be retained until the second release after bzr 1.5.
 
2301
 
 
2302
    Supports external lookups, which results in non-truncated ghosts after
 
2303
    reconcile compared to pack-0.92 formats.
 
2304
    """
 
2305
 
 
2306
    supports_external_lookups = True
 
2307
 
 
2308
    def _get_matching_bzrdir(self):
 
2309
        return bzrdir.format_registry.make_bzrdir(
 
2310
            'development1-subtree')
 
2311
 
 
2312
    def _ignore_setting_bzrdir(self, format):
 
2313
        pass
 
2314
 
 
2315
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
 
2316
 
 
2317
    def check_conversion_target(self, target_format):
 
2318
        if not target_format.rich_root_data:
 
2319
            raise errors.BadConversionTarget(
 
2320
                'Does not support rich root data.', target_format)
 
2321
        if not getattr(target_format, 'supports_tree_reference', False):
 
2322
            raise errors.BadConversionTarget(
 
2323
                'Does not support nested trees', target_format)
 
2324
            
 
2325
    def get_format_string(self):
 
2326
        """See RepositoryFormat.get_format_string()."""
 
2327
        return ("Bazaar development format 1 with subtree support "
 
2328
            "(needs bzr.dev from before 1.6)\n")
 
2329
 
 
2330
    def get_format_description(self):
 
2331
        """See RepositoryFormat.get_format_description()."""
 
2332
        return ("Development repository format, currently the same as "
 
2333
            "pack-0.92-subtree with external reference support.\n")