~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

Merge from integration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
 
18
18
import os
19
 
import tempfile
20
19
import shutil
21
20
import errno
22
21
 
39
38
from bzrlib.trace import mutter, warning, note
40
39
from bzrlib.fetch import greedy_fetch, fetch
41
40
from bzrlib.revision import is_ancestor, NULL_REVISION
42
 
from bzrlib.osutils import rename
 
41
from bzrlib.osutils import rename, pathjoin
43
42
from bzrlib.revision import common_ancestor, MultipleRevisionSources
44
43
from bzrlib.errors import NoSuchRevision
45
44
 
172
171
        return "skip"
173
172
 
174
173
    def rem_contents_conflict(self, filename, this_contents, base_contents):
175
 
        base_contents(filename+".BASE", self, False)
176
 
        this_contents(filename+".THIS", self, False)
177
 
        return ReplaceContents(this_contents, None)
178
 
 
179
 
    def rem_contents_conflict(self, filename, this_contents, base_contents):
180
 
        base_contents(filename+".BASE", self, False)
181
 
        this_contents(filename+".THIS", self, False)
 
174
        base_contents(filename+".BASE", self)
 
175
        this_contents(filename+".THIS", self)
182
176
        self.conflict("Other branch deleted locally modified file %s" %
183
177
                      filename)
184
178
        return ReplaceContents(this_contents, None)
202
196
            abspath = self.create_all_missing(entry.parent_id, tree)
203
197
        else:
204
198
            abspath = self.abs_this_path(entry.parent_id)
205
 
        entry_path = os.path.join(abspath, entry.name)
 
199
        entry_path = pathjoin(abspath, entry.name)
206
200
        if not os.path.isdir(entry_path):
207
201
            self.create(file_id, entry_path, tree)
208
202
        return entry_path
209
203
 
210
 
    def create(self, file_id, path, tree, reverse=False):
 
204
    def create(self, file_id, path, tree):
211
205
        """Uses tree data to create a filesystem object for the file_id"""
212
206
        from changeset import get_contents
213
 
        get_contents(tree, file_id)(path, self, reverse)
 
207
        get_contents(tree, file_id)(path, self)
214
208
 
215
209
    def missing_for_merge(self, file_id, other_path):
216
210
        """The file_id doesn't exist in THIS, but does in OTHER and BASE"""
217
211
        self.conflict("Other branch modified locally deleted file %s" %
218
212
                      other_path)
219
213
        parent_dir = self.add_missing_parents(file_id, self.other_tree)
220
 
        stem = os.path.join(parent_dir, os.path.basename(other_path))
 
214
        stem = pathjoin(parent_dir, os.path.basename(other_path))
221
215
        self.create(file_id, stem+".OTHER", self.other_tree)
222
216
        self.create(file_id, stem+".BASE", self.base_tree)
223
217
 
226
220
        self.conflict("Three-way conflict merging %s" % filename)
227
221
 
228
222
    def finalize(self):
229
 
        if not self.ignore_zero:
230
 
            note("%d conflicts encountered.\n", self.conflicts)
 
223
        if self.conflicts == 0:
 
224
            if not self.ignore_zero:
 
225
                note("All changes applied successfully.")
 
226
        else:
 
227
            note("%d conflicts encountered." % self.conflicts)
231
228
            
232
229
def get_tree(treespec, local_branch=None):
233
230
    location, revno = treespec
310
307
    clients might prefer to call merge_inner(), which has less magic behavior.
311
308
    """
312
309
    if this_dir is None:
313
 
        this_dir = '.'
 
310
        this_dir = u'.'
314
311
    this_branch = Branch.open_containing(this_dir)[0]
315
312
    if show_base and not merge_type is ApplyMerge3:
316
313
        raise BzrCommandError("Show-base is not supported for this merge"
554
551
        adjust_ids = []
555
552
        for id, path in inv_changes.iteritems():
556
553
            if path is not None:
557
 
                if path == '.':
558
 
                    path = ''
 
554
                if path == u'.':
 
555
                    path = u''
559
556
                else:
560
 
                    assert path.startswith('.' + os.sep), "path is %s" % path
 
557
                    assert path.startswith('.' + '/') or path.startswith('.' + '\\'), "path is %s" % path
561
558
                path = path[2:]
562
559
            adjust_ids.append((path, id))
563
560
        if len(adjust_ids) > 0:
583
580
            entry = old_entries[file_id]
584
581
            if entry.parent_id is None:
585
582
                return entry.name
586
 
            return os.path.join(id2path(entry.parent_id), entry.name)
 
583
            return pathjoin(id2path(entry.parent_id), entry.name)
587
584
            
588
585
        for file_id in old_entries:
589
586
            entry = old_entries[file_id]
610
607
                parent = None
611
608
            else:
612
609
                parent = by_path[os.path.dirname(path)]
613
 
            abspath = os.path.join(self.this_tree.basedir, path)
 
610
            abspath = pathjoin(self.this_tree.basedir, path)
614
611
            kind = bzrlib.osutils.file_kind(abspath)
615
612
            new_inventory[file_id] = (path, file_id, parent, kind)
616
613
            by_path[path] = file_id