~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-10-15 16:32:29 UTC
  • mfrom: (1731.1.67 unique-root)
  • Revision ID: pqm@pqm.ubuntu.com-20061015163229-648b1f2ebe692136
New trees have unique root ids

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
from bzrlib.textfile import check_text_lines
46
46
from bzrlib.trace import mutter, warning, note
47
47
from bzrlib.transform import (TreeTransform, resolve_conflicts, cook_conflicts,
48
 
                              FinalPaths, create_by_entry, unique_add)
 
48
                              FinalPaths, create_by_entry, unique_add,
 
49
                              ROOT_PARENT)
49
50
from bzrlib.versionedfile import WeaveMerge
50
51
from bzrlib import ui
51
52
 
388
389
                    self.merge_executable(file_id, file_status)
389
390
            finally:
390
391
                child_pb.finished()
391
 
                
 
392
            self.fix_root()
392
393
            self.pp.next_phase()
393
394
            child_pb = ui.ui_factory.nested_progress_bar()
394
395
            try:
410
411
            working_tree.unlock()
411
412
            self.pb.clear()
412
413
 
 
414
    def fix_root(self):
 
415
        try:
 
416
            self.tt.final_kind(self.tt.root)
 
417
        except NoSuchFile:
 
418
            self.tt.cancel_deletion(self.tt.root)
 
419
        if self.tt.final_file_id(self.tt.root) is None:
 
420
            self.tt.version_file(self.tt.tree_file_id(self.tt.root), 
 
421
                                 self.tt.root)
 
422
        if self.other_tree.inventory.root is None:
 
423
            return
 
424
        other_root_file_id = self.other_tree.inventory.root.file_id
 
425
        other_root = self.tt.trans_id_file_id(other_root_file_id)
 
426
        if other_root == self.tt.root:
 
427
            return
 
428
        try:
 
429
            self.tt.final_kind(other_root)
 
430
        except NoSuchFile:
 
431
            return
 
432
        self.reparent_children(self.other_tree.inventory.root, self.tt.root)
 
433
        self.tt.cancel_creation(other_root)
 
434
        self.tt.cancel_versioning(other_root)
 
435
 
 
436
    def reparent_children(self, ie, target):
 
437
        for thing, child in ie.children.iteritems():
 
438
            trans_id = self.tt.trans_id_file_id(child.file_id)
 
439
            self.tt.adjust_path(self.tt.final_name(trans_id), target, trans_id)
 
440
 
413
441
    def write_modified(self, results):
414
442
        modified_hashes = {}
415
443
        for path in results.modified_paths:
520
548
                        "conflict": other_entry}
521
549
        trans_id = self.tt.trans_id_file_id(file_id)
522
550
        parent_id = winner_entry[parent_id_winner].parent_id
523
 
        parent_trans_id = self.tt.trans_id_file_id(parent_id)
524
 
        self.tt.adjust_path(winner_entry[name_winner].name, parent_trans_id,
525
 
                            trans_id)
 
551
        if parent_id is not None:
 
552
            parent_trans_id = self.tt.trans_id_file_id(parent_id)
 
553
            self.tt.adjust_path(winner_entry[name_winner].name, 
 
554
                                parent_trans_id, trans_id)
526
555
 
527
556
    def merge_contents(self, file_id):
528
557
        """Performa a merge on file_id contents."""