~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/pack_repo.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-08-06 22:49:13 UTC
  • mfrom: (3603.2.1 dupe-code)
  • Revision ID: pqm@pqm.ubuntu.com-20080806224913-zg129xmi6x8045k3
Remove duplicated class definitions and remove unused imports from
        pack_repo.py. (Andrew Bennetts)

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
 
1819
1810
            raise errors.ReadOnlyError(self)
1820
1811
        self._write_lock_count += 1
1821
1812
        if self._write_lock_count == 1:
1822
 
            from bzrlib import transactions
1823
1813
            self._transaction = transactions.WriteTransaction()
1824
1814
            for repo in self._fallback_repositories:
1825
1815
                # Writes don't affect fallback repos
1980
1970
        pass
1981
1971
 
1982
1972
 
1983
 
class RepositoryFormatPack(MetaDirRepositoryFormat):
1984
 
    """Format logic for pack structured repositories.
1985
 
 
1986
 
    This repository format has:
1987
 
     - a list of packs in pack-names
1988
 
     - packs in packs/NAME.pack
1989
 
     - indices in indices/NAME.{iix,six,tix,rix}
1990
 
     - knit deltas in the packs, knit indices mapped to the indices.
1991
 
     - thunk objects to support the knits programming API.
1992
 
     - a format marker of its own
1993
 
     - an optional 'shared-storage' flag
1994
 
     - an optional 'no-working-trees' flag
1995
 
     - a LockDir lock
1996
 
    """
1997
 
 
1998
 
    # Set this attribute in derived classes to control the repository class
1999
 
    # created by open and initialize.
2000
 
    repository_class = None
2001
 
    # Set this attribute in derived classes to control the
2002
 
    # _commit_builder_class that the repository objects will have passed to
2003
 
    # their constructor.
2004
 
    _commit_builder_class = None
2005
 
    # Set this attribute in derived clases to control the _serializer that the
2006
 
    # repository objects will have passed to their constructor.
2007
 
    _serializer = None
2008
 
    # External references are not supported in pack repositories yet.
2009
 
    supports_external_lookups = False
2010
 
 
2011
 
    def initialize(self, a_bzrdir, shared=False):
2012
 
        """Create a pack based repository.
2013
 
 
2014
 
        :param a_bzrdir: bzrdir to contain the new repository; must already
2015
 
            be initialized.
2016
 
        :param shared: If true the repository will be initialized as a shared
2017
 
                       repository.
2018
 
        """
2019
 
        mutter('creating repository in %s.', a_bzrdir.transport.base)
2020
 
        dirs = ['indices', 'obsolete_packs', 'packs', 'upload']
2021
 
        builder = GraphIndexBuilder()
2022
 
        files = [('pack-names', builder.finish())]
2023
 
        utf8_files = [('format', self.get_format_string())]
2024
 
        
2025
 
        self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
2026
 
        return self.open(a_bzrdir=a_bzrdir, _found=True)
2027
 
 
2028
 
    def open(self, a_bzrdir, _found=False, _override_transport=None):
2029
 
        """See RepositoryFormat.open().
2030
 
        
2031
 
        :param _override_transport: INTERNAL USE ONLY. Allows opening the
2032
 
                                    repository at a slightly different url
2033
 
                                    than normal. I.e. during 'upgrade'.
2034
 
        """
2035
 
        if not _found:
2036
 
            format = RepositoryFormat.find_format(a_bzrdir)
2037
 
        if _override_transport is not None:
2038
 
            repo_transport = _override_transport
2039
 
        else:
2040
 
            repo_transport = a_bzrdir.get_repository_transport(None)
2041
 
        control_files = lockable_files.LockableFiles(repo_transport,
2042
 
                                'lock', lockdir.LockDir)
2043
 
        return self.repository_class(_format=self,
2044
 
                              a_bzrdir=a_bzrdir,
2045
 
                              control_files=control_files,
2046
 
                              _commit_builder_class=self._commit_builder_class,
2047
 
                              _serializer=self._serializer)
2048
 
 
2049
 
 
2050
 
class RepositoryFormatKnitPack1(RepositoryFormatPack):
2051
 
    """A no-subtrees parameterized Pack repository.
2052
 
 
2053
 
    This format was introduced in 0.92.
2054
 
    """
2055
 
 
2056
 
    repository_class = KnitPackRepository
2057
 
    _commit_builder_class = PackCommitBuilder
2058
 
    _serializer = xml5.serializer_v5
2059
 
 
2060
 
    def _get_matching_bzrdir(self):
2061
 
        return bzrdir.format_registry.make_bzrdir('pack-0.92')
2062
 
 
2063
 
    def _ignore_setting_bzrdir(self, format):
2064
 
        pass
2065
 
 
2066
 
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
2067
 
 
2068
 
    def get_format_string(self):
2069
 
        """See RepositoryFormat.get_format_string()."""
2070
 
        return "Bazaar pack repository format 1 (needs bzr 0.92)\n"
2071
 
 
2072
 
    def get_format_description(self):
2073
 
        """See RepositoryFormat.get_format_description()."""
2074
 
        return "Packs containing knits without subtree support"
2075
 
 
2076
 
    def check_conversion_target(self, target_format):
2077
 
        pass
2078
 
 
2079
 
 
2080
1973
class RepositoryFormatKnitPack3(RepositoryFormatPack):
2081
1974
    """A subtrees parameterized Pack repository.
2082
1975