/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Andrew Bennetts
  • Date: 2008-10-27 06:14:45 UTC
  • mfrom: (3793 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3795.
  • Revision ID: andrew.bennetts@canonical.com-20081027061445-eqt9lz6uw1mbvq4g
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    patiencediff,
29
29
    registry,
30
30
    revision as _mod_revision,
 
31
    tree as _mod_tree,
31
32
    tsort,
32
33
    )
33
34
from bzrlib.branch import Branch
54
55
from bzrlib.trace import mutter, warning, note, is_quiet
55
56
from bzrlib.transform import (TransformPreview, TreeTransform,
56
57
                              resolve_conflicts, cook_conflicts,
57
 
                              conflict_pass, FinalPaths, create_by_entry,
 
58
                              conflict_pass, FinalPaths, create_from_tree,
58
59
                              unique_add, ROOT_PARENT)
59
60
from bzrlib.versionedfile import PlanWeaveMerge
60
61
from bzrlib import ui
96
97
        self._revision_graph = revision_graph
97
98
        self._base_is_ancestor = None
98
99
        self._base_is_other_ancestor = None
 
100
        self._is_criss_cross = None
 
101
        self._lca_trees = None
99
102
 
100
103
    @property
101
104
    def revision_graph(self):
129
132
                                      _set_base_is_other_ancestor)
130
133
 
131
134
    @staticmethod
132
 
    def from_uncommitted(tree, other_tree, pb):
 
135
    def from_uncommitted(tree, other_tree, pb, base_tree=None):
133
136
        """Return a Merger for uncommitted changes in other_tree.
134
137
 
135
138
        :param tree: The tree to merge into
136
139
        :param other_tree: The tree to get uncommitted changes from
137
140
        :param pb: A progress indicator
 
141
        :param base_tree: The basis to use for the merge.  If unspecified,
 
142
            other_tree.basis_tree() will be used.
138
143
        """
139
 
        merger = Merger(tree.branch, other_tree, other_tree.basis_tree(), tree,
140
 
                        pb)
 
144
        if base_tree is None:
 
145
            base_tree = other_tree.basis_tree()
 
146
        merger = Merger(tree.branch, other_tree, base_tree, tree, pb)
141
147
        merger.base_rev_id = merger.base_tree.get_revision_id()
142
148
        merger.other_rev_id = None
143
149
        merger.other_basis = merger.base_rev_id
169
175
 
170
176
    @staticmethod
171
177
    def from_revision_ids(pb, tree, other, base=None, other_branch=None,
172
 
                          base_branch=None, revision_graph=None):
 
178
                          base_branch=None, revision_graph=None,
 
179
                          tree_branch=None):
173
180
        """Return a Merger for revision-ids.
174
181
 
 
182
        :param pb: A progress indicator
175
183
        :param tree: The tree to merge changes into
176
184
        :param other: The revision-id to use as OTHER
177
185
        :param base: The revision-id to use as BASE.  If not specified, will
182
190
            not supplied, other_branch or tree.branch will be used.
183
191
        :param revision_graph: If you have a revision_graph precomputed, pass
184
192
            it in, otherwise it will be created for you.
185
 
        :param pb: A progress indicator
 
193
        :param tree_branch: The branch associated with tree.  If not supplied,
 
194
            tree.branch will be used.
186
195
        """
187
 
        merger = Merger(tree.branch, this_tree=tree, pb=pb,
 
196
        if tree_branch is None:
 
197
            tree_branch = tree.branch
 
198
        merger = Merger(tree_branch, this_tree=tree, pb=pb,
188
199
                        revision_graph=revision_graph)
189
200
        if other_branch is None:
190
201
            other_branch = tree.branch
353
364
                     ensure_null(self.other_basis)]
354
365
        if NULL_REVISION in revisions:
355
366
            self.base_rev_id = NULL_REVISION
 
