~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/diff.py

  • Committer: INADA Naoki
  • Date: 2010-02-25 11:57:09 UTC
  • mto: (5074.5.1 fix-523746-dev)
  • mto: This revision was merged to the branch mainline in revision 5892.
  • Revision ID: songofacandy@gmail.com-20100225115709-huestawx67a60z1m
Make temporary filename more friendly for non ascii filename.

Show diffs side-by-side

added added

removed removed

Lines of Context:
682
682
 
683
683
    def _get_command(self, old_path, new_path):
684
684
        my_map = {'old_path': old_path, 'new_path': new_path}
685
 
        return [t % my_map for t in self.command_template]
 
685
        command = [t % my_map for t in self.command_template]
 
686
        if sys.platform == 'win32': # Popen doesn't accept unicode on win32
 
687
            command_encoded = []
 
688
            for c in command:
 
689
                if isinstance(c, unicode):
 
690
                    command_encoded.append(c.encode('mbcs'))
 
691
                else:
 
692
                    command_encoded.append(c)
 
693
            return command_encoded
 
694
        else:
 
695
            return command
686
696
 
687
697
    def _execute(self, old_path, new_path):
688
698
        command = self._get_command(old_path, new_path)
709
719
        return True
710
720
 
711
721
    def _write_file(self, file_id, tree, prefix, relpath):
712
 
        full_path = osutils.pathjoin(self._root, prefix,
713
 
                                     '_'+relpath.encode('ascii', 'ignore'))
 
722
        if sys.platform == 'win32':
 
723
            fenc = 'mbcs'
 
724
        else:
 
725
            fenc = sys.getfilesystemencoding()
 
726
        relpath_tmp = relpath.encode(fenc, 'replace').decode(fenc, 'replace')
 
727
        relpath_tmp.replace(u'?', u'_')
 
728
        full_path = osutils.pathjoin(self._root, prefix, relpath_tmp)
714
729
        if self._try_symlink_root(tree, prefix):
715
730
            return full_path
716
731
        parent_dir = osutils.dirname(full_path)