1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
from bzrlib.repository import (
32
class KnitRepository2(KnitRepository):
34
def __init__(self, _format, a_bzrdir, control_files, _revision_store,
35
control_store, text_store):
36
KnitRepository.__init__(self, _format, a_bzrdir, control_files,
37
_revision_store, control_store, text_store)
38
self._serializer = xml6.serializer_v6
40
def deserialise_inventory(self, revision_id, xml):
41
"""Transform the xml into an inventory object.
43
:param revision_id: The expected revision id of the inventory.
44
:param xml: A serialised inventory.
46
result = self._serializer.read_inventory_from_string(xml)
47
assert result.root.revision is not None
50
def serialise_inventory(self, inv):
51
"""Transform the inventory object into XML text.
53
:param revision_id: The expected revision id of the inventory.
54
:param xml: A serialised inventory.
56
assert inv.revision_id is not None
57
assert inv.root.revision is not None
58
return KnitRepository.serialise_inventory(self, inv)
60
def get_commit_builder(self, branch, parents, config, timestamp=None,
61
timezone=None, committer=None, revprops=None,
63
"""Obtain a CommitBuilder for this repository.
65
:param branch: Branch to commit to.
66
:param parents: Revision ids of the parents of the new revision.
67
:param config: Configuration to use.
68
:param timestamp: Optional timestamp recorded for commit.
69
:param timezone: Optional timezone for timestamp.
70
:param committer: Optional committer to set for commit.
71
:param revprops: Optional dictionary of revision properties.
72
:param revision_id: Optional revision id.
74
return RootCommitBuilder(self, parents, config, timestamp, timezone,
75
committer, revprops, revision_id)
78
class RepositoryFormatKnit2(RepositoryFormatKnit):
79
"""Bzr repository knit format 2.
81
THIS FORMAT IS EXPERIMENTAL
82
This repository format has:
83
- knits for file texts and inventory
84
- hash subdirectory based stores.
85
- knits for revisions and signatures
86
- TextStores for revisions and signatures.
87
- a format marker of its own
88
- an optional 'shared-storage' flag
89
- an optional 'no-working-trees' flag
91
- Support for recording full info about the tree root
97
def get_format_string(self):
98
"""See RepositoryFormat.get_format_string()."""
99
return "Bazaar Knit Repository Format 2\n"
101
def get_format_description(self):
102
"""See RepositoryFormat.get_format_description()."""
103
return "Knit repository format 2"
105
def check_conversion_target(self, target_format):
106
if not target_format.rich_root_data:
107
raise errors.BadConversionTarget(
108
'Does not support rich root data.', target_format)
110
def open(self, a_bzrdir, _found=False, _override_transport=None):
111
"""See RepositoryFormat.open().
113
:param _override_transport: INTERNAL USE ONLY. Allows opening the
114
repository at a slightly different url
115
than normal. I.e. during 'upgrade'.
118
format = RepositoryFormat.find_format(a_bzrdir)
119
assert format.__class__ == self.__class__
120
if _override_transport is not None:
121
repo_transport = _override_transport
123
repo_transport = a_bzrdir.get_repository_transport(None)
124
control_files = lockable_files.LockableFiles(repo_transport, 'lock',
126
text_store = self._get_text_store(repo_transport, control_files)
127
control_store = self._get_control_store(repo_transport, control_files)
128
_revision_store = self._get_revision_store(repo_transport, control_files)
129
return KnitRepository2(_format=self,
131
control_files=control_files,
132
_revision_store=_revision_store,
133
control_store=control_store,
134
text_store=text_store)
137
RepositoryFormatKnit2_instance = RepositoryFormatKnit2()