367
            self.base_tree = self.revision_tree(self.base_rev_id)
 
368
            self._is_criss_cross = False
356
369
        else:
357
 
            self.base_rev_id, steps = self.revision_graph.find_unique_lca(
358
 
                revisions[0], revisions[1], count_steps=True)
 
370
            lcas = self.revision_graph.find_lca(revisions[0], revisions[1])
 
371
            self._is_criss_cross = False
 
372
            if len(lcas) == 0:
 
373
                self.base_rev_id = NULL_REVISION
 
374
            elif len(lcas) == 1:
 
375
                self.base_rev_id = list(lcas)[0]
 
376
            else: # len(lcas) > 1
 
377
                if len(lcas) > 2:
 
378
                    # find_unique_lca can only handle 2 nodes, so we have to
 
379
                    # start back at the beginning. It is a shame to traverse
 
380
                    # the graph again, but better than re-implementing
 
381
                    # find_unique_lca.
 
382
                    self.base_rev_id = self.revision_graph.find_unique_lca(
 
383
                                            revisions[0], revisions[1])
 
384
                else:
 
385
                    self.base_rev_id = self.revision_graph.find_unique_lca(
 
386
                                            *lcas)
 
387
                self._is_criss_cross = True
359
388
            if self.base_rev_id == NULL_REVISION:
360
389
                raise UnrelatedBranches()
361
 
            if steps > 1:
 
390
            if self._is_criss_cross:
362
391
                warning('Warning: criss-cross merge encountered.  See bzr'
363
392
                        ' help criss-cross.')
364
 
        self.base_tree = self.revision_tree(self.base_rev_id)
 
393
                interesting_revision_ids = [self.base_rev_id]
 
394
                interesting_revision_ids.extend(lcas)
 
395
                interesting_trees = dict((t.get_revision_id(), t)
 
396
                    for t in self.this_branch.repository.revision_trees(
 
397
                        interesting_revision_ids))
 
398
                self._cached_trees.update(interesting_trees)
 
399
                self.base_tree = interesting_trees.pop(self.base_rev_id)
 
400
                sorted_lca_keys = self.revision_graph.find_merge_order(
 
401
                    revisions[0], lcas)
 
402
                self._lca_trees = [interesting_trees[key]
 
403
                                   for key in sorted_lca_keys]
 
404
            else:
 
405
                self.base_tree = self.revision_tree(self.base_rev_id)
365
406
        self.base_is_ancestor = True
366
407
        self.base_is_other_ancestor = True
367
408
 
409
450
        if self.merge_type.supports_cherrypick:
410
451
            kwargs['cherrypick'] = (not self.base_is_ancestor or
411
452
                                    not self.base_is_other_ancestor)
 
453
        if self._is_criss_cross and getattr(self.merge_type,
 
454
                                            'supports_lca_trees', False):
 
455
            kwargs['lca_trees'] = self._lca_trees
412
456
        return self.merge_type(pb=self._pb,
413
457
                               change_reporter=self.change_reporter,
414
458
                               **kwargs)
460
504
        return len(merge.cooked_conflicts)
461
505
 
462
506
 
 
507
class _InventoryNoneEntry(object):
 
508
    """This represents an inventory entry which *isn't there*.
 
509
 
 
510
    It simplifies the merging logic if we always have an InventoryEntry, even
 
511
    if it isn't actually present
 
512
    """
 
513
    executable = None
 
514
    kind = None
 
515
    name = None
 
516
    parent_id = None
 
517
    revision = None
 
518
    symlink_target = None
 
519
    text_sha1 = None
 
520
 
 
521
_none_entry = _InventoryNoneEntry()
 
522
 
 
523
 
463
524
class Merge3Merger(object):
464
525
    """Three-way merger that uses the merge3 text merger"""
465
526
    requires_base = True
469
530
    supports_cherrypick = True
470
531
    supports_reverse_cherrypick = True
