Commits

Yuya Nishihara  committed bc1036e

rename: move path normalization to command layer

canonpath() is only necessary if RenameDialog is called from run module.
wctxactions specifies canonical paths.

  • Participants
  • Parent commits e1c5d73

Comments (0)

Files changed (3)

File tortoisehg/hgqt/rename.py

 from tortoisehg.hgqt import cmdcore, cmdui, qtlib, manifestmodel
 from tortoisehg.util import hglib
 
-# TODO: this should be done by the caller of RenameDialog
-def _mapcanonpath(root, pats):
-    fname = ''
-    target = ''
-    cwd = os.getcwd()
-    if pats[0]:
-        fname = hglib.canonpath(root, cwd, pats[0])
-    if pats[1]:
-        target = hglib.canonpath(root, cwd, pats[1])
-    fname = hglib.tounicode(util.normpath(fname))
-    if target:
-        target = hglib.tounicode(util.normpath(target))
-    else:
-        target = fname
-    return (fname, target)
-
-
 class RenameWidget(cmdui.AbstractCmdWidget):
 
     def __init__(self, repoagent, parent=None, source=None, destination=None,
                  iscopy=False):
         super(RenameWidget, self).__init__(parent)
         self._repoagent = repoagent
-        # pats: local; src, dest: unicode
-        src, dest = _mapcanonpath(self.repo.root, [source, destination])
 
         form = QFormLayout()
         form.setContentsMargins(0, 0, 0, 0)
         self.setLayout(form)
 
         # widgets
-        self.src_txt = QLineEdit(src)
+        self.src_txt = QLineEdit(source or '')
         self.src_txt.setMinimumWidth(300)
         self.src_btn = QPushButton(_('Browse...'))
-        self.dest_txt = QLineEdit(dest)
+        self.dest_txt = QLineEdit(destination or source or '')
         self.dest_btn = QPushButton(_('Browse...'))
         comp = manifestmodel.ManifestCompleter(self)
         comp.setModel(manifestmodel.ManifestModel(self.repo, parent=comp))

File tortoisehg/hgqt/run.py

     from tortoisehg.hgqt import rename as renamemod
     if len(pats) > 2:
         raise util.Abort(_('too many files specified'))
+    pats = map(hglib.tounicode, hglib.canonpaths(pats))
     iscopy = (opts.get('alias') == 'copy')
     return renamemod.RenameDialog(repoagent, None, *pats, iscopy=iscopy)
 

File tortoisehg/hgqt/wctxactions.py

 def copy(parent, repoagent, files):
     from tortoisehg.hgqt.rename import RenameDialog
     assert len(files) == 1
-    dlg = RenameDialog(repoagent, parent, files[0], iscopy=True)
+    dlg = RenameDialog(repoagent, parent, hglib.tounicode(files[0]),
+                       iscopy=True)
     dlg.finished.connect(dlg.deleteLater)
     dlg.exec_()
     return True
 def rename(parent, repoagent, files):
     from tortoisehg.hgqt.rename import RenameDialog
     assert len(files) == 1
-    dlg = RenameDialog(repoagent, parent, files[0])
+    dlg = RenameDialog(repoagent, parent, hglib.tounicode(files[0]))
     dlg.finished.connect(dlg.deleteLater)
     dlg.exec_()
     return True