Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

rename: take care of Steve's remarks

let Hg do all the work for copies (--after=False),
but do the moves ourselves (--after==True)

Changeset 6c9ce121647d

Parent 8bf01e9375ab

by Johan Samyn

Changes to one file · Browse files at 6c9ce121647d Showing diff from parent 8bf01e9375ab Diff from another changeset...

 
7
8
9
10
11
12
13
 
14
15
16
17
18
19
20
21
22
 
23
24
25
26
27
28
 
 
29
30
31
 
48
49
50
51
 
52
53
54
 
194
195
196
197
 
198
199
200
201
202
 
203
204
205
 
212
213
214
 
215
216
217
 
218
219
 
220
221
222
 
230
231
232
233
 
234
235
236
 
282
283
284
285
286
287
288
289
290
 
291
292
293
294
295
296
297
 
298
299
300
 
301
302
303
 
304
305
306
 
7
8
9
 
 
 
 
10
11
12
13
14
 
 
 
 
 
15
16
17
 
 
 
 
18
19
20
21
22
 
39
40
41
 
42
43
44
45
 
185
186
187
 
188
189
190
191
192
 
193
194
195
196
 
203
204
205
206
207
208
209
210
211
212
213
214
215
216
 
224
225
226
 
227
228
229
230
 
276
277
278
 
 
 
 
 
 
279
280
281
282
283
284
285
 
286
287
288
 
289
290
291
 
292
293
294
295
@@ -7,25 +7,16 @@
 # GNU General Public License version 2, incorporated herein by reference.     -import os -import sys -import cStringIO -import shutil +import os, sys, cStringIO, shutil    from PyQt4.QtCore import *  from PyQt4.QtGui import *   -from mercurial import hg -from mercurial import ui -from mercurial import util -from mercurial import commands -from mercurial import error +from mercurial import hg, ui, util, commands, error    from tortoisehg.hgqt.i18n import _ -from tortoisehg.hgqt import cmdui -from tortoisehg.hgqt import qtlib -from tortoisehg.util import hglib -from tortoisehg.util import paths +from tortoisehg.hgqt import cmdui, qtlib +from tortoisehg.util import hglib, paths      class RenameDialog(QDialog): @@ -48,7 +39,7 @@
  try:   self.root = paths.find_root()   self.repo = hg.repository(ui, self.root) - except (ImportError, error.RepoError): + except (error.RepoError):   qtlib.ErrorMsgBox(_('Rename Error'),   _('Could not find or initialize the repository'   ' from folder<p>%s</p>' % cwd)) @@ -194,12 +185,12 @@
  filter = 'All Files (*.*)'   filename = FD.getOpenFileName(parent=self, caption=caption,   options=FD.ReadOnly) - response = str(filename) + response = hglib.fromunicode(filename)   else:   caption = _('Select %s Folder' % capt)   path = FD.getExistingDirectory(parent=self, caption=caption,   options=FD.ShowDirsOnly | FD.ReadOnly) - response = str(path) + response = hglib.fromunicode(path)   if response:   response = os.path.relpath(response, start=self.root)   if mode == 'src': @@ -212,11 +203,14 @@
  if self.copy_chk.isChecked():   sw = self.wintitle.replace(_('Rename'), _('Copy'))   sb = self.rename_btn_txt.replace(_('Rename'), _('Copy')) + self.opts['after'] = False   else:   sw = self.wintitle.replace(_('Copy'), _('Rename'))   sb = self.rename_btn_txt.replace(_('Copy'), _('Rename')) + self.opts['after'] = True   self.setWindowTitle(sw)   self.rename_btn.setText(sb) + self.show_command(self.compose_command(self.get_src(), self.get_dest()))     def compose_command(self, src, dest):   cmdline = ['rename'] @@ -230,7 +224,7 @@
  vcmdline.append(hglib.fromunicode(src))   vcmdline.append(hglib.fromunicode(dest))   vcmdline = ' '.join(vcmdline) - return cmdline, vcmdline + return (cmdline, vcmdline)     def show_command(self, clinfo):   cl, vcl = clinfo @@ -282,25 +276,20 @@
  if not os.path.isdir(targetdir):   os.makedirs(targetdir)   if self.copy_chk.isChecked(): - if os.path.isfile(curr_name): - shutil.copy(curr_name, new_name) - else: - shutil.copytree(curr_name, new_name) - addopts = {} - commands.add(self.repo.ui, self.repo, new_name, **addopts) + commands.copy(self.repo.ui, self.repo, curr_name, new_name, **opts)   else:   shutil.move(curr_name, new_name)   commands.rename(self.repo.ui, self.repo, curr_name, new_name, **opts)   except (OSError, IOError, util.Abort, error.RepoError), inst:   qtlib.ErrorMsgBox(_('Rename Error'),   _('The following erorr was caught with rename :'), - str(inst)) + hglib.tounicode(inst))   finally:   sys.stderr = saved - textout = errors.getvalue() + self.repo.ui.popbuffer() + textout = hglib.tounicode(errors.getvalue() + self.repo.ui.popbuffer())   errors.close()   if len(textout) > 1: - qtlib.ErrorMsgBox(_('rename error'), textout) + qtlib.ErrorMsgBox(_('Rename Error'), textout)     def detail_clicked(self):   if self.cmd.is_show_output():