471
532
    winner_idx = {"this": 2, "other": 1, "conflict": 1}
 
533
    supports_lca_trees = True
472
534
 
473
535
    def __init__(self, working_tree, this_tree, base_tree, other_tree, 
474
536
                 interesting_ids=None, reprocess=False, show_base=False,
475
537
                 pb=DummyProgress(), pp=None, change_reporter=None,
476
538
                 interesting_files=None, do_merge=True,
477
 
                 cherrypick=False):
 
539
                 cherrypick=False, lca_trees=None):
478
540
        """Initialize the merger object and perform the merge.
479
541
 
480
542
        :param working_tree: The working tree to apply the merge to
496
558
            be combined with interesting_ids.  If neither interesting_files nor
497
559
            interesting_ids is specified, all files may participate in the
498
560
            merge.
 
561
        :param lca_trees: Can be set to a dictionary of {revision_id:rev_tree}
 
562
            if the ancestry was found to include a criss-cross merge.
 
563
            Otherwise should be None.
499
564
        """
500
565
        object.__init__(self)
501
566
        if interesting_files is not None and interesting_ids is not None:
510
575
        self.cooked_conflicts = []
511
576
        self.reprocess = reprocess
512
577
        self.show_base = show_base
 
578
        self._lca_trees = lca_trees
 
579
        # Uncommenting this will change the default algorithm to always use
 
580
        # _entries_lca. This can be useful for running the test suite and
 
581
        # making sure we haven't missed any corner cases.
 
582
        # if lca_trees is None:
 
583
        #     self._lca_trees = [self.base_tree]
513
584
        self.pb = pb
514
585
        self.pp = pp
515
586
        self.change_reporter = change_reporter
556
627
        return self.tt
557
628
 
558
629
    def _compute_transform(self):
559
 
        entries = self._entries3()
 
630
        if self._lca_trees is None:
 
631
            entries = self._entries3()
 
632
            resolver = self._three_way
 
633
        else:
 
634
            entries = self._entries_lca()
 
635
            resolver = self._lca_multi_way
560
636
        child_pb = ui.ui_factory.nested_progress_bar()
561
637
        try:
562
638
            for num, (file_id, changed, parents3, names3,
563
639
                      executable3) in enumerate(entries):
564
640
                child_pb.update('Preparing file merge', num, len(entries))
565
 
                self._merge_names(file_id, parents3, names3)
 
641
                self._merge_names(file_id, parents3, names3, resolver=resolver)
566
642
                if changed:
567
643
                    file_status = self.merge_contents(file_id)
568
644
                else:
569
645
                    file_status = 'unmodified'
570
646
                self._merge_executable(file_id,
571
 
                    executable3, file_status)
 
647
                    executable3, file_status, resolver=resolver)
572
648
        finally:
573
649
            child_pb.finished()
574
650
        self.fix_root()
600
676
        iterator = self.other_tree.iter_changes(self.base_tree,
601
677
                include_unchanged=True, specific_files=self.interesting_files,
602
678
                extra_trees=[self.this_tree])
 
679
        this_entries = dict((e.file_id, e) for p, e in
 
680
                            self.this_tree.iter_entries_by_dir(
 
681
                            self.interesting_ids))
603
682
        for (file_id, paths, changed, versioned, parents, names, kind,
604
683
             executable) in iterator:
605
684
            if (self.interesting_ids is not None and
606
685
                file_id not in self.interesting_ids):
607
686
                continue
608
 
            if file_id in self.this_tree.inventory:
609
 
                entry = self.this_tree.inventory[file_id]
 
687
            entry = this_entries.get(file_id)
 
688
            if entry is not None:
610
689
                this_name = entry.name
611
690
                this_parent = entry.parent_id
612
691
                this_executable = entry.executable
620
699
            result.append((file_id, changed, parents3, names3, executable3))
621
700
        return result
622
701
 
 
702
    def _entries_lca(self):
 
