374
374
return vf.plan_lca_merge(last_revision_a, last_revision_b,
375
375
last_revision_base)
377
def _iter_parent_trees(self):
378
"""Iterate through parent trees, defaulting to Tree.revision_tree."""
379
for revision_id in self.get_parent_ids():
381
yield self.revision_tree(revision_id)
382
except errors.NoSuchRevisionInTree:
383
yield self.repository.revision_tree(revision_id)
386
def _file_revision(revision_tree, file_id):
387
"""Determine the revision associated with a file in a given tree."""
388
revision_tree.lock_read()
390
return revision_tree.inventory[file_id].revision
392
revision_tree.unlock()
377
394
def _get_file_revision(self, file_id, vf, tree_revision):
378
395
"""Ensure that file_id, tree_revision is in vf to plan the merge."""
379
def file_revision(revision_tree):
380
revision_tree.lock_read()
382
return revision_tree.inventory[file_id].revision
384
revision_tree.unlock()
386
def iter_parent_trees():
387
for revision_id in self.get_parent_ids():
389
yield self.revision_tree(revision_id)
391
yield self.repository.revision_tree(revision_id)
393
397
if getattr(self, '_repository', None) is None:
394
398
last_revision = tree_revision
395
parent_keys = [(file_id, file_revision(t)) for t in
399
parent_keys = [(file_id, self._file_revision(t, file_id)) for t in
400
self._iter_parent_trees()]
397
401
vf.add_lines((file_id, last_revision), parent_keys,
398
402
self.get_file(file_id).readlines())
399
403
repo = self.branch.repository
400
404
base_vf = repo.texts
402
last_revision = file_revision(self)
406
last_revision = self._file_revision(self, file_id)
403
407
base_vf = self._repository.texts
404
408
if base_vf not in vf.fallback_versionedfiles:
405
409
vf.fallback_versionedfiles.append(base_vf)
553
557
def _get_rules_searcher(self, default_searcher):
554
558
"""Get the RulesSearcher for this tree given the default one."""
555
559
searcher = default_searcher
556
file_id = self.path2id(rules.RULES_TREE_FILENAME)
557
if file_id is not None:
558
ini_file = self.get_file(file_id)
559
searcher = rules._StackedRulesSearcher(
560
[rules._IniBasedRulesSearcher(ini_file), default_searcher])
949
948
self.source._comparison_data(from_entry, path)
950
949
kind = (from_kind, None)
951
950
executable = (from_executable, None)
952
changed_content = True
951
changed_content = from_kind is not None
953
952
# the parent's path is necessarily known at this point.
954
953
yield(file_id, (path, to_path), changed_content, versioned, parent,
955
954
name, kind, executable)
971
970
that they yield (path, object) tuples, where that object will have a
972
971
'.file_id' member, that can be used to check equality.
974
:param master_tree: All trees will be 'slaved' to the master_tree. Such
973
:param master_tree: All trees will be 'slaved' to the master_tree such
975
974
that nodes in master_tree will be used as 'first-pass' sync points.
976
975
Any nodes that aren't in master_tree will be merged in a second
1025
1024
if not isinstance(path2, unicode):
1026
1025
raise TypeError("'path2' must be a unicode string, not %s: %r"
1027
1026
% (type(path2), path2))
1028
return cmp(MultiWalker._path_key(path1), MultiWalker._path_key(path2))
1027
return cmp(MultiWalker._path_to_key(path1),
1028
MultiWalker._path_to_key(path2))
1031
def _path_key(other):
1033
dirname, basename = os.path.split(path)
1031
def _path_to_key(path):
1032
dirname, basename = osutils.split(path)
1034
1033
return (dirname.split(u'/'), basename)
1036
1035
def _lookup_by_file_id(self, extra_entries, other_tree, file_id):
1169
1168
# might ensure better ordering, in case a caller strictly
1170
1169
# requires parents before children.
1171
1170
for idx, other_extra in enumerate(self._others_extra):
1172
others = sorted(other_extra.itervalues(), key=self._path_key)
1171
others = sorted(other_extra.itervalues(),
1172
key=lambda x: self._path_to_key(x[0]))
1173
1173
for other_path, other_ie in others:
1174
1174
file_id = other_ie.file_id
1175
1175
# We don't need to check out_of_order_processed here, because