56
56
weave = transaction.map.find_weave(file_id)
58
58
mutter("old data in transaction in %s for %s", self, file_id)
59
# FIXME abstraction violation.
60
transaction.map.remove_object('weave-' + file-id)
59
# FIXME abstraction violation - transaction now has stale data.
60
transaction.map.remove_object(weave)
62
62
def filename(self, file_id):
63
63
"""Return the path relative to the transport root."""
102
102
def get_weave(self, file_id, transaction):
103
103
weave = transaction.map.find_weave(file_id)
104
if weave is not None:
105
105
mutter("cache hit in %s for %s", self, file_id)
107
107
w = self._versionedfile_class(self.filename(file_id), self._transport, self._file_mode)
120
120
def _new_weave(self, file_id, transaction):
121
121
"""Make a new weave for file_id and return it."""
122
weave = self._make_new_versionedfile(file_id)
122
weave = self._make_new_versionedfile(file_id, transaction)
123
123
transaction.map.add_weave(file_id, weave)
124
124
transaction.register_clean(weave, precious=self._precious)
127
def _make_new_versionedfile(self, file_id):
127
def _make_new_versionedfile(self, file_id, transaction):
128
if self.has_id(file_id):
129
self.delete(file_id, transaction)
129
131
weave = self._versionedfile_class(self.filename(file_id), self._transport, self._file_mode, create=True)
130
132
except NoSuchFile:
158
160
def _put_weave(self, file_id, weave, transaction):
159
161
"""Preserved here for upgrades-to-weaves to use."""
160
myweave = self._make_new_versionedfile(file_id)
162
myweave = self._make_new_versionedfile(file_id, transaction)
161
163
myweave.join(weave)
163
165
@deprecated_method(zero_eight)
186
188
self._clear_cache_id(result_id, transaction)
187
189
source.copy_to(self.filename(result_id), self._transport)
189
def copy_all_ids(self, store_from, pb=None, from_transaction=None):
191
def copy_all_ids(self, store_from, pb=None, from_transaction=None,
192
to_transaction=None):
190
193
"""Copy all the file ids from store_from into self."""
191
194
if from_transaction is None:
192
warn("Please pase from_transaction into "
195
warn("Please pass from_transaction into "
196
"versioned_store.copy_all_ids.", stacklevel=2)
197
if to_transaction is None:
198
warn("Please pass to_transaction into "
193
199
"versioned_store.copy_all_ids.", stacklevel=2)
194
200
if not store_from.listable():
195
201
raise UnlistableStore(store_from)
203
209
mutter('copy_all ids: %r', ids)
204
210
self.copy_multi(store_from, ids, pb=pb,
205
from_transaction=from_transaction)
211
from_transaction=from_transaction,
212
to_transaction=to_transaction)
207
def copy_multi(self, from_store, file_ids, pb=None, from_transaction=None):
214
def copy_multi(self, from_store, file_ids, pb=None, from_transaction=None,
215
to_transaction=None):
208
216
"""Copy all the versions for multiple file_ids from from_store.
210
218
:param from_transaction: required current transaction in from_store.
220
from bzrlib.transactions import PassThroughTransaction
212
221
assert isinstance(from_store, WeaveStore)
213
222
if from_transaction is None:
214
223
warn("WeaveStore.copy_multi without a from_transaction parameter "
215
224
"is deprecated. Please provide a from_transaction.",
216
225
DeprecationWarning,
227
# we are reading one object - caching is irrelevant.
228
from_transaction = PassThroughTransaction()
229
if to_transaction is None:
230
warn("WeaveStore.copy_multi without a to_transaction parameter "
231
"is deprecated. Please provide a to_transaction.",
234
# we are copying single objects, and there may be open tranasactions
235
# so again with the passthrough
236
to_transaction = PassThroughTransaction()
218
237
for count, f in enumerate(file_ids):
219
238
mutter("copy weave {%s} into %s", f, self)
221
240
pb.update('copy', count, len(file_ids))
222
241
# if we have it in cache, its faster.
223
if not from_transaction:
224
from bzrlib.transactions import PassThroughTransaction
225
from_transaction = PassThroughTransaction()
226
242
# joining is fast with knits, and bearable for weaves -
227
# indeed the new case can be optimised
228
target = self._make_new_versionedfile(f)
243
# indeed the new case can be optimised if needed.
244
target = self._make_new_versionedfile(f, to_transaction)
229
245
target.join(from_store.get_weave(f, from_transaction))