Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.0.4, 2.0.5, and 2.1

stable rename: show unicode filename correctly (fixes #614)

Also removed usage of os.path.relpath(), which is incompatible with Python<2.6.

Changeset 91a9e11f8677

Parent 0b0af862ba51

by Yuya Nishihara

Changes to one file · Browse files at 91a9e11f8677 Showing diff from parent 0b0af862ba51 Diff from another changeset...

 
27
28
29
 
30
31
32
 
49
50
51
52
 
53
54
55
56
 
57
58
59
 
196
197
198
199
 
200
201
202
203
204
205
206
207
 
 
 
 
 
 
208
209
 
210
211
 
212
213
214
 
234
235
236
237
 
238
239
240
 
242
243
244
245
246
247
248
249
250
251
 
273
274
275
276
277
278
279
 
284
285
286
287
 
288
289
290
 
27
28
29
30
31
32
33
 
50
51
52
 
53
54
55
56
 
57
58
59
60
 
197
198
199
 
200
201
 
202
203
204
 
 
 
205
206
207
208
209
210
211
 
212
213
 
214
215
216
217
 
237
238
239
 
240
241
242
243
 
245
246
247
 
 
 
 
248
249
250
 
272
273
274
 
275
276
277
 
282
283
284
 
285
286
287
288
@@ -27,6 +27,7 @@
  def __init__(self, ui, pats, parent=None, **opts):   super(RenameDialog, self).__init__(parent)   self.iscopy = (opts.get('alias') == 'copy') + # pats: local; src, dest: unicode   src, dest = self.init_data(ui, pats)   self.init_view(src, dest)   @@ -49,11 +50,11 @@
  except:   pass   os.chdir(self.root) - fname = util.normpath(fname) + fname = hglib.tounicode(util.normpath(fname))   if target:   target = hglib.tounicode(util.normpath(target))   else: - target = hglib.tounicode(fname) + target = fname   return (fname, target)     def init_view(self, src, dest): @@ -196,19 +197,21 @@
  caption = _('Select Destination Folder')   FD = QFileDialog   if os.path.isfile(curr): - filename = FD.getOpenFileName(parent=self, caption=caption, + path = FD.getOpenFileName(parent=self, caption=caption,   options=FD.ReadOnly) - response = hglib.fromunicode(filename)   else:   path = FD.getExistingDirectory(parent=self, caption=caption,   options=FD.ShowDirsOnly | FD.ReadOnly) - response = hglib.fromunicode(path) - if response: - response = os.path.relpath(response, start=self.root) + if path: + path = util.normpath(unicode(path)) + pathprefix = util.normpath(hglib.tounicode(self.root)) + '/' + if not path.startswith(pathprefix): + return + relpath = path[len(pathprefix):]   if mode == 'src': - self.src_txt.setText(response) + self.src_txt.setText(relpath)   else: - self.dest_txt.setText(response) + self.dest_txt.setText(relpath)     def copy_chk_toggled(self):   self.setRenameCopy() @@ -234,7 +237,7 @@
  return cmdline     def show_command(self, cmdline): - self.hgcmd_txt.setText('hg ' + ' '.join(cmdline)) + self.hgcmd_txt.setText(hglib.tounicode('hg ' + ' '.join(cmdline)))     def rename(self):   """execute the rename""" @@ -242,10 +245,6 @@
  # check inputs   src = self.get_src()   dest = self.get_dest() - curr_name = os.path.relpath(src, start=self.root) - self.src_txt.setText(curr_name) - new_name = os.path.relpath(dest, start=self.root) - self.dest_txt.setText(new_name)   if not os.path.exists(src):   qtlib.WarningMsgBox(self.msgTitle, _('Source does not exists.'))   return @@ -273,7 +272,6 @@
    cmdline = self.compose_command(src, dest)   self.show_command(cmdline) - new_name = util.canonpath(self.root, self.root, new_name)   if self.isCaseFoldingOnWin():   # We do the rename ourselves if it's a pure casefolding   # action on Windows. Because there is no way to make Hg @@ -284,7 +282,7 @@
  return   else:   try: - targetdir = os.path.dirname(new_name) or '.' + targetdir = os.path.dirname(dest)   if not os.path.isdir(targetdir):   os.makedirs(targetdir)   os.rename(fullsrc, fulldest)