/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 processors/generic_processor.py

add lots of import tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
668
668
        old_path = filecmd.old_path
669
669
        new_path = filecmd.new_path
670
670
        self.debug("renaming %s to %s", old_path, new_path)
671
 
        file_id = self.bzr_file_id(old_path)
672
 
        basename, new_parent_ie = self._ensure_directory(new_path)
 
671
        old_file_id = self.inventory.path2id(old_path)
 
672
        old_ie = self.inventory[old_file_id]
 
673
        new_file_id = self.inventory.path2id(new_path)
 
674
        if new_file_id is not None:
 
675
            self.inventory.remove_recursive_id(new_file_id)
 
676
 
 
677
        # Why are these lines needed?
 
678
        old_lines = self.loader._get_lines(old_file_id, old_ie.revision)
 
679
        self.lines_for_commit[old_file_id] = old_lines
 
680
        self.inventory[old_file_id].revision = self.revision_id
 
681
 
 
682
        new_basename, new_parent_ie = self._ensure_directory(new_path)
673
683
        new_parent_id = new_parent_ie.file_id
674
 
        existing_id = self.inventory.path2id(new_path)
675
 
        if existing_id is not None:
676
 
            self.inventory.remove_recursive_id(existing_id)
677
 
        ie = self.inventory[file_id]
678
 
        lines = self.loader._get_lines(file_id, ie.revision)
679
 
        self.lines_for_commit[file_id] = lines
680
 
        self.inventory.rename(file_id, new_parent_id, basename)
 
684
        self.inventory.rename(old_file_id, new_parent_id, new_basename)
681
685
        self.cache_mgr.rename_path(old_path, new_path)
682
 
        self.inventory[file_id].revision = self.revision_id
683
686
 
684
687
    def deleteall_handler(self, filecmd):
685
688
        self.debug("deleting all files (and also all directories)")
829
832
        # make sure the cache used by get_lines knows that
830
833
        self.lines_for_commit[dir_file_id] = []
831
834
        #print "adding dir for %s" % path
832
 
        self.inventory.add(ie)
 
835
        try:
 
836
            self.inventory.add(ie)
 
837
        except errors.DuplicateFileId:
 
838
            # Directory already exists as a file or symlink
 
839
            del self.inventory[ie.file_id]
 
840
            # Try again
 
841
            self.inventory.add(ie)
833
842
        return basename, ie