83
83
count_copied -- number of revisions copied
85
count_texts -- number of file texts copied
85
count_weaves -- number of file weaves copied
87
87
def __init__(self, to_branch, from_branch, last_revision=None, pb=None):
88
88
if to_branch == from_branch:
191
192
self._copy_inventory(rev_id, inv_xml, parents)
192
193
self._copy_ancestry(rev_id, parents)
193
194
self.to_branch.revision_store.add(StringIO(rev_xml), rev_id)
195
mutter('copied revision %s', rev_id)
196
198
def _copy_inventory(self, rev_id, inv_xml, parent_ids):
210
212
# in memory until everything's done? But this way is nicer
211
213
# if it's interrupted.
212
214
for path, ie in inv.iter_entries():
213
if not ie.has_text():
215
215
if ie.revision != rev_id:
217
217
mutter('%s {%s} is changed in this revision',
218
218
path, ie.file_id)
219
self._copy_one_text(rev_id, ie.file_id)
222
def _copy_one_text(self, rev_id, file_id):
223
"""Copy one file text."""
224
mutter('copy text version {%s} of file {%s}',
219
self._copy_one_weave(rev_id, ie.file_id)
222
def _copy_one_weave(self, rev_id, file_id):
223
"""Copy one file weave."""
224
mutter('copy file {%s} modified in {%s}', file_id, rev_id)
225
if file_id in self.copied_file_ids:
226
mutter('file {%s} already copied', file_id)
226
228
from_weave = self.from_weaves.get_weave(file_id)
227
from_idx = from_weave.lookup(rev_id)
228
from_parents = map(from_weave.idx_to_name, from_weave.parents(from_idx))
229
text_lines = from_weave.get(from_idx)
230
229
to_weave = self.to_weaves.get_weave_or_empty(file_id)
231
to_parents = map(to_weave.lookup, from_parents)
232
# it's ok to add even if the text is already there
233
to_weave.add(rev_id, to_parents, text_lines)
230
to_weave.join(from_weave)
234
231
self.to_weaves.put_weave(file_id, to_weave)
235
self.count_texts += 1
232
self.count_weaves += 1
233
self.copied_file_ids.add(file_id)
234
mutter('copied file {%s}', file_id)