bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
5590.1.6
by John Arbash Meinel
Found another tuned_gzip use in weaverepo |
1 |
# Copyright (C) 2007-2011 Canonical Ltd
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
2 |
#
|
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.
|
|
7 |
#
|
|
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.
|
|
12 |
#
|
|
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
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
16 |
|
|
2803.2.1
by Robert Collins
* CommitBuilder now advertises itself as requiring the root entry to be |
17 |
"""Deprecated weave-based repository formats.
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
18 |
|
|
2803.2.1
by Robert Collins
* CommitBuilder now advertises itself as requiring the root entry to be |
19 |
Weave based formats scaled linearly with history size and could not represent
|
20 |
ghosts.
|
|
21 |
"""
|
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
22 |
|
|
5590.1.6
by John Arbash Meinel
Found another tuned_gzip use in weaverepo |
23 |
import gzip |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
24 |
import os |
25 |
from cStringIO import StringIO |
|
26 |
import urllib |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
27 |
|
|
3224.5.1
by Andrew Bennetts
Lots of assorted hackery to reduce the number of imports for common operations. Improves 'rocks', 'st' and 'help' times by ~50ms on my laptop. |
28 |
from bzrlib.lazy_import import lazy_import |
29 |
lazy_import(globals(), """ |
|
30 |
from bzrlib import (
|
|
31 |
xml5,
|
|
|
4593.5.34
by John Arbash Meinel
Change the KnownGraph.merge_sort api. |
32 |
graph as _mod_graph,
|
|
5537.2.1
by Jelmer Vernooij
Move InterWeaveRepo and InterKnitRepo to related repository files. |
33 |
ui,
|
|
3224.5.1
by Andrew Bennetts
Lots of assorted hackery to reduce the number of imports for common operations. Improves 'rocks', 'st' and 'help' times by ~50ms on my laptop. |
34 |
)
|
35 |
""") |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
36 |
from bzrlib import ( |
37 |
bzrdir, |
|
|
2850.3.1
by Robert Collins
Move various weave specific code out of the base Repository class to weaverepo.py. |
38 |
debug, |
39 |
errors, |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
40 |
lockable_files, |
41 |
lockdir, |
|
|
2803.2.1
by Robert Collins
* CommitBuilder now advertises itself as requiring the root entry to be |
42 |
osutils, |
|
5539.2.10
by Andrew Bennetts
s/NotInOtherForRev/NotInOtherForRevs/, and allow passing multiple revision_ids to search_missing_revision_ids. |
43 |
symbol_versioning, |
|
5184.1.1
by Vincent Ladeuil
Random cleanups to catch up with copyright updates in trunk. |
44 |
trace, |
|
5590.1.6
by John Arbash Meinel
Found another tuned_gzip use in weaverepo |
45 |
tuned_gzip, |
|
3834.2.2
by Martin Pool
Deprecated LockableFiles._escape |
46 |
urlutils, |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
47 |
versionedfile, |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
48 |
weave, |
49 |
weavefile, |
|
|
3224.5.4
by Andrew Bennetts
Fix test suite, mainly weeding out uses of bzrlib.user_encoding. |
50 |
)
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
51 |
from bzrlib.decorators import needs_read_lock, needs_write_lock |
52 |
from bzrlib.repository import ( |
|
|
2803.2.1
by Robert Collins
* CommitBuilder now advertises itself as requiring the root entry to be |
53 |
CommitBuilder, |
|
5537.2.1
by Jelmer Vernooij
Move InterWeaveRepo and InterKnitRepo to related repository files. |
54 |
InterRepository, |
55 |
InterSameDataRepository, |
|
|
3316.2.3
by Robert Collins
Remove manual notification of transaction finishing on versioned files. |
56 |
MetaDirVersionedFileRepository, |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
57 |
MetaDirRepositoryFormat, |
58 |
Repository, |
|
59 |
RepositoryFormat, |
|
60 |
)
|
|
61 |
from bzrlib.store.text import TextStore |
|
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
62 |
from bzrlib.versionedfile import ( |
63 |
AbsentContentFactory, |
|
64 |
FulltextContentFactory, |
|
65 |
VersionedFiles, |
|
66 |
)
|
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
67 |
|
68 |
||
69 |
class AllInOneRepository(Repository): |
|
70 |
"""Legacy support - the repository behaviour for all-in-one branches.""" |
|
71 |
||
|
3224.5.1
by Andrew Bennetts
Lots of assorted hackery to reduce the number of imports for common operations. Improves 'rocks', 'st' and 'help' times by ~50ms on my laptop. |
72 |
@property
|
73 |
def _serializer(self): |
|
74 |
return xml5.serializer_v5 |
|
|
2241.1.8
by Martin Pool
Set the repository's serializer in the places it's needed, not in the base class |
75 |
|
|
3834.2.2
by Martin Pool
Deprecated LockableFiles._escape |
76 |
def _escape(self, file_or_path): |
77 |
if not isinstance(file_or_path, basestring): |
|
78 |
file_or_path = '/'.join(file_or_path) |
|
79 |
if file_or_path == '': |
|
80 |
return u'' |
|
81 |
return urlutils.escape(osutils.safe_unicode(file_or_path)) |
|
82 |
||
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
83 |
def __init__(self, _format, a_bzrdir): |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
84 |
# we reuse one control files instance.
|
|
3416.2.3
by Martin Pool
typo |
85 |
dir_mode = a_bzrdir._get_dir_mode() |
86 |
file_mode = a_bzrdir._get_file_mode() |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
87 |
|
88 |
def get_store(name, compressed=True, prefixed=False): |
|
89 |
# FIXME: This approach of assuming stores are all entirely compressed
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
90 |
# or entirely uncompressed is tidy, but breaks upgrade from
|
91 |
# some existing branches where there's a mixture; we probably
|
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
92 |
# still want the option to look for both.
|
|
3834.2.2
by Martin Pool
Deprecated LockableFiles._escape |
93 |
relpath = self._escape(name) |
|
3407.2.13
by Martin Pool
Remove indirection through control_files to get transports |
94 |
store = TextStore(a_bzrdir.transport.clone(relpath), |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
95 |
prefixed=prefixed, compressed=compressed, |
96 |
dir_mode=dir_mode, |
|
97 |
file_mode=file_mode) |
|
98 |
return store |
|
99 |
||
100 |
# not broken out yet because the controlweaves|inventory_store
|
|
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
101 |
# and texts bits are still different.
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
102 |
if isinstance(_format, RepositoryFormat4): |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
103 |
# cannot remove these - there is still no consistent api
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
104 |
# which allows access to this old info.
|
105 |
self.inventory_store = get_store('inventory-store') |
|
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
106 |
self._text_store = get_store('text-store') |
107 |
super(AllInOneRepository, self).__init__(_format, a_bzrdir, a_bzrdir._control_files) |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
108 |
|
|
2850.3.1
by Robert Collins
Move various weave specific code out of the base Repository class to weaverepo.py. |
109 |
@needs_read_lock
|
110 |
def _all_possible_ids(self): |
|
111 |
"""Return all the possible revisions that we could find.""" |
|
112 |
if 'evil' in debug.debug_flags: |
|
|
5184.1.1
by Vincent Ladeuil
Random cleanups to catch up with copyright updates in trunk. |
113 |
trace.mutter_callsite( |
114 |
3, "_all_possible_ids scales with size of history.") |
|
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
115 |
return [key[-1] for key in self.inventories.keys()] |
|
2850.3.1
by Robert Collins
Move various weave specific code out of the base Repository class to weaverepo.py. |
116 |
|
117 |
@needs_read_lock
|
|
118 |
def _all_revision_ids(self): |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
119 |
"""Returns a list of all the revision ids in the repository. |
|
2850.3.1
by Robert Collins
Move various weave specific code out of the base Repository class to weaverepo.py. |
120 |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
121 |
These are in as much topological order as the underlying store can
|
|
2850.3.1
by Robert Collins
Move various weave specific code out of the base Repository class to weaverepo.py. |
122 |
present: for weaves ghosts may lead to a lack of correctness until
|
123 |
the reweave updates the parents list.
|
|
124 |
"""
|
|
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
125 |
return [key[-1] for key in self.revisions.keys()] |
126 |
||
127 |
def _activate_new_inventory(self): |
|
128 |
"""Put a replacement inventory.new into use as inventories.""" |
|
129 |
# Copy the content across
|
|
130 |
t = self.bzrdir._control_files._transport |
|
131 |
t.copy('inventory.new.weave', 'inventory.weave') |
|
132 |
# delete the temp inventory
|
|
133 |
t.delete('inventory.new.weave') |
|
134 |
# Check we can parse the new weave properly as a sanity check
|
|
135 |
self.inventories.keys() |
|
136 |
||
137 |
def _backup_inventory(self): |
|
138 |
t = self.bzrdir._control_files._transport |
|
139 |
t.copy('inventory.weave', 'inventory.backup.weave') |
|
140 |
||
141 |
def _temp_inventories(self): |
|
142 |
t = self.bzrdir._control_files._transport |
|
143 |
return self._format._get_inventories(t, self, 'inventory.new') |
|
|
2850.3.1
by Robert Collins
Move various weave specific code out of the base Repository class to weaverepo.py. |
144 |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
145 |
def get_commit_builder(self, branch, parents, config, timestamp=None, |
146 |
timezone=None, committer=None, revprops=None, |
|
147 |
revision_id=None): |
|
148 |
self._check_ascii_revisionid(revision_id, self.get_commit_builder) |
|
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
149 |
result = CommitBuilder(self, parents, config, timestamp, timezone, |
|
2803.2.1
by Robert Collins
* CommitBuilder now advertises itself as requiring the root entry to be |
150 |
committer, revprops, revision_id) |
151 |
self.start_write_group() |
|
152 |
return result |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
153 |
|
154 |
@needs_read_lock
|
|
|
2850.3.1
by Robert Collins
Move various weave specific code out of the base Repository class to weaverepo.py. |
155 |
def get_revisions(self, revision_ids): |
156 |
revs = self._get_revisions(revision_ids) |
|
157 |
return revs |
|
158 |
||
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
159 |
def _inventory_add_lines(self, revision_id, parents, lines, |
160 |
check_content=True): |
|
161 |
"""Store lines in inv_vf and return the sha1 of the inventory.""" |
|
162 |
present_parents = self.get_graph().get_parent_map(parents) |
|
163 |
final_parents = [] |
|
164 |
for parent in parents: |
|
165 |
if parent in present_parents: |
|
166 |
final_parents.append((parent,)) |
|
167 |
return self.inventories.add_lines((revision_id,), final_parents, lines, |
|
168 |
check_content=check_content)[0] |
|
|
3172.3.1
by Robert Collins
Repository has a new method ``has_revisions`` which signals the presence |
169 |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
170 |
def is_shared(self): |
171 |
"""AllInOne repositories cannot be shared.""" |
|
172 |
return False |
|
173 |
||
174 |
@needs_write_lock
|
|
175 |
def set_make_working_trees(self, new_value): |
|
176 |
"""Set the policy flag for making working trees when creating branches. |
|
177 |
||
178 |
This only applies to branches that use this repository.
|
|
179 |
||
180 |
The default is 'True'.
|
|
181 |
:param new_value: True to restore the default, False to disable making
|
|
182 |
working trees.
|
|
183 |
"""
|
|
|
5158.6.10
by Martin Pool
Update more code to use user_transport when it should |
184 |
raise errors.RepositoryUpgradeRequired(self.user_url) |
|
3349.1.1
by Aaron Bentley
Enable setting and getting make_working_trees for all repositories |
185 |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
186 |
def make_working_trees(self): |
187 |
"""Returns the policy for making working trees on new branches.""" |
|
188 |
return True |
|
189 |
||
|
2819.2.4
by Andrew Bennetts
Add a 'revision_graph_can_have_wrong_parents' method to repository. |
190 |
def revision_graph_can_have_wrong_parents(self): |
191 |
# XXX: This is an old format that we don't support full checking on, so
|
|
192 |
# just claim that checking for this inconsistency is not required.
|
|
193 |
return False |
|
194 |
||
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
195 |
|
|
3316.2.3
by Robert Collins
Remove manual notification of transaction finishing on versioned files. |
196 |
class WeaveMetaDirRepository(MetaDirVersionedFileRepository): |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
197 |
"""A subclass of MetaDirRepository to set weave specific policy.""" |
198 |
||
|
3565.3.1
by Robert Collins
* The generic fetch code now uses two attributes on Repository objects |
199 |
def __init__(self, _format, a_bzrdir, control_files): |
200 |
super(WeaveMetaDirRepository, self).__init__(_format, a_bzrdir, control_files) |
|
|
4022.1.1
by Robert Collins
Refactoring of fetch to have a sender and sink component enabling splitting the logic over a network stream. (Robert Collins, Andrew Bennetts) |
201 |
self._serializer = _format._serializer |
|
3565.3.1
by Robert Collins
* The generic fetch code now uses two attributes on Repository objects |
202 |
|
|
2850.3.1
by Robert Collins
Move various weave specific code out of the base Repository class to weaverepo.py. |
203 |
@needs_read_lock
|
204 |
def _all_possible_ids(self): |
|
205 |
"""Return all the possible revisions that we could find.""" |
|
206 |
if 'evil' in debug.debug_flags: |
|
|
5184.1.1
by Vincent Ladeuil
Random cleanups to catch up with copyright updates in trunk. |
207 |
trace.mutter_callsite( |
208 |
3, "_all_possible_ids scales with size of history.") |
|
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
209 |
return [key[-1] for key in self.inventories.keys()] |
|
2850.3.1
by Robert Collins
Move various weave specific code out of the base Repository class to weaverepo.py. |
210 |
|
211 |
@needs_read_lock
|
|
212 |
def _all_revision_ids(self): |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
213 |
"""Returns a list of all the revision ids in the repository. |
|
2850.3.1
by Robert Collins
Move various weave specific code out of the base Repository class to weaverepo.py. |
214 |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
215 |
These are in as much topological order as the underlying store can
|
|
2850.3.1
by Robert Collins
Move various weave specific code out of the base Repository class to weaverepo.py. |
216 |
present: for weaves ghosts may lead to a lack of correctness until
|
217 |
the reweave updates the parents list.
|
|
218 |
"""
|
|
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
219 |
return [key[-1] for key in self.revisions.keys()] |
220 |
||
221 |
def _activate_new_inventory(self): |
|
222 |
"""Put a replacement inventory.new into use as inventories.""" |
|
223 |
# Copy the content across
|
|
224 |
t = self._transport |
|
225 |
t.copy('inventory.new.weave', 'inventory.weave') |
|
226 |
# delete the temp inventory
|
|
227 |
t.delete('inventory.new.weave') |
|
228 |
# Check we can parse the new weave properly as a sanity check
|
|
229 |
self.inventories.keys() |
|
230 |
||
231 |
def _backup_inventory(self): |
|
232 |
t = self._transport |
|
233 |
t.copy('inventory.weave', 'inventory.backup.weave') |
|
234 |
||
235 |
def _temp_inventories(self): |
|
236 |
t = self._transport |
|
237 |
return self._format._get_inventories(t, self, 'inventory.new') |
|
|
2850.3.1
by Robert Collins
Move various weave specific code out of the base Repository class to weaverepo.py. |
238 |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
239 |
def get_commit_builder(self, branch, parents, config, timestamp=None, |
240 |
timezone=None, committer=None, revprops=None, |
|
241 |
revision_id=None): |
|
242 |
self._check_ascii_revisionid(revision_id, self.get_commit_builder) |
|
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
243 |
result = CommitBuilder(self, parents, config, timestamp, timezone, |
|
2803.2.1
by Robert Collins
* CommitBuilder now advertises itself as requiring the root entry to be |
244 |
committer, revprops, revision_id) |
245 |
self.start_write_group() |
|
246 |
return result |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
247 |
|
|
2850.3.1
by Robert Collins
Move various weave specific code out of the base Repository class to weaverepo.py. |
248 |
@needs_read_lock
|
249 |
def get_revision(self, revision_id): |
|
250 |
"""Return the Revision object for a named revision""" |
|
251 |
r = self.get_revision_reconcile(revision_id) |
|
252 |
return r |
|
253 |
||
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
254 |
def _inventory_add_lines(self, revision_id, parents, lines, |
255 |
check_content=True): |
|
256 |
"""Store lines in inv_vf and return the sha1 of the inventory.""" |
|
257 |
present_parents = self.get_graph().get_parent_map(parents) |
|
258 |
final_parents = [] |
|
259 |
for parent in parents: |
|
260 |
if parent in present_parents: |
|
261 |
final_parents.append((parent,)) |
|
262 |
return self.inventories.add_lines((revision_id,), final_parents, lines, |
|
263 |
check_content=check_content)[0] |
|
|
3172.3.1
by Robert Collins
Repository has a new method ``has_revisions`` which signals the presence |
264 |
|
|
2819.2.4
by Andrew Bennetts
Add a 'revision_graph_can_have_wrong_parents' method to repository. |
265 |
def revision_graph_can_have_wrong_parents(self): |
266 |
return False |
|
267 |
||
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
268 |
|
269 |
class PreSplitOutRepositoryFormat(RepositoryFormat): |
|
270 |
"""Base class for the pre split out repository formats.""" |
|
271 |
||
272 |
rich_root_data = False |
|
|
2323.5.17
by Martin Pool
Add supports_tree_reference to all repo formats (robert) |
273 |
supports_tree_reference = False |
|
2949.1.2
by Robert Collins
* Fetch with pack repositories will no longer read the entire history graph. |
274 |
supports_ghosts = False |
|
3221.3.1
by Robert Collins
* Repository formats have a new supported-feature attribute |
275 |
supports_external_lookups = False |
|
4246.2.1
by Ian Clatworthy
supports_chks flag on repo formats & log tuning |
276 |
supports_chks = False |
|
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
277 |
_fetch_order = 'topological' |
278 |
_fetch_reconcile = True |
|
|
4183.5.1
by Robert Collins
Add RepositoryFormat.fast_deltas to signal fast delta creation. |
279 |
fast_deltas = False |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
280 |
|
281 |
def initialize(self, a_bzrdir, shared=False, _internal=False): |
|
|
2949.1.2
by Robert Collins
* Fetch with pack repositories will no longer read the entire history graph. |
282 |
"""Create a weave repository.""" |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
283 |
if shared: |
284 |
raise errors.IncompatibleFormat(self, a_bzrdir._format) |
|
285 |
||
286 |
if not _internal: |
|
287 |
# always initialized when the bzrdir is.
|
|
288 |
return self.open(a_bzrdir, _found=True) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
289 |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
290 |
# Create an empty weave
|
291 |
sio = StringIO() |
|
292 |
weavefile.write_weave_v5(weave.Weave(), sio) |
|
293 |
empty_weave = sio.getvalue() |
|
294 |
||
|
5184.1.1
by Vincent Ladeuil
Random cleanups to catch up with copyright updates in trunk. |
295 |
trace.mutter('creating repository in %s.', a_bzrdir.transport.base) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
296 |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
297 |
# FIXME: RBC 20060125 don't peek under the covers
|
298 |
# NB: no need to escape relative paths that are url safe.
|
|
299 |
control_files = lockable_files.LockableFiles(a_bzrdir.transport, |
|
|
3407.2.4
by Martin Pool
Small cleanups to initial creation of repository files |
300 |
'branch-lock', lockable_files.TransportLock) |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
301 |
control_files.create_lock() |
302 |
control_files.lock_write() |
|
|
3407.2.13
by Martin Pool
Remove indirection through control_files to get transports |
303 |
transport = a_bzrdir.transport |
|
3407.2.4
by Martin Pool
Small cleanups to initial creation of repository files |
304 |
try: |
305 |
transport.mkdir_multi(['revision-store', 'weaves'], |
|
|
3407.2.18
by Martin Pool
BzrDir takes responsibility for default file/dir modes |
306 |
mode=a_bzrdir._get_dir_mode()) |
307 |
transport.put_bytes_non_atomic('inventory.weave', empty_weave, |
|
308 |
mode=a_bzrdir._get_file_mode()) |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
309 |
finally: |
310 |
control_files.unlock() |
|
|
5107.3.1
by Marco Pantaleoni
Added the new hooks 'post_branch', 'post_switch' and 'post_repo_init', |
311 |
repository = self.open(a_bzrdir, _found=True) |
312 |
self._run_post_repo_init_hooks(repository, a_bzrdir, shared) |
|
313 |
return repository |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
314 |
|
315 |
def open(self, a_bzrdir, _found=False): |
|
316 |
"""See RepositoryFormat.open().""" |
|
317 |
if not _found: |
|
318 |
# we are being called directly and must probe.
|
|
319 |
raise NotImplementedError |
|
320 |
||
321 |
repo_transport = a_bzrdir.get_repository_transport(None) |
|
322 |
control_files = a_bzrdir._control_files |
|
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
323 |
result = AllInOneRepository(_format=self, a_bzrdir=a_bzrdir) |
324 |
result.revisions = self._get_revisions(repo_transport, result) |
|
325 |
result.signatures = self._get_signatures(repo_transport, result) |
|
326 |
result.inventories = self._get_inventories(repo_transport, result) |
|
327 |
result.texts = self._get_texts(repo_transport, result) |
|
|
4246.2.1
by Ian Clatworthy
supports_chks flag on repo formats & log tuning |
328 |
result.chk_bytes = None |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
329 |
return result |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
330 |
|
331 |
||
332 |
class RepositoryFormat4(PreSplitOutRepositoryFormat): |
|
333 |
"""Bzr repository format 4. |
|
334 |
||
335 |
This repository format has:
|
|
336 |
- flat stores
|
|
337 |
- TextStores for texts, inventories,revisions.
|
|
338 |
||
339 |
This format is deprecated: it indexes texts using a text id which is
|
|
340 |
removed in format 5; initialization and write support for this format
|
|
341 |
has been removed.
|
|
342 |
"""
|
|
343 |
||
|
5582.9.1
by Jelmer Vernooij
Add flag for 'supports_funky_characters'. |
344 |
supports_funky_characters = False |
345 |
||
|
2241.1.11
by Martin Pool
Get rid of RepositoryFormat*_instance objects. Instead the format |
346 |
_matchingbzrdir = bzrdir.BzrDirFormat4() |
347 |
||
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
348 |
def get_format_description(self): |
349 |
"""See RepositoryFormat.get_format_description().""" |
|
350 |
return "Repository format 4" |
|
351 |
||
352 |
def initialize(self, url, shared=False, _internal=False): |
|
353 |
"""Format 4 branches cannot be created.""" |
|
354 |
raise errors.UninitializableFormat(self) |
|
355 |
||
356 |
def is_supported(self): |
|
357 |
"""Format 4 is not supported. |
|
358 |
||
359 |
It is not supported because the model changed from 4 to 5 and the
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
360 |
conversion logic is expensive - so doing it on the fly was not
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
361 |
feasible.
|
362 |
"""
|
|
363 |
return False |
|
364 |
||
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
365 |
def _get_inventories(self, repo_transport, repo, name='inventory'): |
366 |
# No inventories store written so far.
|
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
367 |
return None |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
368 |
|
369 |
def _get_revisions(self, repo_transport, repo): |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
370 |
from bzrlib.xml4 import serializer_v4 |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
371 |
return RevisionTextStore(repo_transport.clone('revision-store'), |
372 |
serializer_v4, True, versionedfile.PrefixMapper(), |
|
373 |
repo.is_locked, repo.is_write_locked) |
|
374 |
||
375 |
def _get_signatures(self, repo_transport, repo): |
|
376 |
return SignatureTextStore(repo_transport.clone('revision-store'), |
|
377 |
False, versionedfile.PrefixMapper(), |
|
378 |
repo.is_locked, repo.is_write_locked) |
|
379 |
||
380 |
def _get_texts(self, repo_transport, repo): |
|
381 |
return None |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
382 |
|
383 |
||
384 |
class RepositoryFormat5(PreSplitOutRepositoryFormat): |
|
385 |
"""Bzr control format 5. |
|
386 |
||
387 |
This repository format has:
|
|
388 |
- weaves for file texts and inventory
|
|
389 |
- flat stores
|
|
390 |
- TextStores for revisions and signatures.
|
|
391 |
"""
|
|
392 |
||
|
2241.1.10
by Martin Pool
Remove more references to weaves from the repository.py file |
393 |
_versionedfile_class = weave.WeaveFile |
|
2241.1.11
by Martin Pool
Get rid of RepositoryFormat*_instance objects. Instead the format |
394 |
_matchingbzrdir = bzrdir.BzrDirFormat5() |
|
5582.9.1
by Jelmer Vernooij
Add flag for 'supports_funky_characters'. |
395 |
supports_funky_characters = False |
396 |
||
|
4022.1.1
by Robert Collins
Refactoring of fetch to have a sender and sink component enabling splitting the logic over a network stream. (Robert Collins, Andrew Bennetts) |
397 |
@property
|
398 |
def _serializer(self): |
|
399 |
return xml5.serializer_v5 |
|
|
2241.1.10
by Martin Pool
Remove more references to weaves from the repository.py file |
400 |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
401 |
def get_format_description(self): |
402 |
"""See RepositoryFormat.get_format_description().""" |
|
403 |
return "Weave repository format 5" |
|
|
4032.1.2
by John Arbash Meinel
Track down a few more files that have trailing whitespace. |
404 |
|
|
3990.5.1
by Andrew Bennetts
Add network_name() to RepositoryFormat. |
405 |
def network_name(self): |
|
3990.5.3
by Robert Collins
Docs and polish on RepositoryFormat.network_name. |
406 |
"""The network name for this format is the control dirs disk label.""" |
|
3990.5.1
by Andrew Bennetts
Add network_name() to RepositoryFormat. |
407 |
return self._matchingbzrdir.get_format_string() |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
408 |
|
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
409 |
def _get_inventories(self, repo_transport, repo, name='inventory'): |
410 |
mapper = versionedfile.ConstantMapper(name) |
|
411 |
return versionedfile.ThunkedVersionedFiles(repo_transport, |
|
412 |
weave.WeaveFile, mapper, repo.is_locked) |
|
413 |
||
414 |
def _get_revisions(self, repo_transport, repo): |
|
415 |
return RevisionTextStore(repo_transport.clone('revision-store'), |
|
|
4022.1.1
by Robert Collins
Refactoring of fetch to have a sender and sink component enabling splitting the logic over a network stream. (Robert Collins, Andrew Bennetts) |
416 |
xml5.serializer_v5, False, versionedfile.PrefixMapper(), |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
417 |
repo.is_locked, repo.is_write_locked) |
418 |
||
419 |
def _get_signatures(self, repo_transport, repo): |
|
420 |
return SignatureTextStore(repo_transport.clone('revision-store'), |
|
421 |
False, versionedfile.PrefixMapper(), |
|
422 |
repo.is_locked, repo.is_write_locked) |
|
423 |
||
424 |
def _get_texts(self, repo_transport, repo): |
|
425 |
mapper = versionedfile.PrefixMapper() |
|
426 |
base_transport = repo_transport.clone('weaves') |
|
427 |
return versionedfile.ThunkedVersionedFiles(base_transport, |
|
428 |
weave.WeaveFile, mapper, repo.is_locked) |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
429 |
|
430 |
||
431 |
class RepositoryFormat6(PreSplitOutRepositoryFormat): |
|
432 |
"""Bzr control format 6. |
|
433 |
||
434 |
This repository format has:
|
|
435 |
- weaves for file texts and inventory
|
|
436 |
- hash subdirectory based stores.
|
|
437 |
- TextStores for revisions and signatures.
|
|
438 |
"""
|
|
439 |
||
|
2241.1.10
by Martin Pool
Remove more references to weaves from the repository.py file |
440 |
_versionedfile_class = weave.WeaveFile |
|
2241.1.11
by Martin Pool
Get rid of RepositoryFormat*_instance objects. Instead the format |
441 |
_matchingbzrdir = bzrdir.BzrDirFormat6() |
|
5582.9.1
by Jelmer Vernooij
Add flag for 'supports_funky_characters'. |
442 |
supports_funky_characters = False |
|
4022.1.1
by Robert Collins
Refactoring of fetch to have a sender and sink component enabling splitting the logic over a network stream. (Robert Collins, Andrew Bennetts) |
443 |
@property
|
444 |
def _serializer(self): |
|
445 |
return xml5.serializer_v5 |
|
|
2241.1.10
by Martin Pool
Remove more references to weaves from the repository.py file |
446 |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
447 |
def get_format_description(self): |
448 |
"""See RepositoryFormat.get_format_description().""" |
|
449 |
return "Weave repository format 6" |
|
450 |
||
|
3990.5.1
by Andrew Bennetts
Add network_name() to RepositoryFormat. |
451 |
def network_name(self): |
|
3990.5.3
by Robert Collins
Docs and polish on RepositoryFormat.network_name. |
452 |
"""The network name for this format is the control dirs disk label.""" |
|
3990.5.1
by Andrew Bennetts
Add network_name() to RepositoryFormat. |
453 |
return self._matchingbzrdir.get_format_string() |
454 |
||
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
455 |
def _get_inventories(self, repo_transport, repo, name='inventory'): |
456 |
mapper = versionedfile.ConstantMapper(name) |
|
457 |
return versionedfile.ThunkedVersionedFiles(repo_transport, |
|
458 |
weave.WeaveFile, mapper, repo.is_locked) |
|
459 |
||
460 |
def _get_revisions(self, repo_transport, repo): |
|
461 |
return RevisionTextStore(repo_transport.clone('revision-store'), |
|
|
4022.1.1
by Robert Collins
Refactoring of fetch to have a sender and sink component enabling splitting the logic over a network stream. (Robert Collins, Andrew Bennetts) |
462 |
xml5.serializer_v5, False, versionedfile.HashPrefixMapper(), |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
463 |
repo.is_locked, repo.is_write_locked) |
464 |
||
465 |
def _get_signatures(self, repo_transport, repo): |
|
466 |
return SignatureTextStore(repo_transport.clone('revision-store'), |
|
467 |
False, versionedfile.HashPrefixMapper(), |
|
468 |
repo.is_locked, repo.is_write_locked) |
|
469 |
||
470 |
def _get_texts(self, repo_transport, repo): |
|
471 |
mapper = versionedfile.HashPrefixMapper() |
|
472 |
base_transport = repo_transport.clone('weaves') |
|
473 |
return versionedfile.ThunkedVersionedFiles(base_transport, |
|
474 |
weave.WeaveFile, mapper, repo.is_locked) |
|
475 |
||
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
476 |
|
477 |
class RepositoryFormat7(MetaDirRepositoryFormat): |
|
478 |
"""Bzr repository 7. |
|
479 |
||
480 |
This repository format has:
|
|
481 |
- weaves for file texts and inventory
|
|
482 |
- hash subdirectory based stores.
|
|
483 |
- TextStores for revisions and signatures.
|
|
484 |
- a format marker of its own
|
|
485 |
- an optional 'shared-storage' flag
|
|
486 |
- an optional 'no-working-trees' flag
|
|
487 |
"""
|
|
488 |
||
|
2241.1.10
by Martin Pool
Remove more references to weaves from the repository.py file |
489 |
_versionedfile_class = weave.WeaveFile |
|
2949.1.2
by Robert Collins
* Fetch with pack repositories will no longer read the entire history graph. |
490 |
supports_ghosts = False |
|
4246.2.1
by Ian Clatworthy
supports_chks flag on repo formats & log tuning |
491 |
supports_chks = False |
|
5609.4.1
by Jelmer Vernooij
Mark RepositoryFormat7 as not supporting funky character file names. This should fix the tests on Windows. |
492 |
supports_funky_characters = False |
|
4246.2.1
by Ian Clatworthy
supports_chks flag on repo formats & log tuning |
493 |
|
|
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
494 |
_fetch_order = 'topological' |
495 |
_fetch_reconcile = True |
|
|
4183.5.1
by Robert Collins
Add RepositoryFormat.fast_deltas to signal fast delta creation. |
496 |
fast_deltas = False |
|
4022.1.1
by Robert Collins
Refactoring of fetch to have a sender and sink component enabling splitting the logic over a network stream. (Robert Collins, Andrew Bennetts) |
497 |
@property
|
498 |
def _serializer(self): |
|
499 |
return xml5.serializer_v5 |
|
|
2241.1.10
by Martin Pool
Remove more references to weaves from the repository.py file |
500 |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
501 |
def get_format_string(self): |
502 |
"""See RepositoryFormat.get_format_string().""" |
|
503 |
return "Bazaar-NG Repository format 7" |
|
504 |
||
505 |
def get_format_description(self): |
|
506 |
"""See RepositoryFormat.get_format_description().""" |
|
507 |
return "Weave repository format 7" |
|
508 |
||
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
509 |
def _get_inventories(self, repo_transport, repo, name='inventory'): |
510 |
mapper = versionedfile.ConstantMapper(name) |
|
511 |
return versionedfile.ThunkedVersionedFiles(repo_transport, |
|
512 |
weave.WeaveFile, mapper, repo.is_locked) |
|
513 |
||
514 |
def _get_revisions(self, repo_transport, repo): |
|
515 |
return RevisionTextStore(repo_transport.clone('revision-store'), |
|
|
4022.1.1
by Robert Collins
Refactoring of fetch to have a sender and sink component enabling splitting the logic over a network stream. (Robert Collins, Andrew Bennetts) |
516 |
xml5.serializer_v5, True, versionedfile.HashPrefixMapper(), |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
517 |
repo.is_locked, repo.is_write_locked) |
518 |
||
519 |
def _get_signatures(self, repo_transport, repo): |
|
520 |
return SignatureTextStore(repo_transport.clone('revision-store'), |
|
521 |
True, versionedfile.HashPrefixMapper(), |
|
522 |
repo.is_locked, repo.is_write_locked) |
|
523 |
||
524 |
def _get_texts(self, repo_transport, repo): |
|
525 |
mapper = versionedfile.HashPrefixMapper() |
|
526 |
base_transport = repo_transport.clone('weaves') |
|
527 |
return versionedfile.ThunkedVersionedFiles(base_transport, |
|
528 |
weave.WeaveFile, mapper, repo.is_locked) |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
529 |
|
530 |
def initialize(self, a_bzrdir, shared=False): |
|
531 |
"""Create a weave repository. |
|
532 |
||
533 |
:param shared: If true the repository will be initialized as a shared
|
|
534 |
repository.
|
|
535 |
"""
|
|
536 |
# Create an empty weave
|
|
537 |
sio = StringIO() |
|
538 |
weavefile.write_weave_v5(weave.Weave(), sio) |
|
539 |
empty_weave = sio.getvalue() |
|
540 |
||
|
5184.1.1
by Vincent Ladeuil
Random cleanups to catch up with copyright updates in trunk. |
541 |
trace.mutter('creating repository in %s.', a_bzrdir.transport.base) |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
542 |
dirs = ['revision-store', 'weaves'] |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
543 |
files = [('inventory.weave', StringIO(empty_weave)), |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
544 |
]
|
545 |
utf8_files = [('format', self.get_format_string())] |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
546 |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
547 |
self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared) |
548 |
return self.open(a_bzrdir=a_bzrdir, _found=True) |
|
549 |
||
550 |
def open(self, a_bzrdir, _found=False, _override_transport=None): |
|
551 |
"""See RepositoryFormat.open(). |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
552 |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
553 |
:param _override_transport: INTERNAL USE ONLY. Allows opening the
|
554 |
repository at a slightly different url
|
|
555 |
than normal. I.e. during 'upgrade'.
|
|
556 |
"""
|
|
557 |
if not _found: |
|
558 |
format = RepositoryFormat.find_format(a_bzrdir) |
|
559 |
if _override_transport is not None: |
|
560 |
repo_transport = _override_transport |
|
561 |
else: |
|
562 |
repo_transport = a_bzrdir.get_repository_transport(None) |
|
563 |
control_files = lockable_files.LockableFiles(repo_transport, |
|
564 |
'lock', lockdir.LockDir) |
|
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
565 |
result = WeaveMetaDirRepository(_format=self, a_bzrdir=a_bzrdir, |
566 |
control_files=control_files) |
|
567 |
result.revisions = self._get_revisions(repo_transport, result) |
|
568 |
result.signatures = self._get_signatures(repo_transport, result) |
|
569 |
result.inventories = self._get_inventories(repo_transport, result) |
|
570 |
result.texts = self._get_texts(repo_transport, result) |
|
|
4246.2.1
by Ian Clatworthy
supports_chks flag on repo formats & log tuning |
571 |
result.chk_bytes = None |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
572 |
result._transport = repo_transport |
573 |
return result |
|
574 |
||
575 |
||
576 |
class TextVersionedFiles(VersionedFiles): |
|
577 |
"""Just-a-bunch-of-files based VersionedFile stores.""" |
|
578 |
||
579 |
def __init__(self, transport, compressed, mapper, is_locked, can_write): |
|
580 |
self._compressed = compressed |
|
581 |
self._transport = transport |
|
582 |
self._mapper = mapper |
|
583 |
if self._compressed: |
|
584 |
self._ext = '.gz' |
|
585 |
else: |
|
586 |
self._ext = '' |
|
587 |
self._is_locked = is_locked |
|
588 |
self._can_write = can_write |
|
589 |
||
590 |
def add_lines(self, key, parents, lines): |
|
591 |
"""Add a revision to the store.""" |
|
592 |
if not self._is_locked(): |
|
593 |
raise errors.ObjectNotLocked(self) |
|
594 |
if not self._can_write(): |
|
595 |
raise errors.ReadOnlyError(self) |
|
596 |
if '/' in key[-1]: |
|
|
3350.6.10
by Martin Pool
VersionedFiles review cleanups |
597 |
raise ValueError('bad idea to put / in %r' % (key,)) |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
598 |
text = ''.join(lines) |
599 |
if self._compressed: |
|
|
5590.1.6
by John Arbash Meinel
Found another tuned_gzip use in weaverepo |
600 |
text = tuned_gzip.bytes_to_gzip(text) |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
601 |
path = self._map(key) |
602 |
self._transport.put_bytes_non_atomic(path, text, create_parent_dir=True) |
|
603 |
||
|
5195.3.26
by Parth Malwankar
reverted changes done to insert_record_stream API |
604 |
def insert_record_stream(self, stream): |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
605 |
adapters = {} |
606 |
for record in stream: |
|
607 |
# Raise an error when a record is missing.
|
|
608 |
if record.storage_kind == 'absent': |
|
609 |
raise errors.RevisionNotPresent([record.key[0]], self) |
|
610 |
# adapt to non-tuple interface
|
|
611 |
if record.storage_kind == 'fulltext': |
|
612 |
self.add_lines(record.key, None, |
|
613 |
osutils.split_lines(record.get_bytes_as('fulltext'))) |
|
614 |
else: |
|
615 |
adapter_key = record.storage_kind, 'fulltext' |
|
616 |
try: |
|
617 |
adapter = adapters[adapter_key] |
|
618 |
except KeyError: |
|
619 |
adapter_factory = adapter_registry.get(adapter_key) |
|
620 |
adapter = adapter_factory(self) |
|
621 |
adapters[adapter_key] = adapter |
|
622 |
lines = osutils.split_lines(adapter.get_bytes( |
|
623 |
record, record.get_bytes_as(record.storage_kind))) |
|
624 |
try: |
|
625 |
self.add_lines(record.key, None, lines) |
|
626 |
except RevisionAlreadyPresent: |
|
627 |
pass
|
|
628 |
||
629 |
def _load_text(self, key): |
|
630 |
if not self._is_locked(): |
|
631 |
raise errors.ObjectNotLocked(self) |
|
632 |
path = self._map(key) |
|
633 |
try: |
|
634 |
text = self._transport.get_bytes(path) |
|
635 |
compressed = self._compressed |
|
636 |
except errors.NoSuchFile: |
|
637 |
if self._compressed: |
|
638 |
# try without the .gz
|
|
639 |
path = path[:-3] |
|
640 |
try: |
|
641 |
text = self._transport.get_bytes(path) |
|
642 |
compressed = False |
|
643 |
except errors.NoSuchFile: |
|
644 |
return None |
|
645 |
else: |
|
646 |
return None |
|
647 |
if compressed: |
|
|
5590.1.6
by John Arbash Meinel
Found another tuned_gzip use in weaverepo |
648 |
text = gzip.GzipFile(mode='rb', fileobj=StringIO(text)).read() |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
649 |
return text |
650 |
||
651 |
def _map(self, key): |
|
652 |
return self._mapper.map(key) + self._ext |
|
653 |
||
654 |
||
655 |
class RevisionTextStore(TextVersionedFiles): |
|
656 |
"""Legacy thunk for format 4 repositories.""" |
|
657 |
||
658 |
def __init__(self, transport, serializer, compressed, mapper, is_locked, |
|
659 |
can_write): |
|
660 |
"""Create a RevisionTextStore at transport with serializer.""" |
|
661 |
TextVersionedFiles.__init__(self, transport, compressed, mapper, |
|
662 |
is_locked, can_write) |
|
663 |
self._serializer = serializer |
|
664 |
||
665 |
def _load_text_parents(self, key): |
|
666 |
text = self._load_text(key) |
|
667 |
if text is None: |
|
668 |
return None, None |
|
669 |
parents = self._serializer.read_revision_from_string(text).parent_ids |
|
670 |
return text, tuple((parent,) for parent in parents) |
|
671 |
||
672 |
def get_parent_map(self, keys): |
|
673 |
result = {} |
|
674 |
for key in keys: |
|
675 |
parents = self._load_text_parents(key)[1] |
|
676 |
if parents is None: |
|
677 |
continue
|
|
678 |
result[key] = parents |
|
679 |
return result |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
680 |
|
|
4593.5.34
by John Arbash Meinel
Change the KnownGraph.merge_sort api. |
681 |
def get_known_graph_ancestry(self, keys): |
682 |
"""Get a KnownGraph instance with the ancestry of keys.""" |
|
683 |
keys = self.keys() |
|
684 |
parent_map = self.get_parent_map(keys) |
|
685 |
kg = _mod_graph.KnownGraph(parent_map) |
|
686 |
return kg |
|
687 |
||
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
688 |
def get_record_stream(self, keys, sort_order, include_delta_closure): |
689 |
for key in keys: |
|
690 |
text, parents = self._load_text_parents(key) |
|
691 |
if text is None: |
|
692 |
yield AbsentContentFactory(key) |
|
693 |
else: |
|
694 |
yield FulltextContentFactory(key, parents, None, text) |
|
695 |
||
696 |
def keys(self): |
|
697 |
if not self._is_locked(): |
|
698 |
raise errors.ObjectNotLocked(self) |
|
699 |
relpaths = set() |
|
700 |
for quoted_relpath in self._transport.iter_files_recursive(): |
|
701 |
relpath = urllib.unquote(quoted_relpath) |
|
702 |
path, ext = os.path.splitext(relpath) |
|
703 |
if ext == '.gz': |
|
704 |
relpath = path |
|
|
4695.2.1
by Vincent Ladeuil
Align RevisionTextStore and SignatureTextStore keys() definitions. |
705 |
if not relpath.endswith('.sig'): |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
706 |
relpaths.add(relpath) |
707 |
paths = list(relpaths) |
|
708 |
return set([self._mapper.unmap(path) for path in paths]) |
|
709 |
||
710 |
||
711 |
class SignatureTextStore(TextVersionedFiles): |
|
712 |
"""Legacy thunk for format 4-7 repositories.""" |
|
713 |
||
714 |
def __init__(self, transport, compressed, mapper, is_locked, can_write): |
|
715 |
TextVersionedFiles.__init__(self, transport, compressed, mapper, |
|
716 |
is_locked, can_write) |
|
717 |
self._ext = '.sig' + self._ext |
|
718 |
||
719 |
def get_parent_map(self, keys): |
|
720 |
result = {} |
|
721 |
for key in keys: |
|
722 |
text = self._load_text(key) |
|
723 |
if text is None: |
|
724 |
continue
|
|
725 |
result[key] = None |
|
726 |
return result |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
727 |
|
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
728 |
def get_record_stream(self, keys, sort_order, include_delta_closure): |
729 |
for key in keys: |
|
730 |
text = self._load_text(key) |
|
731 |
if text is None: |
|
732 |
yield AbsentContentFactory(key) |
|
733 |
else: |
|
734 |
yield FulltextContentFactory(key, None, None, text) |
|
735 |
||
736 |
def keys(self): |
|
737 |
if not self._is_locked(): |
|
738 |
raise errors.ObjectNotLocked(self) |
|
739 |
relpaths = set() |
|
740 |
for quoted_relpath in self._transport.iter_files_recursive(): |
|
741 |
relpath = urllib.unquote(quoted_relpath) |
|
742 |
path, ext = os.path.splitext(relpath) |
|
743 |
if ext == '.gz': |
|
744 |
relpath = path |
|
745 |
if not relpath.endswith('.sig'): |
|
746 |
continue
|
|
747 |
relpaths.add(relpath[:-4]) |
|
748 |
paths = list(relpaths) |
|
749 |
return set([self._mapper.unmap(path) for path in paths]) |
|
|
2803.2.1
by Robert Collins
* CommitBuilder now advertises itself as requiring the root entry to be |
750 |
|
|
5537.2.1
by Jelmer Vernooij
Move InterWeaveRepo and InterKnitRepo to related repository files. |
751 |
|
752 |
class InterWeaveRepo(InterSameDataRepository): |
|
753 |
"""Optimised code paths between Weave based repositories. |
|
754 |
"""
|
|
755 |
||
756 |
@classmethod
|
|
757 |
def _get_repo_format_to_test(self): |
|
758 |
return RepositoryFormat7() |
|
759 |
||
760 |
@staticmethod
|
|
761 |
def is_compatible(source, target): |
|
762 |
"""Be compatible with known Weave formats. |
|
763 |
||
764 |
We don't test for the stores being of specific types because that
|
|
765 |
could lead to confusing results, and there is no need to be
|
|
766 |
overly general.
|
|
767 |
"""
|
|
768 |
try: |
|
769 |
return (isinstance(source._format, (RepositoryFormat5, |
|
770 |
RepositoryFormat6, |
|
771 |
RepositoryFormat7)) and |
|
772 |
isinstance(target._format, (RepositoryFormat5, |
|
773 |
RepositoryFormat6, |
|
774 |
RepositoryFormat7))) |
|
775 |
except AttributeError: |
|
776 |
return False |
|
777 |
||
778 |
@needs_write_lock
|
|
779 |
def copy_content(self, revision_id=None): |
|
780 |
"""See InterRepository.copy_content().""" |
|
781 |
# weave specific optimised path:
|
|
782 |
try: |
|
783 |
self.target.set_make_working_trees(self.source.make_working_trees()) |
|
784 |
except (errors.RepositoryUpgradeRequired, NotImplemented): |
|
785 |
pass
|
|
786 |
# FIXME do not peek!
|
|
787 |
if self.source._transport.listable(): |
|
788 |
pb = ui.ui_factory.nested_progress_bar() |
|
789 |
try: |
|
790 |
self.target.texts.insert_record_stream( |
|
791 |
self.source.texts.get_record_stream( |
|
792 |
self.source.texts.keys(), 'topological', False)) |
|
793 |
pb.update('Copying inventory', 0, 1) |
|
794 |
self.target.inventories.insert_record_stream( |
|
795 |
self.source.inventories.get_record_stream( |
|
796 |
self.source.inventories.keys(), 'topological', False)) |
|
797 |
self.target.signatures.insert_record_stream( |
|
798 |
self.source.signatures.get_record_stream( |
|
799 |
self.source.signatures.keys(), |
|
800 |
'unordered', True)) |
|
801 |
self.target.revisions.insert_record_stream( |
|
802 |
self.source.revisions.get_record_stream( |
|
803 |
self.source.revisions.keys(), |
|
804 |
'topological', True)) |
|
805 |
finally: |
|
806 |
pb.finished() |
|
807 |
else: |
|
808 |
self.target.fetch(self.source, revision_id=revision_id) |
|
809 |
||
810 |
@needs_read_lock
|
|
|
5539.2.10
by Andrew Bennetts
s/NotInOtherForRev/NotInOtherForRevs/, and allow passing multiple revision_ids to search_missing_revision_ids. |
811 |
def search_missing_revision_ids(self, |
812 |
revision_id=symbol_versioning.DEPRECATED_PARAMETER, |
|
|
5535.3.32
by Andrew Bennetts
Implement if_present_ids behaviour in all implementations and code paths of searching_missing_revision_ids |
813 |
find_ghosts=True, revision_ids=None, if_present_ids=None): |
|
5539.2.10
by Andrew Bennetts
s/NotInOtherForRev/NotInOtherForRevs/, and allow passing multiple revision_ids to search_missing_revision_ids. |
814 |
"""See InterRepository.search_missing_revision_ids().""" |
|
5537.2.1
by Jelmer Vernooij
Move InterWeaveRepo and InterKnitRepo to related repository files. |
815 |
# we want all revisions to satisfy revision_id in source.
|
816 |
# but we don't want to stat every file here and there.
|
|
817 |
# we want then, all revisions other needs to satisfy revision_id
|
|
818 |
# checked, but not those that we have locally.
|
|
819 |
# so the first thing is to get a subset of the revisions to
|
|
820 |
# satisfy revision_id in source, and then eliminate those that
|
|
821 |
# we do already have.
|
|
822 |
# this is slow on high latency connection to self, but as this
|
|
823 |
# disk format scales terribly for push anyway due to rewriting
|
|
824 |
# inventory.weave, this is considered acceptable.
|
|
825 |
# - RBC 20060209
|
|
|
5539.2.10
by Andrew Bennetts
s/NotInOtherForRev/NotInOtherForRevs/, and allow passing multiple revision_ids to search_missing_revision_ids. |
826 |
if symbol_versioning.deprecated_passed(revision_id): |
827 |
symbol_versioning.warn( |
|
828 |
'search_missing_revision_ids(revision_id=...) was '
|
|
|
5536.3.3
by Andrew Bennetts
Merge lp:bzr. |
829 |
'deprecated in 2.4. Use revision_ids=[...] instead.', |
|
5539.2.10
by Andrew Bennetts
s/NotInOtherForRev/NotInOtherForRevs/, and allow passing multiple revision_ids to search_missing_revision_ids. |
830 |
DeprecationWarning, stacklevel=2) |
831 |
if revision_ids is not None: |
|
832 |
raise AssertionError( |
|
833 |
'revision_ids is mutually exclusive with revision_id') |
|
834 |
if revision_id is not None: |
|
835 |
revision_ids = [revision_id] |
|
836 |
del revision_id |
|
|
5535.3.32
by Andrew Bennetts
Implement if_present_ids behaviour in all implementations and code paths of searching_missing_revision_ids |
837 |
source_ids_set = self._present_source_revisions_for( |
838 |
revision_ids, if_present_ids) |
|
|
5537.2.1
by Jelmer Vernooij
Move InterWeaveRepo and InterKnitRepo to related repository files. |
839 |
# source_ids is the worst possible case we may need to pull.
|
840 |
# now we want to filter source_ids against what we actually
|
|
841 |
# have in target, but don't try to check for existence where we know
|
|
842 |
# we do not have a revision as that would be pointless.
|
|
843 |
target_ids = set(self.target._all_possible_ids()) |
|
844 |
possibly_present_revisions = target_ids.intersection(source_ids_set) |
|
845 |
actually_present_revisions = set( |
|
846 |
self.target._eliminate_revisions_not_present(possibly_present_revisions)) |
|
847 |
required_revisions = source_ids_set.difference(actually_present_revisions) |
|
|
5539.2.10
by Andrew Bennetts
s/NotInOtherForRev/NotInOtherForRevs/, and allow passing multiple revision_ids to search_missing_revision_ids. |
848 |
if revision_ids is not None: |
|
5537.2.1
by Jelmer Vernooij
Move InterWeaveRepo and InterKnitRepo to related repository files. |
849 |
# we used get_ancestry to determine source_ids then we are assured all
|
850 |
# revisions referenced are present as they are installed in topological order.
|
|
851 |
# and the tip revision was validated by get_ancestry.
|
|
852 |
result_set = required_revisions |
|
853 |
else: |
|
854 |
# if we just grabbed the possibly available ids, then
|
|
855 |
# we only have an estimate of whats available and need to validate
|
|
856 |
# that against the revision records.
|
|
857 |
result_set = set( |
|
858 |
self.source._eliminate_revisions_not_present(required_revisions)) |
|
859 |
return self.source.revision_ids_to_search_result(result_set) |
|
860 |
||
861 |
||
862 |
InterRepository.register_optimiser(InterWeaveRepo) |