~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/conflicts.py

Fixed as per Aaron's remark.

* bzrlib/tests/test_conflicts.py:
(TestResolveParentLoop.test_resolve_keeping_mine,
TestResolveParentLoop.test_resolve_taking_theirs): Toghten the
tests as debug showed they were passing with bogus code.

* bzrlib/conflicts.py:
(ParentLoop.take_theirs): Use a TreeTransform to safely rename
multiple files at once.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    osutils,
32
32
    rio,
33
33
    trace,
 
34
    transform,
34
35
    workingtree,
35
36
    )
36
37
""")
607
608
    def take_theirs(self, tree):
608
609
        # FIXME: We shouldn't have to manipulate so many paths here (and there
609
610
        # is probably a bug or two...)
 
611
        base_path = osutils.basename(self.path)
610
612
        conflict_base_path = osutils.basename(self.conflict_path)
611
 
        base_path = osutils.basename(self.path)
612
 
        tree.rename_one(self.conflict_path, conflict_base_path)
613
 
        tree.rename_one(self.path,
614
 
                        osutils.joinpath([conflict_base_path, base_path]))
 
613
        tt = transform.TreeTransform(tree)
 
614
        try:
 
615
            p_tid = tt.trans_id_file_id(self.file_id)
 
616
            parent_tid = tt.get_tree_parent(p_tid)
 
617
            cp_tid = tt.trans_id_file_id(self.conflict_file_id)
 
618
            cparent_tid = tt.get_tree_parent(cp_tid)
 
619
            tt.adjust_path(base_path, cparent_tid, cp_tid)
 
620
            tt.adjust_path(conflict_base_path, parent_tid, p_tid)
 
621
            tt.apply()
 
622
        finally:
 
623
            tt.finalize()
615
624
 
616
625
 
617
626
class UnversionedParent(HandledConflict):