373
373
return vf.plan_lca_merge(last_revision_a, last_revision_b,
374
374
last_revision_base)
376
def _iter_parent_trees(self):
377
"""Iterate through parent trees, defaulting to Tree.revision_tree."""
378
for revision_id in self.get_parent_ids():
380
yield self.revision_tree(revision_id)
381
except errors.NoSuchRevisionInTree:
382
yield self.repository.revision_tree(revision_id)
385
def _file_revision(revision_tree, file_id):
386
"""Determine the revision associated with a file in a given tree."""
387
revision_tree.lock_read()
389
return revision_tree.inventory[file_id].revision
391
revision_tree.unlock()
376
393
def _get_file_revision(self, file_id, vf, tree_revision):
377
394
"""Ensure that file_id, tree_revision is in vf to plan the merge."""
378
def file_revision(revision_tree):
379
revision_tree.lock_read()
381
return revision_tree.inventory[file_id].revision
383
revision_tree.unlock()
385
def iter_parent_trees():
386
for revision_id in self.get_parent_ids():
388
yield self.revision_tree(revision_id)
390
yield self.repository.revision_tree(revision_id)
392
396
if getattr(self, '_repository', None) is None:
393
397
last_revision = tree_revision
394
parent_keys = [(file_id, file_revision(t)) for t in
398
parent_keys = [(file_id, self._file_revision(t, file_id)) for t in
399
self._iter_parent_trees()]
396
400
vf.add_lines((file_id, last_revision), parent_keys,
397
401
self.get_file(file_id).readlines())
398
402
repo = self.branch.repository
399
403
base_vf = repo.texts
401
last_revision = file_revision(self)
405
last_revision = self._file_revision(self, file_id)
402
406
base_vf = self._repository.texts
403
407
if base_vf not in vf.fallback_versionedfiles:
404
408
vf.fallback_versionedfiles.append(base_vf)