Commits

Yuya Nishihara  committed dc378bb

rename: handle paths in unicode

  • Participants
  • Parent commits 6301918

Comments (0)

Files changed (1)

File tortoisehg/hgqt/rename.py

     def repo(self):
         return self._repoagent.rawRepo()
 
-    def get_src(self):
-        return hglib.fromunicode(self.src_txt.text())
+    def source(self):
+        return unicode(self.src_txt.text())
 
-    def get_dest(self):
-        return hglib.fromunicode(self.dest_txt.text())
+    def destination(self):
+        return unicode(self.dest_txt.text())
 
     def src_dest_edited(self):
         self.show_command(self.compose_command())
     def src_btn_clicked(self):
         """Select the source file of folder"""
         FD = QFileDialog
-        curr = self.get_src()
-        if os.path.isfile(curr):
+        if os.path.isfile(self.source()):
             caption = _('Select Source File')
             path = FD.getOpenFileName(self, caption, '', '', None, FD.ReadOnly)
         else:
     def dest_btn_clicked(self):
         """Select the destination file of folder"""
         FD = QFileDialog
-        if os.path.isfile(self.get_src()):
+        if os.path.isfile(self.source()):
             caption = _('Select Destination File')
         else:
             caption = _('Select Destination Folder')
         self.commandChanged.emit()
 
     def isCaseFoldingOnWin(self):
-        fullsrc = os.path.abspath(self.get_src())
-        fulldest = os.path.abspath(self.get_dest())
+        fullsrc = os.path.abspath(self.source())
+        fulldest = os.path.abspath(self.destination())
         return (fullsrc.upper() == fulldest.upper() and sys.platform == 'win32')
 
     def compose_command(self):
-        'src and dest are expected to be in local encoding'
         if self.copy_chk.isChecked():
             cmdline = ['copy']
         else:
             cmdline = ['rename']
         cmdline.append('-vf')
-        cmdline.append(self.get_src())
-        cmdline.append(self.get_dest())
+        cmdline.append(self.source())
+        cmdline.append(self.destination())
         return cmdline
 
     def show_command(self, cmdline):
-        self.hgcmd_txt.setText(hglib.tounicode('hg ' + ' '.join(cmdline)))
+        self.hgcmd_txt.setText('hg %s' % ' '.join(cmdline))
 
     def canRunCommand(self):
-        src, dest = self.get_src(), self.get_dest()
+        src, dest = self.source(), self.destination()
         return bool(src and dest and src != dest
                     and not (self.isCopyCommand()
                              and self.isCaseFoldingOnWin()))
 
     def runCommand(self):
         # check inputs
-        src = self.get_src()
-        dest = self.get_dest()
+        src, dest = self.source(), self.destination()
         if not os.path.exists(src):
             qtlib.WarningMsgBox(self.msgTitle, _('Source does not exists.'))
             return cmdcore.nullCmdSession()
         fullsrc = os.path.abspath(src)
-        if not fullsrc.startswith(self.repo.root):
+        if not fullsrc.startswith(self._repoagent.rootPath()):
             qtlib.ErrorMsgBox(self.errTitle,
                     _('The source must be within the repository tree.'))
             return cmdcore.nullCmdSession()
         fulldest = os.path.abspath(dest)
-        if not fulldest.startswith(self.repo.root):
+        if not fulldest.startswith(self._repoagent.rootPath()):
             qtlib.ErrorMsgBox(self.errTitle,
                     _('The destination must be within the repository tree.'))
             return cmdcore.nullCmdSession()
 
         cmdline = self.compose_command()
         self.show_command(cmdline)
-        cmdline = map(hglib.tounicode, cmdline)
         return self._repoagent.runCommand(cmdline, self)