703
        """Gather data about files modified between multiple trees.
 
704
 
 
705
        This compares OTHER versus all LCA trees, and for interesting entries,
 
706
        it then compares with THIS and BASE.
 
707
 
 
708
        For the multi-valued entries, the format will be (BASE, [lca1, lca2])
 
709
        :return: [(file_id, changed, parents, names, executable)]
 
710
            file_id     Simple file_id of the entry
 
711
            changed     Boolean, True if the kind or contents changed
 
712
                        else False
 
713
            parents     ((base, [parent_id, in, lcas]), parent_id_other,
 
714
                         parent_id_this)
 
715
            names       ((base, [name, in, lcas]), name_in_other, name_in_this)
 
716
            executable  ((base, [exec, in, lcas]), exec_in_other, exec_in_this)
 
717
        """
 
718
        if self.interesting_files is not None:
 
719
            lookup_trees = [self.this_tree, self.base_tree]
 
720
            lookup_trees.extend(self._lca_trees)
 
721
            # I think we should include the lca trees as well
 
722
            interesting_ids = self.other_tree.paths2ids(self.interesting_files,
 
723
                                                        lookup_trees)
 
724
        else:
 
725
            interesting_ids = self.interesting_ids
 
726
        result = []
 
727
        walker = _mod_tree.MultiWalker(self.other_tree, self._lca_trees)
 
728
 
 
729
        base_inventory = self.base_tree.inventory
 
730
        this_inventory = self.this_tree.inventory
 
731
        for path, file_id, other_ie, lca_values in walker.iter_all():
 
732
            # Is this modified at all from any of the other trees?
 
733
            if other_ie is None:
 
734
                other_ie = _none_entry
 
735
            if interesting_ids is not None and file_id not in interesting_ids:
 
736
                continue
 
737
 
 
738
            # If other_revision is found in any of the lcas, that means this
 
739
            # node is uninteresting. This is because when merging, if there are
 
740
            # multiple heads(), we have to create a new node. So if we didn't,
 
741
            # we know that the ancestry is linear, and that OTHER did not
 
742
            # modify anything
 
743
            # See doc/developers/lca_merge_resolution.txt for details
 
744
            other_revision = other_ie.revision
 
745
            if other_revision is not None:
 
746
                # We can't use this shortcut when other_revision is None,
 
747
                # because it may be None because things are WorkingTrees, and
 
748
                # not because it is *actually* None.
 
749
                is_unmodified = False
 
750
                for lca_path, ie in lca_values:
 
751
                    if ie is not None and ie.revision == other_revision:
 
752
                        is_unmodified = True
 
753
                        break
 
754
                if is_unmodified:
 
755
                    continue
 
756
 
 
757
            lca_entries = []
 
758
            for lca_path, lca_ie in lca_values:
 
759
                if lca_ie is None:
 
760
                    lca_entries.append(_none_entry)
 
761
                else:
 
762
                    lca_entries.append(lca_ie)
 
763
 
 
764
            if file_id in base_inventory:
 
765
                base_ie = base_inventory[file_id]
 
766
            else:
 
767
                base_ie = _none_entry
 
768
 
 
769
            if file_id in this_inventory:
 
770
                this_ie = this_inventory[file_id]
 
771
            else:
 
772
                this_ie = _none_entry
 
773
 
 
774
            lca_kinds = []
 
775
            lca_parent_ids = []
 
776
            lca_names = []
 
777
            lca_executable = []
 
778
            for lca_ie in lca_entries:
 
779
                lca_kinds.append(lca_ie.kind)
 
780
                lca_parent_ids.append(lca_ie.parent_id)
 
781
                lca_names.append(lca_ie.name)
 
782
                lca_executable.append(lca_ie.executable)
 
783
 
 
784
            kind_winner = self._lca_multi_way(
 
785
                (base_ie.kind, lca_kinds),
 
786
                other_ie.kind, this_ie.kind)
 
