~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Aaron Bentley
  • Date: 2005-09-15 21:32:56 UTC
  • mto: (1185.1.29)
  • mto: This revision was merged to the branch mainline in revision 1390.
  • Revision ID: abentley@panoramicfeedback.com-20050915213256-45b0f3d25faa8c52
Reverted incomplete conflict handling

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
    conflict that are not explicitly handled cause an exception and
48
48
    terminate the merge.
49
49
    """
50
 
    def __init__(self, this_branch, this_tree, base_tree, other_tree, 
51
 
                 ignore_zero=False):
 
50
    def __init__(self, ignore_zero=False):
52
51
        ExceptionConflictHandler.__init__(self)
53
 
        self.this_branch = this_branch
54
 
        self.this_tree = this_tree
55
 
        self.base_tree = base_tree
56
 
        self.other_tree = other_tree
57
52
        self.conflicts = 0
58
53
        self.ignore_zero = ignore_zero
59
 
        self.inventory_changes = []
60
 
 
61
 
    def inventory_add(self, id, path):
62
 
        self.this_branch.inventory.add([path])
63
 
        self.inventory_changes[id] = path
64
54
 
65
55
    def copy(self, source, dest):
66
56
        """Copy the text and mode of a file
78
68
        :param source: The path of the file to copy
79
69
        :param dest: The distination file to create
80
70
        """
81
 
        self.clear_path(dest)
82
71
        d_file = file(dest, "wb")
83
72
        for line in lines:
84
73
            d_file.write(line)
122
111
        os.rename(new_file, this_path)
123
112
        self.conflict("Diff3 conflict encountered in %s" % this_path)
124
113
 
125
 
    def invent_path(self, file_id, create_dir=False):
126
 
        """Copies as much of the path as possible from this_tree, substituting
127
 
        pathname elements from other_tree where necessary.
128
 
        """
129
 
        path = self.this_tree.id2path()
130
 
        if path is not None:
131
 
            return this_tree.abspath(path)
132
 
        else:
133
 
            ie = other.inventory[file_id]
134
 
            parent_dir = self.invent_path(ie.parent_id, create_dir=True)
135
 
            path = os.path.join(parent_dir, ie.name)
136
 
            if create_dir:
137
 
                add_dir(self, file_id, path)
138
 
 
139
 
    def add_dir(self, file_id, path):
140
 
        self.clear_path(path)
141
 
        os.path.mkdir(path)
142
 
        self.this_branch.add([path], [file_id])
143
 
        self.inventory_change[file_id] = path
144
 
 
145
 
    def missing_for_merge(self, file_id, other_path):
146
 
        try:
147
 
            path = self.invent_path(file_id)
148
 
            self.clear_path()
149
 
            self.dump(self.base_tree.get_file(file_id), path)
150
 
 
151
114
    def new_contents_conflict(self, filename, other_contents):
152
115
        """Conflicting contents for newly added file."""
153
116
        self.copy(other_contents, filename + ".OTHER")
239
202
            return True
240
203
        return self.tree.inventory.has_id(file_id)
241
204
 
242
 
    def abspath(self, filename):
243
 
        return self.tree.filename
244
 
 
245
205
    def readonly_path(self, id):
246
206
        if id not in self.tree:
247
207
            return None
390
350
    def get_inventory(tree):
391
351
        return tree.tree.inventory
392
352
 
393
 
    handler = MergeConflictHander(this_branch, this_tree, base_tree, 
394
 
                                  other_tree, ignore_zero=ignore_zero)
395
353
    inv_changes = merge_flex(this_tree, base_tree, other_tree,
396
 
                             generate_cset_optimized, get_inventory, handler,
 
354
                             generate_cset_optimized, get_inventory,
 
355
                             MergeConflictHandler(ignore_zero=ignore_zero),
397
356
                             merge_factory=merge_factory, 
398
357
                             interesting_ids=interesting_ids)
399
358