189
190
if not self.to_branch.has_revision(parent):
190
191
parents.pop(parents.index(parent))
191
192
self._copy_inventory(rev_id, inv_xml, parents)
192
self._copy_ancestry(rev_id, parents)
193
193
self.to_branch.revision_store.add(StringIO(rev_xml), rev_id)
194
mutter('copied revision %s', rev_id)
196
197
def _copy_inventory(self, rev_id, inv_xml, parent_ids):
197
198
self.to_control.add_text('inventory', rev_id,
198
199
split_lines(inv_xml), parent_ids)
201
def _copy_ancestry(self, rev_id, parent_ids):
202
ancestry_lines = self.from_control.get_lines('ancestry', rev_id)
203
self.to_control.add_text('ancestry', rev_id, ancestry_lines,
207
201
def _copy_new_texts(self, rev_id, inv):
208
202
"""Copy any new texts occuring in this revision."""
209
203
# TODO: Rather than writing out weaves every time, hold them
210
204
# in memory until everything's done? But this way is nicer
211
205
# if it's interrupted.
212
206
for path, ie in inv.iter_entries():
213
if ie.kind != 'file':
215
207
if ie.revision != rev_id:
217
209
mutter('%s {%s} is changed in this revision',
218
210
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}',
211
self._copy_one_weave(rev_id, ie.file_id)
214
def _copy_one_weave(self, rev_id, file_id):
215
"""Copy one file weave."""
216
mutter('copy file {%s} modified in {%s}', file_id, rev_id)
217
if file_id in self.copied_file_ids:
218
mutter('file {%s} already copied', file_id)
226
220
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
221
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)
222
to_weave.join(from_weave)
234
223
self.to_weaves.put_weave(file_id, to_weave)
235
self.count_texts += 1
224
self.count_weaves += 1
225
self.copied_file_ids.add(file_id)
226
mutter('copied file {%s}', file_id)