/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 breezy/merge.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-07-20 02:17:05 UTC
  • mfrom: (7518.1.2 merge-3.1)
  • Revision ID: breezy.the.bot@gmail.com-20200720021705-5f11tmo1hdqjxm6x
Merge lp:brz/3.1.

Merged from https://code.launchpad.net/~jelmer/brz/merge-3.1/+merge/387628

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    revision as _mod_revision,
31
31
    textfile,
32
32
    trace,
33
 
    transform,
34
33
    tree as _mod_tree,
35
34
    tsort,
36
35
    ui,
47
46
    errors,
48
47
    hooks,
49
48
    registry,
 
49
    transform,
50
50
    )
51
51
# TODO: Report back as changes are merged in
52
52
 
758
758
            stack.enter_context(self.this_tree.lock_read())
759
759
            stack.enter_context(self.base_tree.lock_read())
760
760
            stack.enter_context(self.other_tree.lock_read())
761
 
            self.tt = self.working_tree.get_transform()
 
761
            self.tt = self.working_tree.transform()
762
762
            stack.enter_context(self.tt)
763
763
            self._compute_transform()
764
764
            results = self.tt.apply(no_conflicts=True)
770
770
 
771
771
    def make_preview_transform(self):
772
772
        with self.base_tree.lock_read(), self.other_tree.lock_read():
773
 
            self.tt = transform.TransformPreview(self.working_tree)
 
773
            self.tt = self.working_tree.preview_transform()
774
774
            self._compute_transform()
775
775
            return self.tt
776
776
 
777
777
    def _compute_transform(self):
778
778
        if self._lca_trees is None:
779
 
            entries = self._entries3()
 
779
            entries = list(self._entries3())
780
780
            resolver = self._three_way
781
781
        else:
782
 
            entries = self._entries_lca()
 
782
            entries = list(self._entries_lca())
783
783
            resolver = self._lca_multi_way
784
784
        # Prepare merge hooks
785
785
        factories = Merger.hooks['merge_file_content']
790
790
            for num, (file_id, changed, paths3, parents3, names3,
791
791
                      executable3) in enumerate(entries):
792
792
                trans_id = self.tt.trans_id_file_id(file_id)
793
 
 
794
793
                # Try merging each entry
795
794
                child_pb.update(gettext('Preparing file merge'),
796
795
                                num, len(entries))
831
830
        other and this.  names3 is a tuple of names for base, other and this.
832
831
        executable3 is a tuple of execute-bit values for base, other and this.
833
832
        """
834
 
        result = []
835
833
        iterator = self.other_tree.iter_changes(self.base_tree,
836
834
                                                specific_files=self.interesting_files,
837
835
                                                extra_trees=[self.this_tree])
859
857
            names3 = change.name + (this_name,)
860
858
            paths3 = change.path + (this_path, )
861
859
            executable3 = change.executable + (this_executable,)
862
 
            result.append(
 
860
            yield (
863
861
                (change.file_id, change.changed_content, paths3,
864
862
                 parents3, names3, executable3))
865
 
        return result
866
863
 
867
864
    def _entries_lca(self):
868
865
        """Gather data about files modified between multiple trees.
891
888
                self.interesting_files, lookup_trees)
892
889
        else:
893
890
            interesting_files = None
894
 
        result = []
895
891
        from .multiwalker import MultiWalker
896
892
        walker = MultiWalker(self.other_tree, self._lca_trees)
897
893
 
1035
1031
                    raise AssertionError('unhandled kind: %s' % other_ie.kind)
1036
1032
 
1037
1033
            # If we have gotten this far, that means something has changed
1038
 
            result.append((file_id, content_changed,
 
1034
            yield (file_id, content_changed,
1039
1035
                           ((base_path, lca_paths),
1040
1036
                            other_path, this_path),
1041
1037
                           ((base_ie.parent_id, lca_parent_ids),
1044
1040
                            other_ie.name, this_ie.name),
1045
1041
                           ((base_ie.executable, lca_executable),
1046
1042
                            other_ie.executable, this_ie.executable)
1047
 
                           ))
1048
 
        return result
 
1043
                           )
1049
1044
 
1050
1045
    def write_modified(self, results):
1051
1046
        if not self.working_tree.supports_merge_modified():
1284
1279
                    keep_this = True
1285
1280
                    # versioning the merged file will trigger a duplicate
1286
1281
                    # conflict
1287
 
                    self.tt.version_file(file_id, trans_id)
 
1282
                    self.tt.version_file(trans_id, file_id=file_id)
1288
1283
                    transform.create_from_tree(
1289
1284
                        self.tt, trans_id, self.other_tree,
1290
1285
                        other_path,
1331
1326
        else:
1332
1327
            raise AssertionError('unknown hook_status: %r' % (hook_status,))
1333
1328
        if not this_path and result == "modified":
1334
 
            self.tt.version_file(file_id, trans_id)
 
1329
            self.tt.version_file(trans_id, file_id=file_id)
1335
1330
        if not keep_this:
1336
1331
            # The merge has been performed and produced a new content, so the
1337
1332
            # old contents should not be retained.
1461
1456
            data.append(('BASE', self.base_tree, base_path, base_lines))
1462
1457
 
1463
1458
        # We need to use the actual path in the working tree of the file here,
1464
 
        # ignoring the conflict suffixes
1465
 
        wt = self.this_tree
1466
 
        if wt.supports_content_filtering():
1467
 
            try:
1468
 
                filter_tree_path = wt.id2path(file_id)
1469
 
            except errors.NoSuchId:
1470
 
                # file has been deleted
1471
 
                filter_tree_path = None
 
1459
        if self.this_tree.supports_content_filtering():
 
1460
            filter_tree_path = this_path
1472
1461
        else:
1473
1462
            # Skip the id2path lookup for older formats
1474
1463
            filter_tree_path = None
1482
1471
                    filter_tree_path)
1483
1472
                file_group.append(trans_id)
1484
1473
                if set_version and not versioned:
1485
 
                    self.tt.version_file(file_id, trans_id)
 
1474
                    self.tt.version_file(trans_id, file_id=file_id)
1486
1475
                    versioned = True
1487
1476
        return file_group
1488
1477