/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

  • Committer: Ian Clatworthy
  • Date: 2009-02-17 23:37:24 UTC
  • mto: (0.64.114 trunk)
  • mto: This revision was merged to the branch mainline in revision 6631.
  • Revision ID: ian.clatworthy@canonical.com-20090217233724-y6q12cyoyln6vkh6
code & tests for file copying

Show diffs side-by-side

added added

removed removed

Lines of Context:
822
822
        self.warning("ignoring delete of %s as not in parent inventories", path)
823
823
 
824
824
    def copy_handler(self, filecmd):
825
 
        raise NotImplementedError(self.copy_handler)
 
825
        src_path = filecmd.src_path
 
826
        dest_path = filecmd.dest_path
 
827
        self.debug("copying %s to %s", src_path, dest_path)
 
828
        if not self.parents:
 
829
            self.warning("ignoring copy of %s to %s - no parent revisions",
 
830
                src_path, dest_path)
 
831
            return
 
832
        file_id = self.inventory.path2id(src_path)
 
833
        if file_id is None:
 
834
            self.warning("ignoring copy of %s to %s - source does not exist",
 
835
                src_path, dest_path)
 
836
            return
 
837
        ie = self.inventory[file_id]
 
838
        kind = ie.kind
 
839
        if kind == 'file':
 
840
            content = self._get_content_from_repo(self.parents[0], file_id)
 
841
            self._modify_inventory(dest_path, kind, ie.executable, content)
 
842
        elif kind == 'symlink':
 
843
            self._modify_inventory(dest_path, kind, False, ie.symlink_target)
 
844
        else:
 
845
            self.warning("ignoring copy of %s %s - feature not yet supported",
 
846
                kind, path)
 
847
 
 
848
    def _get_content_from_repo(self, revision_id, file_id):
 
849
        """Get the content of a file for a revision-id."""
 
850
        revtree = self.repo.revision_tree(revision_id)
 
851
        return revtree.get_file_text(file_id)
826
852
 
827
853
    def rename_handler(self, filecmd):
828
854
        old_path = filecmd.old_path