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

Merge with stable

Changeset be86dd9c982b

Parents b3d899faedb1

Parents e38f83200e70

by Steve Borho

Changes to 4 files · Browse files at be86dd9c982b Showing diff from parent b3d899faedb1 e38f83200e70 Diff from another changeset...

 
403
404
405
 
 
 
 
 
 
 
 
 
 
 
406
407
408
 
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
@@ -403,6 +403,17 @@
  self.setCursorPosition(self.lines() - 1, len(self._prompt))   self.setReadOnly(False)   + # make sure the prompt line is visible. Because QsciScintilla may + # delay line wrapping, setCursorPosition() doesn't always scrolls + # to the correct position. + # http://www.scintilla.org/ScintillaDoc.html#LineWrapping + self.SCN_PAINTED.connect(self._scrollCaretOnPainted) + + @pyqtSlot() + def _scrollCaretOnPainted(self): + self.SCN_PAINTED.disconnect(self._scrollCaretOnPainted) + self.SendScintilla(self.SCI_SCROLLCARET) +   @pyqtSlot()   def closePrompt(self):   """Disable user input"""
 
175
176
177
178
 
179
180
181
 
175
176
177
 
178
179
180
181
@@ -175,7 +175,7 @@
  _('Unable to create new repository'),   hglib.tounicode(str(inst)))   return False - except util.Abort, inst: + except util.Abort, e:   if e.hint:   err = _('%s (hint: %s)') % (hglib.tounicode(str(e)),   hglib.tounicode(e.hint))
 
27
28
29
30
 
31
32
33
 
47
48
49
50
 
51
52
53
 
372
373
374
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
28
29
 
30
31
32
33
 
47
48
49
 
50
51
52
53
 
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
@@ -27,7 +27,7 @@
  StatusRole = Qt.UserRole + 1   """Role for file change status"""   - def __init__(self, repo, rev, statusfilter='MASC', parent=None): + def __init__(self, repo, rev=None, statusfilter='MASC', parent=None):   QAbstractItemModel.__init__(self, parent)     self._repo = repo @@ -47,7 +47,7 @@
  return self.fileStatus(index)     e = index.internalPointer() - if role == Qt.DisplayRole: + if role in (Qt.DisplayRole, Qt.EditRole):   return e.name     def filePath(self, index): @@ -372,3 +372,27 @@
  self._nameindex.sort(   key=lambda s: '%s%s' % (self[s] and 'D' or 'F', s),   reverse=reverse) + +class ManifestCompleter(QCompleter): + """QCompleter for ManifestModel""" + + def splitPath(self, path): + """ + >>> c = ManifestCompleter() + >>> c.splitPath(QString('foo/bar')) + [u'foo', u'bar'] + + trailing slash appends extra '', so that QCompleter can descend to + next level: + >>> c.splitPath(QString('foo/')) + [u'foo', u''] + """ + return unicode(path).split('/') + + def pathFromIndex(self, index): + if not index.isValid(): + return '' + m = self.model() + if not m: + return '' + return m.filePath(index)
 
11
12
13
14
 
15
16
17
 
18
19
20
 
25
26
27
28
 
29
30
31
 
32
33
34
 
51
52
53
54
 
55
56
57
58
 
59
60
61
 
66
67
68
69
 
70
71
72
73
 
74
75
 
 
 
 
 
76
77
78
 
106
107
108
109
 
110
111
 
112
113
114
115
116
 
117
118
119
 
197
198
199
200
201
 
202
203
204
205
206
207
208
209
 
 
 
 
 
 
210
211
 
212
213
214
 
215
216
217
 
234
235
236
237
238
 
239
240
241
242
 
 
243
244
245
 
247
248
249
250
251
252
253
254
255
256
 
276
277
278
279
280
281
 
 
282
283
284
 
289
290
291
292
 
293
294
295
 
309
310
311
312
 
313
314
315
 
11
12
13
 
14
15
16
 
17
18
19
20
 
25
26
27
 
28
29
 
 
30
31
32
33
 
50
51
52
 
53
54
55
56
 
57
58
59
60
 
65
66
67
 
68
69
70
71
 
72
73
74
75
76
77
78
79
80
81
82
 
110
111
112
 
113
114
 
115
116
117
118
119
120
121
122
123
124
 
202
203
204
 
 
205
206
 
207
208
209
 
 
 
210
211
212
213
214
215
216
 
217
218
 
 
219
220
221
222
 
239
240
241
 
 
242
243
 
 
 
244
245
246
247
248
 
