~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_merge_core.py

Merge in bzrdir work to enable checkout improvements.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from os import fdopen
1
2
import os.path
 
3
from tempfile import mkstemp
2
4
 
3
 
import changeset
4
 
from changeset import Inventory, apply_changeset, invert_dict
 
5
from bzrlib import _changeset
 
6
from bzrlib._changeset import Inventory, apply_changeset, invert_dict
5
7
from bzrlib.osutils import backup_file, rename, pathjoin
6
8
from bzrlib.merge3 import Merge3
7
9
import bzrlib
8
10
from bzrlib.atomicfile import AtomicFile
9
 
from changeset import get_contents
 
11
from bzrlib._changeset import get_contents
10
12
 
11
13
 
12
14
class ApplyMerge3:
37
39
        return not (self == other)
38
40
 
39
41
    def apply(self, filename, conflict_handler):
40
 
        new_file = filename+".new" 
 
42
        output_file, new_file = mkstemp(dir=os.path.dirname(filename),
 
43
                                        prefix=os.path.basename(filename))
 
44
        output_file = fdopen(output_file, 'wb')
41
45
        base = self.base
42
46
        other = self.other
43
47
        def get_lines(tree):
50
54
        m3 = Merge3(base_lines, file(filename, "rb").readlines(), other_lines)
51
55
 
52
56
        new_conflicts = False
53
 
        output_file = file(new_file, "wb")
54
57
        start_marker = "!START OF MERGE CONFLICT!" + "I HOPE THIS IS UNIQUE"
55
58
        if self.show_base is True:
56
59
            base_marker = '|' * 7
168
171
 
169
172
def make_merge_changeset(cset, this, base, other, 
170
173
                         conflict_handler, merge_factory):
171
 
    new_cset = changeset.Changeset()
 
174
    new_cset = _changeset.Changeset()
172
175
 
173
176
    for entry in cset.entries.itervalues():
174
177
        if entry.is_boring():
252
255
 
253
256
    old_path = get_path(old_name, old_parent)
254
257
        
255
 
    new_entry = changeset.ChangesetEntry(entry.id, old_parent, old_path)
 
258
    new_entry = _changeset.ChangesetEntry(entry.id, old_parent, old_path)
256
259
    new_entry.new_path = get_path(new_name, new_parent)
257
260
    new_entry.new_parent = new_parent
258
261
    mutter(repr(new_entry))
274
277
                                                      other.id2path(entry.id))
275
278
        return merge_factory(entry.id, base, other)
276
279
 
277
 
    if isinstance(contents, changeset.ReplaceContents):
 
280
    if isinstance(contents, _changeset.ReplaceContents):
278
281
        base_contents = contents.old_contents
279
282
        other_contents = contents.new_contents
280
283
        if base_contents is None and other_contents is None:
298
301
                else:
299
302
                    conflict_handler.new_contents_conflict(this_path, 
300
303
                        other_contents)
301
 
        elif isinstance(base_contents, changeset.TreeFileCreate) and \
302
 
            isinstance(other_contents, changeset.TreeFileCreate):
 
304
        elif isinstance(base_contents, _changeset.TreeFileCreate) and \
 
305
            isinstance(other_contents, _changeset.TreeFileCreate):
303
306
            return make_merge()
304
307
        else:
305
308
            this_contents = get_contents(this, entry.id)
320
323
    metadata = entry.metadata_change
321
324
    if metadata is None:
322
325
        return None
323
 
    assert isinstance(metadata, changeset.ChangeExecFlag)
 
326
    assert isinstance(metadata, _changeset.ChangeExecFlag)
324
327
    if metadata.new_exec_flag is None:
325
328
        return None
326
329
    elif metadata.old_exec_flag is None: