/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

[merge] (Goffredo) faster merge/fetch by peeking into weave

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
 
115
114
                    if file_id is not None:
116
115
                        new_path = self.this_tree.relpath(new_name)
117
116
                        rename(new_name, name)
118
 
                        self.this_tree.branch.rename_one(relpath, new_path)
119
 
                        assert self.this_tree.id2path(file_id) == relpath
120
 
                        self.this_tree._inventory = self.this_tree.read_working_inventory()
 
117
                        self.this_tree.rename_one(relpath, new_path)
121
118
                        assert self.this_tree.id2path(file_id) == new_path
122
119
        except OSError, e:
123
120
            if e.errno != errno.EEXIST and e.errno != errno.ENOTEMPTY:
174
171
        return "skip"
175
172
 
176
173
    def rem_contents_conflict(self, filename, this_contents, base_contents):
177
 
        base_contents(filename+".BASE", self, False)
178
 
        this_contents(filename+".THIS", self, False)
179
 
        return ReplaceContents(this_contents, None)
180
 
 
181
 
    def rem_contents_conflict(self, filename, this_contents, base_contents):
182
 
        base_contents(filename+".BASE", self, False)
183
 
        this_contents(filename+".THIS", self, False)
 
174
        base_contents(filename+".BASE", self)
 
175
        this_contents(filename+".THIS", self)
184
176
        self.conflict("Other branch deleted locally modified file %s" %
185
177
                      filename)
186
178
        return ReplaceContents(this_contents, None)
204
196
            abspath = self.create_all_missing(entry.parent_id, tree)
205
197
        else:
206
198
            abspath = self.abs_this_path(entry.parent_id)
207
 
        entry_path = os.path.join(abspath, entry.name)
 
199
        entry_path = pathjoin(abspath, entry.name)
208
200
        if not os.path.isdir(entry_path):
209
201
            self.create(file_id, entry_path, tree)
210
202
        return entry_path
211
203
 
212
 
    def create(self, file_id, path, tree, reverse=False):
 
204
    def create(self, file_id, path, tree):
213
205
        """Uses tree data to create a filesystem object for the file_id"""
214
206
        from changeset import get_contents
215
 
        get_contents(tree, file_id)(path, self, reverse)
 
207
        get_contents(tree, file_id)(path, self)
216
208
 
217
209
    def missing_for_merge(self, file_id, other_path):
218
210
        """The file_id doesn't exist in THIS, but does in OTHER and BASE"""
219
211
        self.conflict("Other branch modified locally deleted file %s" %
220
212
                      other_path)
221
213
        parent_dir = self.add_missing_parents(file_id, self.other_tree)
222
 
        stem = os.path.join(parent_dir, os.path.basename(other_path))
 
214
        stem = pathjoin(parent_dir, os.path.basename(other_path))
223
215
        self.create(file_id, stem+".OTHER", self.other_tree)
224
216
        self.create(file_id, stem+".BASE", self.base_tree)
225
217
 
228
220
        self.conflict("Three-way conflict merging %s" % filename)
229
221
 
230
222
    def finalize(self):
231
 
        if not self.ignore_zero:
232
 
            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)
233
228
            
234
229
def get_tree(treespec, local_branch=None):
235
230
    location, revno = treespec
312
307
    clients might prefer to call merge_inner(), which has less magic behavior.
313
308
    """
314
309
    if this_dir is None:
315
 
        this_dir = '.'
 
310
        this_dir = u'.'
316
311
    this_branch = Branch.open_containing(this_dir)[0]
317
312
    if show_base and not merge_type is ApplyMerge3:
318
313
        raise BzrCommandError("Show-base is not supported for this merge"
556
551
        adjust_ids = []
557
552
        for id, path in inv_changes.iteritems():
558
553
            if path is not None:
559
 
                if path == '.':
560
 
                    path = ''
 
554
                if path == u'.':
 
555
                    path = u''
561
556
                else:
562
 
                    assert path.startswith('.' + os.sep), "path is %s" % path
 
557
                    assert path.startswith('.' + '/') or path.startswith('.' + '\\'), "path is %s" % path
563
558
                path = path[2:]
564
559
            adjust_ids.append((path, id))
565
560
        if len(adjust_ids) > 0:
585
580
            entry = old_entries[file_id]
586
581
            if entry.parent_id is None:
587
582
                return entry.name
588
 
            return os.path.join(id2path(entry.parent_id), entry.name)
 
583
            return pathjoin(id2path(entry.parent_id), entry.name)
589
584
            
590
585
        for file_id in old_entries:
591
586
            entry = old_entries[file_id]
612
607
                parent = None
613
608
            else:
614
609
                parent = by_path[os.path.dirname(path)]
615
 
            abspath = os.path.join(self.this_tree.basedir, path)
 
610
            abspath = pathjoin(self.this_tree.basedir, path)
616
611
            kind = bzrlib.osutils.file_kind(abspath)
617
612
            new_inventory[file_id] = (path, file_id, parent, kind)
618
613
            by_path[path] = file_id