~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Aaron Bentley
  • Date: 2007-12-25 04:17:50 UTC
  • mto: This revision was merged to the branch mainline in revision 3160.
  • Revision ID: aaron.bentley@utoronto.ca-20071225041750-t6chr3pmgnebvqcz
Handle non-directory parent conflicts (abentley, #177390)

Show diffs side-by-side

added added

removed removed

Lines of Context:
658
658
                        self.tree_kind(t) == 'directory'])
659
659
        for trans_id in self._removed_id:
660
660
            file_id = self.tree_file_id(trans_id)
661
 
            if self._tree.inventory[file_id].kind == 'directory':
 
661
            if file_id is not None:
 
662
                if self._tree.inventory[file_id].kind == 'directory':
 
663
                    parents.append(trans_id)
 
664
            elif self.tree_kind(trans_id) == 'directory':
662
665
                parents.append(trans_id)
663
666
 
664
667
        for parent_id in parents:
982
985
                        file_id = self._tree.get_root_id()
983
986
                    else:
984
987
                        file_id = self.tree_file_id(trans_id)
985
 
                    assert file_id is not None
986
 
                    inventory_delta.append((path, None, file_id, None))
 
988
                    if file_id is not None:
 
989
                        inventory_delta.append((path, None, file_id, None))
987
990
        finally:
988
991
            child_pb.finished()
989
992
 
1490
1493
    for child in tt.iter_tree_children(old_parent):
1491
1494
        tt.adjust_path(tt.final_name(child), new_parent, child)
1492
1495
 
 
1496
def _reparent_transform_children(tt, old_parent, new_parent):
 
1497
    by_parent = tt.by_parent()
 
1498
    for child in by_parent[old_parent]:
 
1499
        tt.adjust_path(tt.final_name(child), new_parent, child)
1493
1500
 
1494
1501
def _content_match(tree, entry, file_id, kind, target_path):
1495
1502
    if entry.kind != kind:
1878
1885
        elif c_type == 'unversioned parent':
1879
1886
            tt.version_file(tt.inactive_file_id(conflict[1]), conflict[1])
1880
1887
            new_conflicts.add((c_type, 'Versioned directory', conflict[1]))
 
1888
        elif c_type == 'non-directory parent':
 
1889
            parent_id = conflict[1]
 
1890
            parent_parent = tt.final_parent(parent_id)
 
1891
            parent_name = tt.final_name(parent_id)
 
1892
            parent_file_id = tt.final_file_id(parent_id)
 
1893
            new_parent_id = tt.new_directory(parent_name + '.new',
 
1894
                parent_parent, parent_file_id)
 
1895
            _reparent_transform_children(tt, parent_id, new_parent_id)
 
1896
            tt.unversion_file(parent_id)
 
1897
            new_conflicts.add((c_type, 'Created directory', new_parent_id))
1881
1898
    return new_conflicts
1882
1899
 
1883
1900