787
            parent_id_winner = self._lca_multi_way(
 
788
                (base_ie.parent_id, lca_parent_ids),
 
789
                other_ie.parent_id, this_ie.parent_id)
 
790
            name_winner = self._lca_multi_way(
 
791
                (base_ie.name, lca_names),
 
792
                other_ie.name, this_ie.name)
 
793
 
 
794
            content_changed = True
 
795
            if kind_winner == 'this':
 
796
                # No kind change in OTHER, see if there are *any* changes
 
797
                if other_ie.kind == None:
 
798
                    # No content and 'this' wins the kind, so skip this?
 
799
                    # continue
 
800
                    pass
 
801
                elif other_ie.kind == 'directory':
 
802
                    if parent_id_winner == 'this' and name_winner == 'this':
 
803
                        # No change for this directory in OTHER, skip
 
804
                        continue
 
805
                    content_changed = False
 
806
                elif other_ie.kind == 'file':
 
807
                    def get_sha1(ie, tree):
 
808
                        if ie.kind != 'file':
 
809
                            return None
 
810
                        return tree.get_file_sha1(file_id)
 
811
                    base_sha1 = get_sha1(base_ie, self.base_tree)
 
812
                    lca_sha1s = [get_sha1(ie, tree) for ie, tree
 
813
                                 in zip(lca_entries, self._lca_trees)]
 
814
                    this_sha1 = get_sha1(this_ie, self.this_tree)
 
815
                    other_sha1 = get_sha1(other_ie, self.other_tree)
 
816
                    sha1_winner = self._lca_multi_way(
 
817
                        (base_sha1, lca_sha1s), other_sha1, this_sha1,
 
818
                        allow_overriding_lca=False)
 
819
                    exec_winner = self._lca_multi_way(
 
820
                        (base_ie.executable, lca_executable),
 
821
                        other_ie.executable, this_ie.executable)
 
822
                    if (parent_id_winner == 'this' and name_winner == 'this'
 
823
                        and sha1_winner == 'this' and exec_winner == 'this'):
 
824
                        # No kind, parent, name, exec, or content change for
 
825
                        # OTHER, so this node is not considered interesting
 
826
                        continue
 
827
                    if sha1_winner == 'this':
 
828
                        content_changed = False
 
829
                elif other_ie.kind == 'symlink':
 
830
                    def get_target(ie, tree):
 
831
                        if ie.kind != 'symlink':
 
832
                            return None
 
833
                        return tree.get_symlink_target(file_id)
 
834
                    base_target = get_target(base_ie, self.base_tree)
 
835
                    lca_targets = [get_target(ie, tree) for ie, tree
 
836
                                   in zip(lca_entries, self._lca_trees)]
 
837
                    this_target = get_target(this_ie, self.this_tree)
 
838
                    other_target = get_target(other_ie, self.other_tree)
 
839
                    target_winner = self._lca_multi_way(
 
840
                        (base_target, lca_targets),
 
841
                        other_target, this_target)
 
842
                    if (parent_id_winner == 'this' and name_winner == 'this'
 
843
                        and target_winner == 'this'):
 
844
                        # No kind, parent, name, or symlink target change
 
845
                        # not interesting
 
846
                        continue
 
847
                    if target_winner == 'this':
 
848
                        content_changed = False
 
849
                elif other_ie.kind == 'tree-reference':
 
850
                    # The 'changed' information seems to be handled at a higher
 
851
                    # level. At least, _entries3 returns False for content
 
852
                    # changed, even when at a new revision_id.
 
853
                    content_changed = False
 
854
                    if (parent_id_winner == 'this' and name_winner == 'this'):
 
855
                        # Nothing interesting
 
856
                        continue
 
857
                else:
 
858
                    raise AssertionError('unhandled kind: %s' % other_ie.kind)
 
859
                # XXX: We need to handle kind == 'symlink'
 
