~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
import bzrlib
24
24
from bzrlib.branch import Branch
 
25
from bzrlib.conflicts import ConflictList
25
26
from bzrlib.delta import compare_trees
26
27
from bzrlib.errors import (BzrCommandError,
27
28
                           BzrError,
32
33
                           NotBranchError,
33
34
                           NotVersionedError,
34
35
                           UnrelatedBranches,
 
36
                           UnsupportedOperation,
35
37
                           WorkingTreeNotRevision,
36
38
                           )
37
39
from bzrlib.merge3 import Merge3
42
44
from bzrlib.symbol_versioning import *
43
45
from bzrlib.trace import mutter, warning, note
44
46
from bzrlib.transform import (TreeTransform, resolve_conflicts, cook_conflicts,
45
 
                              conflicts_strings, FinalPaths, create_by_entry,
46
 
                              unique_add)
 
47
                              FinalPaths, create_by_entry, unique_add)
47
48
from bzrlib.versionedfile import WeaveMerge
48
49
import bzrlib.ui
49
50
 
282
283
        for file_id in old_entries:
283
284
            entry = old_entries[file_id]
284
285
            path = id2path(file_id)
 
286
            if file_id in self.base_tree.inventory:
 
287
                executable = getattr(self.base_tree.inventory[file_id], 'executable', False)
 
288
            else:
 
289
                executable = getattr(entry, 'executable', False)
285
290
            new_inventory[file_id] = (path, file_id, entry.parent_id, 
286
 
                                      entry.kind)
 
291
                                      entry.kind, executable)
 
292
                                      
287
293
            by_path[path] = file_id
288
294
        
289
295
        deletions = 0
306
312
                parent = by_path[os.path.dirname(path)]
307
313
            abspath = pathjoin(self.this_tree.basedir, path)
308
314
            kind = bzrlib.osutils.file_kind(abspath)
309
 
            new_inventory[file_id] = (path, file_id, parent, kind)
 
315
            if file_id in self.base_tree.inventory:
 
316
                executable = getattr(self.base_tree.inventory[file_id], 'executable', False)
 
317
            else:
 
318
                executable = False
 
319
            new_inventory[file_id] = (path, file_id, parent, kind, executable)
310
320
            by_path[path] = file_id 
311
321
 
312
322
        # Get a list in insertion order
371
381
            finally:
372
382
                child_pb.finished()
373
383
            self.cook_conflicts(fs_conflicts)
374
 
            for line in conflicts_strings(self.cooked_conflicts):
375
 
                warning(line)
 
384
            for conflict in self.cooked_conflicts:
 
385
                warning(conflict)
376
386
            self.pp.next_phase()
377
387
            results = self.tt.apply()
378
388
            self.write_modified(results)
 
389
            try:
 
390
                working_tree.set_conflicts(ConflictList(self.cooked_conflicts))
 
391
            except UnsupportedOperation:
 
392
                pass
379
393
        finally:
380
394
            try:
381
395
                self.tt.finalize()
693
707
 
694
708
    def cook_conflicts(self, fs_conflicts):
695
709
        """Convert all conflicts into a form that doesn't depend on trans_id"""
 
710
        from conflicts import Conflict
696
711
        name_conflicts = {}
697
712
        self.cooked_conflicts.extend(cook_conflicts(fs_conflicts, self.tt))
698
713
        fp = FinalPaths(self.tt)
715
730
                    if path.endswith(suffix):
716
731
                        path = path[:-len(suffix)]
717
732
                        break
718
 
                self.cooked_conflicts.append((conflict_type, file_id, path))
 
733
                c = Conflict.factory(conflict_type, path=path, file_id=file_id)
 
734
                self.cooked_conflicts.append(c)
719
735
            if conflict_type == 'text conflict':
720
736
                trans_id = conflict[1]
721
737
                path = fp.get_path(trans_id)
722
738
                file_id = self.tt.final_file_id(trans_id)
723
 
                self.cooked_conflicts.append((conflict_type, file_id, path))
 
739
                c = Conflict.factory(conflict_type, path=path, file_id=file_id)
 
740
                self.cooked_conflicts.append(c)
724
741
 
725
742
        for trans_id, conflicts in name_conflicts.iteritems():
726
743
            try:
742
759
            else:
743
760
                this_path = "<deleted>"
744
761
            file_id = self.tt.final_file_id(trans_id)
745
 
            self.cooked_conflicts.append(('path conflict', file_id, this_path, 
746
 
                                         other_path))
 
762
            c = Conflict.factory('path conflict', path=this_path,
 
763
                                 conflict_path=other_path, file_id=file_id)
 
764
            self.cooked_conflicts.append(c)
747
765
 
748
766
 
749
767
class WeaveMerger(Merge3Merger):