/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: Jelmer Vernooij
  • Date: 2020-02-21 03:58:42 UTC
  • mfrom: (7490.3.4 work)
  • mto: This revision was merged to the branch mainline in revision 7495.
  • Revision ID: jelmer@jelmer.uk-20200221035842-j97r6b74q8cgxb21
merge lp:brz/3.1.

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,
33
34
    tree as _mod_tree,
34
35
    tsort,
35
36
    ui,
46
47
    errors,
47
48
    hooks,
48
49
    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.transform()
 
761
            self.tt = self.working_tree.get_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 = self.working_tree.preview_transform()
 
773
            self.tt = transform.TransformPreview(self.working_tree)
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 = list(self._entries3())
 
779
            entries = self._entries3()
780
780
            resolver = self._three_way
781
781
        else:
782
 
            entries = list(self._entries_lca())
 
782
            entries = 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
 
793
794
                # Try merging each entry
794
795
                child_pb.update(gettext('Preparing file merge'),
795
796
                                num, len(entries))
830
831
        other and this.  names3 is a tuple of names for base, other and this.
831
832
        executable3 is a tuple of execute-bit values for base, other and this.
832
833
        """
 
834
        result = []
833
835
        iterator = self.other_tree.iter_changes(self.base_tree,
834
836
                                                specific_files=self.interesting_files,
835
837
                                                extra_trees=[self.this_tree])
857
859
            names3 = change.name + (this_name,)
858
860
            paths3 = change.path + (this_path, )
859
861
            executable3 = change.executable + (this_executable,)
860
 
            yield (
 
862
            result.append(
861
863
                (change.file_id, change.changed_content, paths3,
862
864
                 parents3, names3, executable3))
 
865
        return result
863
866
 
864
867
    def _entries_lca(self):
865
868
        """Gather data about files modified between multiple trees.
888
891
                self.interesting_files, lookup_trees)
889
892
        else:
890
893
            interesting_files = None
 
894
        result = []
891
895
        from .multiwalker import MultiWalker
892
896
        walker = MultiWalker(self.other_tree, self._lca_trees)
893
897
 
1031
1035
                    raise AssertionError('unhandled kind: %s' % other_ie.kind)
1032
1036
 
1033
1037
            # If we have gotten this far, that means something has changed
1034
 
            yield (file_id, content_changed,
 
1038
            result.append((file_id, content_changed,
1035
1039
                           ((base_path, lca_paths),
1036
1040
                            other_path, this_path),
1037
1041
                           ((base_ie.parent_id, lca_parent_ids),
1040
1044
                            other_ie.name, this_ie.name),
1041
1045
                           ((base_ie.executable, lca_executable),
1042
1046
                            other_ie.executable, this_ie.executable)
1043
 
                           )
 
1047
                           ))
 
1048
        return result
1044
1049
 
1045
1050
    def write_modified(self, results):
1046
1051
        if not self.working_tree.supports_merge_modified():
1279
1284
                    keep_this = True
1280
1285
                    # versioning the merged file will trigger a duplicate
1281
1286
                    # conflict
1282
 
                    self.tt.version_file(trans_id, file_id=file_id)
 
1287
                    self.tt.version_file(file_id, trans_id)
1283
1288
                    transform.create_from_tree(
1284
1289
                        self.tt, trans_id, self.other_tree,
1285
1290
                        other_path,
1326
1331
        else:
1327
1332
            raise AssertionError('unknown hook_status: %r' % (hook_status,))
1328
1333
        if not this_path and result == "modified":
1329
 
            self.tt.version_file(trans_id, file_id=file_id)
 
1334
            self.tt.version_file(file_id, trans_id)
1330
1335
        if not keep_this:
1331
1336
            # The merge has been performed and produced a new content, so the
1332
1337
            # old contents should not be retained.
1456
1461
            data.append(('BASE', self.base_tree, base_path, base_lines))
1457
1462
 
1458
1463
        # We need to use the actual path in the working tree of the file here,
1459
 
        if self.this_tree.supports_content_filtering():
1460
 
            filter_tree_path = this_path
 
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
1461
1472
        else:
1462
1473
            # Skip the id2path lookup for older formats
1463
1474
            filter_tree_path = None
1471
1482
                    filter_tree_path)
1472
1483
                file_group.append(trans_id)
1473
1484
                if set_version and not versioned:
1474
 
                    self.tt.version_file(trans_id, file_id=file_id)
 
1485
                    self.tt.version_file(file_id, trans_id)
1475
1486
                    versioned = True
1476
1487
        return file_group
1477
1488