~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: John Arbash Meinel
  • Date: 2006-02-21 16:43:22 UTC
  • mfrom: (1560 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1562.
  • Revision ID: john@arbash-meinel.com-20060221164322-b007aa882582a66e
[merge] bzr.dev, cleanup conflicts, fixup http tests for new TestCase layout.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
                           UnrelatedBranches,
35
35
                           WorkingTreeNotRevision,
36
36
                           )
37
 
from bzrlib.fetch import greedy_fetch, fetch
38
37
from bzrlib.merge3 import Merge3
39
38
import bzrlib.osutils
40
39
from bzrlib.osutils import rename, pathjoin
41
40
from bzrlib.revision import common_ancestor, is_ancestor, NULL_REVISION
 
41
from bzrlib.trace import mutter, warning, note
42
42
from bzrlib.transform import (TreeTransform, resolve_conflicts, cook_conflicts,
43
43
                              conflicts_strings, FinalPaths, create_by_entry,
44
44
                              unique_add)
45
 
from bzrlib.trace import mutter, warning, note
46
45
 
47
46
# TODO: Report back as changes are merged in
48
47
 
66
65
    else:
67
66
        if local_branch is not None:
68
67
            if local_branch.base != branch.base:
69
 
                greedy_fetch(local_branch, branch, revision)
 
68
                local_branch.fetch(branch, revision)
70
69
            base_tree = local_branch.repository.revision_tree(revision)
71
70
        else:
72
71
            base_tree = branch.repository.revision_tree(revision)
194
193
            if self.other_basis is None:
195
194
                raise NoCommits(other_branch)
196
195
        if other_branch.base != self.this_branch.base:
197
 
            fetch(from_branch=other_branch, to_branch=self.this_branch, 
198
 
                  last_revision=self.other_basis)
 
196
            self.this_branch.fetch(other_branch, last_revision=self.other_basis)
199
197
 
200
198
    def set_base(self, base_revision):
201
199
        mutter("doing merge() with no base_revision specified")
217
215
                self.base_rev_id = None
218
216
            else:
219
217
                self.base_rev_id = base_branch.get_rev_id(base_revision[1])
220
 
            fetch(from_branch=base_branch, to_branch=self.this_branch)
 
218
            self.this_branch.fetch(base_branch)
221
219
            self.base_is_ancestor = is_ancestor(self.this_basis, 
222
220
                                                self.base_rev_id,
223
221
                                                self.this_branch)
426
424
        if name_winner == "this" and parent_id_winner == "this":
427
425
            return
428
426
        if name_winner == "conflict":
429
 
            trans_id = self.tt.get_trans_id(file_id)
 
427
            trans_id = self.tt.trans_id_file_id(file_id)
430
428
            self._raw_conflicts.append(('name conflict', trans_id, 
431
429
                                        self.name(this_entry, file_id), 
432
430
                                        self.name(other_entry, file_id)))
433
431
        if parent_id_winner == "conflict":
434
 
            trans_id = self.tt.get_trans_id(file_id)
 
432
            trans_id = self.tt.trans_id_file_id(file_id)
435
433
            self._raw_conflicts.append(('parent conflict', trans_id, 
436
434
                                        self.parent(this_entry, file_id), 
437
435
                                        self.parent(other_entry, file_id)))
442
440
        # if we get here, name_winner and parent_winner are set to safe values.
443
441
        winner_entry = {"this": this_entry, "other": other_entry, 
444
442
                        "conflict": other_entry}
445
 
        trans_id = self.tt.get_trans_id(file_id)
 
443
        trans_id = self.tt.trans_id_file_id(file_id)
446
444
        parent_id = winner_entry[parent_id_winner].parent_id
447
 
        parent_trans_id = self.tt.get_trans_id(parent_id)
 
445
        parent_trans_id = self.tt.trans_id_file_id(parent_id)
448
446
        self.tt.adjust_path(winner_entry[name_winner].name, parent_trans_id,
449
447
                            trans_id)
450
448
 
476
474
            # THIS and OTHER introduced the same changes
477
475
            return "unmodified"
478
476
        else:
479
 
            trans_id = self.tt.get_trans_id(file_id)
 
477
            trans_id = self.tt.trans_id_file_id(file_id)
480
478
            if this_pair == base_pair:
481
479
                # only OTHER introduced changes
482
480
                if file_id in self.this_tree:
510
508
                return "modified"
511
509
            else:
512
510
                # Scalar conflict, can't text merge.  Dump conflicts
513
 
                trans_id = self.tt.get_trans_id(file_id)
 
511
                trans_id = self.tt.trans_id_file_id(file_id)
514
512
                name = self.tt.final_name(trans_id)
515
513
                parent_id = self.tt.final_parent(trans_id)
516
514
                if file_id in self.this_tree.inventory:
607
605
        """Perform a merge on the execute bit."""
608
606
        if file_status == "deleted":
609
607
            return
610
 
        trans_id = self.tt.get_trans_id(file_id)
 
608
        trans_id = self.tt.trans_id_file_id(file_id)
611
609
        try:
612
610
            if self.tt.final_kind(trans_id) != "file":
613
611
                return
627
625
            if file_status == "modified":
628
626
                executability = self.this_tree.is_executable(file_id)
629
627
                if executability is not None:
630
 
                    trans_id = self.tt.get_trans_id(file_id)
 
628
                    trans_id = self.tt.trans_id_file_id(file_id)
631
629
                    self.tt.set_executability(executability, trans_id)
632
630
        else:
633
631
            assert winner == "other"
638
636
            elif file_id in self.base_tree:
639
637
                executability = self.base_tree.is_executable(file_id)
640
638
            if executability is not None:
641
 
                trans_id = self.tt.get_trans_id(file_id)
 
639
                trans_id = self.tt.trans_id_file_id(file_id)
642
640
                self.tt.set_executability(executability, trans_id)
643
641
 
644
642
    def cook_conflicts(self, fs_conflicts):
687
685
            other_path = fp.get_path(trans_id)
688
686
            if this_parent is not None:
689
687
                this_parent_path = \
690
 
                    fp.get_path(self.tt.get_trans_id(this_parent))
 
688
                    fp.get_path(self.tt.trans_id_file_id(this_parent))
691
689
                this_path = pathjoin(this_parent_path, this_name)
692
690
            else:
693
691
                this_path = "<deleted>"