860
 
 
861
            # If we have gotten this far, that means something has changed
 
862
            result.append((file_id, content_changed,
 
863
                           ((base_ie.parent_id, lca_parent_ids),
 
864
                            other_ie.parent_id, this_ie.parent_id),
 
865
                           ((base_ie.name, lca_names),
 
866
                            other_ie.name, this_ie.name),
 
867
                           ((base_ie.executable, lca_executable),
 
868
                            other_ie.executable, this_ie.executable)
 
869
                          ))
 
870
        return result
 
871
 
 
872
 
623
873
    def fix_root(self):
624
874
        try:
625
875
            self.tt.final_kind(self.tt.root)
628
878
        if self.tt.final_file_id(self.tt.root) is None:
629
879
            self.tt.version_file(self.tt.tree_file_id(self.tt.root), 
630
880
                                 self.tt.root)
631
 
        if self.other_tree.inventory.root is None:
632
 
            return
633
881
        other_root_file_id = self.other_tree.get_root_id()
 
882
        if other_root_file_id is None:
 
883
            return
634
884
        other_root = self.tt.trans_id_file_id(other_root_file_id)
635
885
        if other_root == self.tt.root:
636
886
            return
714
964
            return "other"
715
965
 
716
966
    @staticmethod
 
967
    def _lca_multi_way(bases, other, this, allow_overriding_lca=True):
 
968
        """Consider LCAs when determining whether a change has occurred.
 
969
 
 
970
        If LCAS are all identical, this is the same as a _three_way comparison.
 
971
 
 
972
        :param bases: value in (BASE, [LCAS])
 
973
        :param other: value in OTHER
 
974
        :param this: value in THIS
 
975
        :param allow_overriding_lca: If there is more than one unique lca
 
976
            value, allow OTHER to override THIS if it has a new value, and
 
977
            THIS only has an lca value, or vice versa. This is appropriate for
 
978
            truly scalar values, not as much for non-scalars.
 
979
        :return: 'this', 'other', or 'conflict' depending on whether an entry
 
980
            changed or not.
 
981
        """
 
982
        # See doc/developers/lca_merge_resolution.txt for details about this
 
983
        # algorithm.
 
984
        if other == this:
 
985
            # Either Ambiguously clean, or nothing was actually changed. We
 
986
            # don't really care
 
987
            return 'this'
 
988
        base_val, lca_vals = bases
 
989
        # Remove 'base_val' from the lca_vals, because it is not interesting
 
990
        filtered_lca_vals = [lca_val for lca_val in lca_vals
 
991
                                      if lca_val != base_val]
 
992
        if len(filtered_lca_vals) == 0:
 
993
            return Merge3Merger._three_way(base_val, other, this)
 
994
 
 
995
        unique_lca_vals = set(filtered_lca_vals)
 
996
        if len(unique_lca_vals) == 1:
 
997
            return Merge3Merger._three_way(unique_lca_vals.pop(), other, this)
 
998
 
 
999
        if allow_overriding_lca:
 
1000
            if other in unique_lca_vals:
 
1001
                if this in unique_lca_vals:
 
1002
                    # Each side picked a different lca, conflict
 
1003
                    return 'conflict'
 
1004
                else:
 
1005
                    # This has a value which supersedes both lca values, and
 
1006
                    # other only has an lca value
 
1007
                    return 'this'
 
1008
            elif this in unique_lca_vals:
 
1009
                # OTHER has a value which supersedes both lca values, and this
 
1010
                # only has an lca value
 
1011
                return 'other'
 
1012
 
 
1013
        # At this point, the lcas disagree, and the tips disagree
 
1014
        return 'conflict'
 
1015
 
 
1016
    @staticmethod
717
1017
    def scalar_three_way(this_tree, base_tree, other_tree, file_id, key):
