292
292
raise NotImplementedError(self.annotate_iter)
294
def plan_file_merge(self, file_id, other):
294
def _get_plan_merge_data(self, file_id, other, base):
295
from bzrlib import merge, versionedfile
296
vf = versionedfile._PlanMergeVersionedFile(file_id)
297
last_revision_a = self._get_file_revision(file_id, vf, 'this:')
298
last_revision_b = other._get_file_revision(file_id, vf, 'other:')
300
last_revision_base = None
302
last_revision_base = base._get_file_revision(file_id, vf, 'base:')
303
return vf, last_revision_a, last_revision_b, last_revision_base
305
def plan_file_merge(self, file_id, other, base=None):
295
306
"""Generate a merge plan based on annotations.
297
308
If the file contains uncommitted changes in this tree, they will be
299
310
uncommitted changes in the other tree, they will be assigned to the
300
311
'other:' pseudo-revision.
302
from bzrlib import merge
303
annotated_a = list(self.annotate_iter(file_id,
304
_mod_revision.CURRENT_REVISION))
305
annotated_b = list(other.annotate_iter(file_id, 'other:'))
306
ancestors_a = self._get_ancestors(_mod_revision.CURRENT_REVISION)
307
ancestors_b = other._get_ancestors('other:')
308
return merge._plan_annotate_merge(annotated_a, annotated_b,
309
ancestors_a, ancestors_b)
313
data = self._get_plan_merge_data(file_id, other, base)
314
vf, last_revision_a, last_revision_b, last_revision_base = data
315
return vf.plan_merge(last_revision_a, last_revision_b,
318
def plan_file_lca_merge(self, file_id, other, base=None):
319
"""Generate a merge plan based lca-newness.
321
If the file contains uncommitted changes in this tree, they will be
322
attributed to the 'current:' pseudo-revision. If the file contains
323
uncommitted changes in the other tree, they will be assigned to the
324
'other:' pseudo-revision.
326
data = self._get_plan_merge_data(file_id, other, base)
327
vf, last_revision_a, last_revision_b, last_revision_base = data
328
return vf.plan_lca_merge(last_revision_a, last_revision_b,
331
def _get_file_revision(self, file_id, vf, tree_revision):
332
def file_revision(revision_tree):
333
revision_tree.lock_read()
335
return revision_tree.inventory[file_id].revision
337
revision_tree.unlock()
339
def iter_parent_trees():
340
for revision_id in self.get_parent_ids():
342
yield self.revision_tree(revision_id)
344
yield self.repository.revision_tree(revision_id)
346
if getattr(self, '_get_weave', None) is None:
347
last_revision = tree_revision
348
parent_revisions = [file_revision(t) for t in iter_parent_trees()]
349
vf.add_lines(last_revision, parent_revisions,
350
self.get_file(file_id).readlines())
351
repo = self.branch.repository
352
transaction = repo.get_transaction()
353
base_vf = repo.weave_store.get_weave(file_id, transaction)
355
last_revision = file_revision(self)
356
base_vf = self._get_weave(file_id)
357
vf.fallback_versionedfiles.append(base_vf)
311
360
inventory = property(_get_inventory,
312
361
doc="Inventory of this Tree")