~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge_core.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:
3
3
import stat
4
4
import sys
5
5
 
 
6
import bzrlib
6
7
from bzrlib.add import smart_add_tree
7
8
from bzrlib.branch import ScratchBranch, Branch
8
9
from bzrlib.builtins import merge
9
10
from bzrlib.errors import (NotBranchError, NotVersionedError,
10
11
                           WorkingTreeNotRevision, BzrCommandError, NoDiff3)
11
 
from bzrlib.fetch import Fetcher
12
12
from bzrlib.inventory import RootEntry
13
13
import bzrlib.inventory as inventory
14
14
from bzrlib.merge import Merge3Merger, Diff3Merger, WeaveMerger
24
24
        def wt(name):
25
25
           path = pathjoin(self.dir, name)
26
26
           os.mkdir(path)
27
 
           b = Branch.initialize(path)
28
 
           wt = b.working_tree()
 
27
           wt = bzrlib.bzrdir.BzrDir.create_standalone_workingtree(path)
29
28
           tt = TreeTransform(wt)
30
29
           return wt, tt
31
30
        self.base, self.base_tt = wt('base') 
40
39
 
41
40
    def add_file(self, id, parent, name, contents, executable):
42
41
        def new_file(tt):
43
 
            parent_id = tt.get_trans_id(parent)
 
42
            parent_id = tt.trans_id_file_id(parent)
44
43
            tt.new_file(name, parent_id, contents, id, executable)
45
44
        for tt in (self.this_tt, self.base_tt, self.other_tt):
46
45
            new_file(tt)
53
52
            tt.apply()
54
53
            wt.commit('branch commit')
55
54
            assert len(wt.branch.revision_history()) == 2
56
 
        Fetcher(self.this.branch, self.other.branch, 
57
 
                self.other.branch.last_revision())
 
55
        self.this.branch.fetch(self.other.branch)
58
56
        other_basis = self.other.branch.basis_tree()
59
57
        merger = merge_type(self.this, self.this, self.base, other_basis)
60
58
        return merger.cooked_conflicts
69
67
 
70
68
    def add_symlink(self, id, parent, name, contents):
71
69
        for tt in self.list_transforms():
72
 
            parent_id = tt.get_trans_id(parent)
 
70
            parent_id = tt.trans_id_file_id(parent)
73
71
            tt.new_symlink(name, parent_id, contents, id)
74
72
 
75
73
    def remove_file(self, file_id, base=False, this=False, other=False):
76
74
        for option, tt in self.selected_transforms(this, base, other):
77
75
            if option is True:
78
 
                trans_id = tt.get_trans_id(file_id)
 
76
                trans_id = tt.trans_id_file_id(file_id)
79
77
                tt.cancel_creation(trans_id)
80
78
                tt.cancel_versioning(trans_id)
81
79
                tt.set_executability(None, trans_id)
82
80
 
83
81
    def add_dir(self, file_id, parent, name):
84
82
        for tt in self.list_transforms():
85
 
            parent_id = tt.get_trans_id(parent)
 
83
            parent_id = tt.trans_id_file_id(parent)
86
84
            tt.new_directory(name, parent_id, file_id)
87
85
 
88
86
    def change_name(self, id, base=None, this=None, other=None):
90
88
                        (other, self.other_tt)):
91
89
            if val is None:
92
90
                continue
93
 
            trans_id = tt.get_trans_id(id)
 
91
            trans_id = tt.trans_id_file_id(id)
94
92
            parent_id = tt.final_parent(trans_id)
95
93
            tt.adjust_path(val, parent_id, trans_id)
96
94
 
97
95
    def change_parent(self, file_id, base=None, this=None, other=None):
98
96
        for parent, tt in self.selected_transforms(this, base, other):
99
 
            trans_id  = tt.get_trans_id(file_id)
100
 
            parent_id = tt.get_trans_id(parent)
 
97
            trans_id  = tt.trans_id_file_id(file_id)
 
98
            parent_id = tt.trans_id_file_id(parent)
101
99
            tt.adjust_path(tt.final_name(trans_id), parent_id, trans_id)
102
100
 
103
101
    def change_contents(self, file_id, base=None, this=None, other=None):
104
102
        for contents, tt in self.selected_transforms(this, base, other):
105
 
            trans_id = tt.get_trans_id(file_id)
 
103
            trans_id = tt.trans_id_file_id(file_id)
106
104
            tt.cancel_creation(trans_id)
107
105
            tt.create_file(contents, trans_id)
108
106
 
109
107
    def change_target(self, id, base=None, this=None, other=None):
110
108
        for target, tt in self.selected_transforms(this, base, other):
111
 
            trans_id = tt.get_trans_id(id)
 
109
            trans_id = tt.trans_id_file_id(id)
112
110
            tt.cancel_creation(trans_id)
113
111
            tt.create_symlink(target, trans_id)
114
112
 
115
113
    def change_perms(self, id, base=None, this=None, other=None):
116
114
        for executability, tt in self.selected_transforms(this, base, other):
117
 
            trans_id = tt.get_trans_id(id)
 
115
            trans_id = tt.trans_id_file_id(id)
118
116
            tt.set_executability(None, trans_id)
119
117
            tt.set_executability(executability, trans_id)
120
118