718
1018
        """Do a three-way test on a scalar.
719
1019
        Return "this", "other" or "conflict", depending whether a value wins.
751
1051
            else:
752
1052
                names.append(entry.name)
753
1053
                parents.append(entry.parent_id)
754
 
        return self._merge_names(file_id, parents, names)
 
1054
        return self._merge_names(file_id, parents, names,
 
1055
                                 resolver=self._three_way)
755
1056
 
756
 
    def _merge_names(self, file_id, parents, names):
 
1057
    def _merge_names(self, file_id, parents, names, resolver):
757
1058
        """Perform a merge on file_id names and parents"""
758
1059
        base_name, other_name, this_name = names
759
1060
        base_parent, other_parent, this_parent = parents
760
1061
 
761
 
        name_winner = self._three_way(*names)
 
1062
        name_winner = resolver(*names)
762
1063
 
763
 
        parent_id_winner = self._three_way(*parents)
 
1064
        parent_id_winner = resolver(*parents)
764
1065
        if this_name is None:
765
1066
            if name_winner == "this":
766
1067
                name_winner = "other"
835
1136
                    self.tt.delete_contents(trans_id)
836
1137
                if file_id in self.other_tree:
837
1138
                    # OTHER changed the file
838
 
                    create_by_entry(self.tt, 
839
 
                                    self.other_tree.inventory[file_id], 
840
 
                                    self.other_tree, trans_id)
841
 
                    if file_id not in self.this_tree.inventory:
 
1139
                    create_from_tree(self.tt, trans_id,
 
1140
                                     self.other_tree, file_id)
 
1141
                    if file_id not in self.this_tree:
842
1142
                        self.tt.version_file(file_id, trans_id)
843
1143
                    return "modified"
844
1144
                elif file_id in self.this_tree.inventory:
854
1154
                    self.text_merge(file_id, trans_id)
855
1155
                except BinaryFile:
856
1156
                    return contents_conflict()
857
 
                if file_id not in self.this_tree.inventory:
 
1157
                if file_id not in self.this_tree:
858
1158
                    self.tt.version_file(file_id, trans_id)
859
1159
                try:
860
1160
                    self.tt.tree_kind(trans_id)
941
1241
                    versioned = True
942
1242
        return file_group
943
1243
           
944
 
    def _conflict_file(self, name, parent_id, tree, file_id, suffix, 
 
1244
    def _conflict_file(self, name, parent_id, tree, file_id, suffix,
945
1245
                       lines=None):
946
1246
        """Emit a single conflict file."""
947
1247
        name = name + '.' + suffix
948
1248
        trans_id = self.tt.create_path(name, parent_id)
949
 
        entry = tree.inventory[file_id]
950
 
        create_by_entry(self.tt, entry, tree, trans_id, lines)
 
1249
        create_from_tree(self.tt, trans_id, tree, file_id, lines)
951
1250
        return trans_id
952
1251
 
953
1252
    def merge_executable(self, file_id, file_status):
954
1253
        """Perform a merge on the execute bit."""
955
1254
        executable = [self.executable(t, file_id) for t in (self.base_tree,
956
1255
                      self.other_tree, self.this_tree)]
957
 
        self._merge_executable(file_id, executable, file_status)
 
1256
        self._merge_executable(file_id, executable, file_status,
 
1257
                               resolver=self._three_way)
958
1258
 
959
 
    def _merge_executable(self, file_id, executable, file_status):
 
1259
    def _merge_executable(self, file_id, executable, file_status,
 
1260
                          resolver):
960
1261
        """Perform a merge on the execute bit."""
961
1262
        base_executable, other_executable, this_executable = executable
962
1263
        if file_status == "deleted":
963
1264
            return
964
 
        winner = self._three_way(*executable)
 
1265
        winner = resolver(*executable)
965
1266
        if winner == "conflict":
966
1267
        # There must be a None in here, if we have a conflict, but we
967
1268
        # need executability since file status was not deleted.