250
251
252
 
 
 
 
253
254
255
 
275
276
277
 
 
 
278
279
280
281
282
 
287
288
289
 
290
291
292
293
 
307
308
309
 
310
311
312
313
@@ -11,10 +11,10 @@
 from PyQt4.QtCore import *  from PyQt4.QtGui import *   -from mercurial import hg, ui, util, error +from mercurial import util, error    from tortoisehg.hgqt.i18n import _ -from tortoisehg.hgqt import cmdui, qtlib, thgrepo +from tortoisehg.hgqt import cmdui, qtlib, thgrepo, manifestmodel  from tortoisehg.util import hglib, paths    class RenameDialog(QDialog): @@ -25,10 +25,9 @@
  progress = pyqtSignal(QString, object, QString, QString, object)     def __init__(self, ui, pats, parent=None, **opts): - super(RenameDialog, self).__init__(parent=None) + super(RenameDialog, self).__init__(parent)   self.iscopy = (opts.get('alias') == 'copy') - src = '' - dest = '' + # pats: local; src, dest: unicode   src, dest = self.init_data(ui, pats)   self.init_view(src, dest)   @@ -51,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): @@ -66,13 +65,18 @@
  self.src_lbl.setAlignment(Qt.AlignRight|Qt.AlignVCenter)   self.src_txt = QLineEdit(src)   self.src_txt.setMinimumWidth(300) - self.src_btn = QPushButton(_('Browse')) + self.src_btn = QPushButton(_('Browse...'))   self.dest_lbl = QLabel(_('Destination:'))   self.dest_lbl.setAlignment(Qt.AlignRight|Qt.AlignVCenter)   self.dest_txt = QLineEdit(dest) - self.dest_btn = QPushButton(_('Browse')) + self.dest_btn = QPushButton(_('Browse...'))   self.copy_chk = QCheckBox(_('Copy source -> destination'))   + comp = manifestmodel.ManifestCompleter(self) + comp.setModel(manifestmodel.ManifestModel(self.repo, parent=comp)) + self.src_txt.setCompleter(comp) + self.dest_txt.setCompleter(comp) +   # some extras   self.dummy_lbl = QLabel('')   self.hgcmd_lbl = QLabel(_('Hg command:')) @@ -106,14 +110,15 @@
  self.cancel_btn.setHidden(True)     # connecting slots - self.src_txt.textEdited.connect(self.src_dest_edited) + self.src_txt.textChanged.connect(self.src_dest_edited)   self.src_btn.clicked.connect(self.src_btn_clicked) - self.dest_txt.textEdited.connect(self.src_dest_edited) + self.dest_txt.textChanged.connect(self.src_dest_edited)   self.dest_btn.clicked.connect(self.dest_btn_clicked)   self.copy_chk.toggled.connect(self.copy_chk_toggled)   self.rename_btn.clicked.connect(self.rename)   self.detail_btn.clicked.connect(self.detail_clicked)   self.close_btn.clicked.connect(self.close) + self.cancel_btn.clicked.connect(self.cancel_clicked)     # main layout   self.grid = QGridLayout() @@ -197,21 +202,21 @@
  caption = _('Select Destination Folder')   FD = QFileDialog   if os.path.isfile(curr): - filter = 'All Files (*.*)' - 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.compose_command(self.get_src(), self.get_dest()) + self.dest_txt.setText(relpath)     def copy_chk_toggled(self):   self.setRenameCopy() @@ -234,12 +239,10 @@
  cmdline.append('-A')   cmdline.append(src)   cmdline.append(dest) - vcmdline = ' '.join(['hg'] + cmdline) - return (cmdline, vcmdline) + return cmdline   - def show_command(self, clinfo): - cl, vcl = clinfo - self.hgcmd_txt.setText(vcl) + def show_command(self, cmdline): + self.hgcmd_txt.setText(hglib.tounicode('hg ' + ' '.join(cmdline)))     def rename(self):   """execute the rename""" @@ -247,10 +250,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 @@ -276,9 +275,8 @@
  if not res:   return   - cmdline, vcl = self.compose_command(src, dest) - self.show_command((cmdline, vcl)) - new_name = hglib.canonpath(self.root, self.root, new_name) + cmdline = self.compose_command(src, dest) + self.show_command(cmdline)   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 @@ -289,7 +287,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) @@ -309,7 +307,7 @@
  else:   self.cmd.setShowOutput(True)   - def cancel_clicked(): + def cancel_clicked(self):   self.cmd.cancel()     def command_started(self):