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