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

hgqt: more pyqt signal cleanups

And bug fixes for rename guess dialog, though it is still
not finding renames for some reason inside Mercurial itself.

Changeset 09a9e2798934

Parent 4faad5f451e2

by Steve Borho

Changes to 6 files · Browse files at 09a9e2798934 Showing diff from parent 4faad5f451e2 Diff from another changeset...

 
147
148
149
150
 
151
152
153
 
180
181
182
 
183
184
185
 
187
188
189
190
191
192
 
 
 
193
194
195
 
353
354
355
356
 
357
358
359
360
361
362
 
363
364
365
 
370
371
372
373
 
374
375
376
 
377
378
379
380
 
381
382
383
 
386
387
388
 
 
 
389
390
391
 
406
407
408
409
410
 
411
412
 
413
414
415
416
417
418
419
 
420
421
422
423
424
 
 
425
426
427
428
429
430
 
443
444
445
446
 
447
448
449
450
451
452
453
 
454
455
456
 
147
148
149
 
150
151
152
153
 
180
181
182
183
184
185
186
 
188
189
190
 
 
 
191
192
193
194
195
196
 
354
355
356
 
357
358
359
360
361
362
 
363
364
365
366
 
371
372
373
 
374
375
376
 
377
378
379
380
 
381
382
383
384
 
387
388
389
390
391
392
393
394
395
 
410
411
412
 
 
413
414
 
415
416
417
418
419
420
421
 
422
423
424
425
 
 
426
427
428
429
 
430
431
432
 
445
446
447
 
448
449
450
451
452
453
454
 
455
456
457
458
@@ -147,7 +147,7 @@
  QTimer.singleShot(0, self.refresh)     def refresh(self): - repo.thginvalidate() + self.repo.thginvalidate()   wctx = self.repo[None]   wctx.status(unknown=True)   self.unrevlist.clear() @@ -180,6 +180,7 @@
  _('Select one or more rows for search'))   return   + self.repo.thginvalidate()   pct = self.simslider.value() / 100.0   copies = not self.copycheck.isChecked()   self.findbtn.setEnabled(False) @@ -187,9 +188,9 @@
    self.matchtv.model().clear()   self.thread = RenameSearchThread(self.repo, ulist, pct, copies) - self.connect(self.thread, SIGNAL('match'), self.rowReceived) - self.connect(self.thread, SIGNAL('progress'), self.progressReceived) - self.connect(self.thread, SIGNAL('error'), self.errorReceived) + self.thread.match.connect(self.rowReceived) + self.thread.progress.connect(self.progressReceived) + self.thread.error.connect(self.errorReceived)   self.thread.searchComplete.connect(self.finished)   self.thread.start()   @@ -353,13 +354,13 @@
  self.beginInsertRows(QModelIndex(), len(self.rows), len(self.rows))   self.rows.append(args)   self.endInsertRows() - self.emit(SIGNAL("dataChanged()")) + self.layoutChanged.emit()     def clear(self):   self.beginRemoveRows(QModelIndex(), 0, len(self.rows)-1)   self.rows = []   self.endRemoveRows() - self.emit(SIGNAL("dataChanged()")) + self.layoutChanged.emit()     def remove(self, dest):   i = 0 @@ -370,14 +371,14 @@
  self.endRemoveRows()   else:   i += 1 - self.emit(SIGNAL("dataChanged()")) + self.layoutChanged.emit()     def sort(self, col, order): - self.emit(SIGNAL("layoutAboutToBeChanged()")) + self.layoutAboutToBeChanged.emit()   self.rows.sort(lambda x, y: cmp(x[col], y[col]))   if order == Qt.DescendingOrder:   self.rows.reverse() - self.emit(SIGNAL("layoutChanged()")) + self.layoutChanged.emit()   self.reset()     def isEmpty(self): @@ -386,6 +387,9 @@
 class RenameSearchThread(QThread):   '''Background thread for searching repository history'''   searchComplete = pyqtSignal() + match = pyqtSignal(object) + progress = pyqtSignal(object) + error = pyqtSignal(object)     def __init__(self, repo, ufiles, minpct, copies):   super(RenameSearchThread, self).__init__() @@ -406,25 +410,23 @@
  else:   self.sig = QObject() # dummy object to emit signals   def progress(self, topic, pos, item='', unit='', total=None): - self.sig.emit(SIGNAL('progress'), - [topic, item, pos, total, unit]) + self.sig.emit("SIGNAL(progress)", [topic, item, pos, total, unit])   progui = ProgUi() - self.connect(progui.sig, SIGNAL('progress'), self.progress) + self.connect(progui.sig, SIGNAL('progress'), self.progressRecvd)   storeui = self.repo.ui   self.progui = progui   self.repo.ui = progui   try:   self.search(self.repo)   except Exception, e: - self.emit(SIGNAL('error'), hglib.tounicode(str(e))) + self.error.emit(hglib.tounicode(str(e)))   self.repo.ui = storeui   self.searchComplete.emit()   - def progress(self, wr): - self.emit(SIGNAL('progress'), wr) + def progressRecvd(self, wr): + self.progress.emit(wr)     def search(self, repo): - repo.thginvalidate()   wctx = repo[None]   pctx = repo['.']   if self.copies: @@ -443,14 +445,14 @@
  for o, n in gen:   old, new = o.path(), n.path()   exacts.append(old) - self.emit(SIGNAL('match'), [old, new, '100%']) + self.match.emit([old, new, '100%'])   if self.minpct == 1.0:   return   removed = [r for r in removed if r.path() not in exacts]   gen = similar._findsimilarmatches(repo, added, removed, self.minpct)   for o, n, s in gen:   old, new, sim = o.path(), n.path(), '%d%%' % (s*100) - self.emit(SIGNAL('match'), [old, new, sim]) + self.match.emit([old, new, sim])    def run(ui, *pats, **opts):   return DetectRenameDialog(None, None, *pats)
1
2
3
4
5
6
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
 
108
109
110
111
112
113
114
115
 
 
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
 
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
 
 
 
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
 
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
1
2
3
4
5
6
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
 
 
 
105
106
107
108
109
110
111
 
 
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
 
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
 
 
 
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
 
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
 # hgignore.py - TortoiseHg's dialog for editing .hgignore  #  # Copyright 2010 Steve Borho <steve@borho.org>  #  # This software may be used and distributed according to the terms of the  # GNU General Public License version 2, incorporated herein by reference.    import os  import re    from PyQt4.QtCore import *  from PyQt4.QtGui import *    from mercurial import hg, ui, match, util, error    from tortoisehg.hgqt.i18n import _  from tortoisehg.util import shlib, hglib, paths, thgrepo    from tortoisehg.hgqt import qtlib    class HgignoreDialog(QDialog):   'Edit a reposiory .hgignore file'     ignoreFilterUpdated = pyqtSignal()     def __init__(self, parent=None, root=None, *pats):   'Initialize the Dialog'   QDialog.__init__(self, parent)   self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)     try:   repo = thgrepo.repository(ui.ui(), path=paths.find_root(root))   except error.RepoError:   QDialog.reject(self)   return     self.repo = repo   self.pats = pats   self.setWindowTitle(_('Ignore filter - %s') % hglib.get_reponame(repo))     vbox = QVBoxLayout()   self.setLayout(vbox)     # layer 1   hbox = QHBoxLayout()   vbox.addLayout(hbox)   recombo = QComboBox()   recombo.addItems([_('Glob'), _('Regexp')])   hbox.addWidget(recombo)     le = QLineEdit()   hbox.addWidget(le, 1)   le.returnPressed.connect(self.addEntry)     add = QPushButton(_('Add'))   add.clicked.connect(self.addEntry)   hbox.addWidget(add, 0)     # layer 2   hbox = QHBoxLayout()   vbox.addLayout(hbox)   ignorefiles = [repo.wjoin('.hgignore')]   for name, value in repo.ui.configitems('ui'):   if name == 'ignore' or name.startswith('ignore.'):   ignorefiles.append(os.path.expanduser(value))     filecombo = QComboBox()   hbox.addWidget(filecombo)   for f in ignorefiles:   filecombo.addItem(hglib.tounicode(f))   filecombo.currentIndexChanged.connect(self.fileselect)   self.ignorefile = ignorefiles[0]     edit = QPushButton(_('Edit File'))   edit.clicked.connect(self.editClicked)   hbox.addWidget(edit)   hbox.addStretch(1)     # layer 3 - main widgets   split = QSplitter()   vbox.addWidget(split, 1)     ignoregb = QFrame()   ignoregb.setFrameStyle(QFrame.Panel|QFrame.Raised)   ivbox = QVBoxLayout()   ignoregb.setLayout(ivbox)   lbl = QLabel(_('<b>Ignore Filter</b>'))   ivbox.addWidget(lbl)   split.addWidget(ignoregb)     unknowngb = QFrame()   unknowngb.setFrameStyle(QFrame.Panel|QFrame.Raised)   uvbox = QVBoxLayout()   unknowngb.setLayout(uvbox)   lbl = QLabel(_('<b>Untracked Files</b>'))   uvbox.addWidget(lbl)   split.addWidget(unknowngb)     ignorelist = QListWidget()   ivbox.addWidget(ignorelist)   unknownlist = QListWidget()   uvbox.addWidget(unknownlist)   unknownlist.currentTextChanged.connect(self.setGlobFilter)   unknownlist.setContextMenuPolicy(Qt.CustomContextMenu) - self.connect(unknownlist, - SIGNAL('customContextMenuRequested(const QPoint &)'), - self.customContextMenuRequested) + unknownlist.customContextMenuRequested.connect(self.menuRequest)   lbl = QLabel(_('Backspace or Del to remove a row'))   ivbox.addWidget(lbl)     # layer 4 - dialog buttons   BB = QDialogButtonBox   bb = QDialogButtonBox(BB.Close) - self.connect(bb, SIGNAL("accepted()"), self, SLOT("accept()")) - self.connect(bb, SIGNAL("rejected()"), self, SLOT("reject()")) + bb.accepted.connect(self.accept) + bb.rejected.connect(self.reject)   vbox.addWidget(bb)   self.bb = bb     le.setFocus()   self.le, self.recombo, self.filecombo = le, recombo, filecombo   self.ignorelist, self.unknownlist = ignorelist, unknownlist   ignorelist.installEventFilter(self)   QTimer.singleShot(0, self.refresh)     s = QSettings()   self.restoreGeometry(s.value('hgignore/geom').toByteArray())     def eventFilter(self, obj, event):   if obj != self.ignorelist:   return False   if event.type() != QEvent.KeyPress:   return False   elif event.key() not in (Qt.Key_Backspace, Qt.Key_Delete):   return False   row = obj.currentRow()   if row < 0:   return False   self.ignorelines.pop(row)   self.writeIgnoreFile()   self.refresh()   return True   - def customContextMenuRequested(self, point): + def menuRequest(self, point):   'context menu request for unknown list'   point = self.unknownlist.mapToGlobal(point)   row = self.unknownlist.currentRow()   if row < 0:   return   local = self.lclunknowns[row]   menu = QMenu(self)   menu.setTitle(_('Add ignore filter...'))   filters = [local]   base, ext = os.path.splitext(local)   if ext:   filters.append('*'+ext)   dirname = os.path.dirname(local)   while dirname:   filters.append(dirname)   dirname = os.path.dirname(dirname)   for f in filters:   action = menu.addAction(_('Ignore ') + hglib.tounicode(f)) - action.localtext = f - action.wrapper = lambda f=f: self.insertFilter(f, False) - self.connect(action, SIGNAL('triggered()'), action.wrapper) + action.args = (f,False) + action.run = lambda: self.insertFilter(*action.args) + action.triggered.connect(action.run)   menu.exec_(point)     def insertFilter(self, pat, isregexp):   h = isregexp and 'syntax: regexp' or 'syntax: glob'   if h in self.ignorelines:   l = self.ignorelines.index(h)   for i, line in enumerate(self.ignorelines[l+1:]):   if line.startswith('syntax:'):   self.ignorelines.insert(l+i+1, pat)   break   else:   self.ignorelines.append(pat)   else:   self.ignorelines.append(h)   self.ignorelines.append(pat)   self.writeIgnoreFile()   self.refresh()     def setGlobFilter(self, qstr):   'user selected an unknown file; prep a glob filter'   self.recombo.setCurrentIndex(0)   self.le.setText(qstr)     def fileselect(self):   'user selected another ignore file'   self.ignorefile = hglib.fromunicode(self.filecombo.currentText())   self.refresh()     def editClicked(self):   if qtlib.fileEditor(self.ignorefile) == QDialog.Accepted:   self.refresh()     def addEntry(self):   newfilter = hglib.fromunicode(self.le.text()).strip()   if newfilter == '':   return   if self.recombo.currentIndex() == 0:   test = 'glob:' + newfilter   try:   match.match(self.repo.root, '', [], [test])   self.insertFilter(newfilter, False)   except util.Abort, inst:   qtlib.WarningMsgBox(_('Invalid glob expression'), str(inst),   parent=self)   return   else:   test = 'relre:' + newfilter   try:   match.match(self.repo.root, '', [], [test])   re.compile(test)   self.insertFilter(newfilter, True)   except (util.Abort, re.error), inst:   qtlib.WarningMsgBox(_('Invalid regexp expression'), str(inst),   parent=self)   return   self.le.clear()     def refresh(self):   uni = hglib.tounicode   try:   self.repo.thginvalidate()   wctx = self.repo[None]   wctx.status(unknown=True)   except (util.Abort, error.RepoError), e:   qtlib.WarningMsgBox(_('Unable to read repository status'),   uni(str(e)), parent=self)   return     self.lclunknowns = wctx.unknown()   self.unknownlist.clear()   self.unknownlist.addItems([uni(u) for u in self.lclunknowns])   for i, u in enumerate(self.lclunknowns):   if u in self.pats:   item = self.unknownlist.item(i)   self.unknownlist.setItemSelected(item, True)   self.unknownlist.setCurrentItem(item)   # single selection only   break     try:   l = open(self.ignorefile, 'rb').readlines()   self.doseoln = l[0].endswith('\r\n')   except (IOError, ValueError, IndexError):   self.doseoln = os.name == 'nt'   l = []   self.ignorelines = [line.strip() for line in l]   self.ignorelist.clear()   self.ignorelist.addItems([uni(l) for l in self.ignorelines])     def writeIgnoreFile(self):   eol = self.doseoln and '\r\n' or '\n'   out = eol.join(self.ignorelines) + eol     try:   f = util.atomictempfile(self.ignorefile, 'wb', createmode=None)   f.write(out)   f.rename()   shlib.shell_notify([self.ignorefile]) - self.emit(SIGNAL('ignoreFilterUpdated')) + self.ignoreFilterUpdated.emit()   except IOError, e:   qtlib.WarningMsgBox(_('Unable to write .hgignore file'),   hglib.tounicode(str(e)), parent=self)     def accept(self):   s = QSettings()   s.setValue('hgignore/geom', self.saveGeometry())   QDialog.accept(self)     def reject(self):   s = QSettings()   s.setValue('hgignore/geom', self.saveGeometry())   QDialog.reject(self)    def run(_ui, *pats, **opts):   if pats and pats[0].endswith('.hgignore'):   pats = []   return HgignoreDialog(None, None, *pats)
 
61
62
63
64
65
 
 
66
67
68
 
61
62
63
 
 
64
65
66
67
68
@@ -61,8 +61,8 @@
  BB = QDialogButtonBox   bb = QDialogButtonBox(BB.Ok|BB.Cancel)   self.apply_button = bb.button(BB.Apply) - self.connect(bb, SIGNAL("accepted()"), self, SLOT("accept()")) - self.connect(bb, SIGNAL("rejected()"), self, SLOT("reject()")) + bb.accepted.connect(self.accept) + bb.rejected.connect(self.reject)   bb.button(BB.Ok).setDefault(True)   layout.addWidget(bb)  
 
254
255
256
257
 
258
259
260
 
466
467
468
469
470
471
472
 
 
473
474
475
 
254
255
256
 
257
258
259
260
 
466
467
468
 
 
 
 
469
470
471
472
473
@@ -254,7 +254,7 @@
  def keyPressEvent(self, event):   for k, btn in self.hotkeys.iteritems():   if event.text() == k: - btn.emit(SIGNAL('clicked()')) + btn.clicked.emit()   super(CustomPrompt, self).keyPressEvent(event)    def setup_font_substitutions(): @@ -466,10 +466,8 @@
  vbox.addWidget(editor)   BB = QDialogButtonBox   bb = QDialogButtonBox(BB.Save|BB.Cancel) - dialog.connect(bb, SIGNAL('accepted()'), - dialog, SLOT('accept()')) - dialog.connect(bb, SIGNAL('rejected()'), - dialog, SLOT('reject()')) + bb.accepted.connect(dialog.accept) + bb.rejected.connect(dialog.reject)   vbox.addWidget(bb)   lexer = QsciLexerProperties()   editor.setLexer(lexer)
 
132
133
134
135
 
136
137
138
 
152
153
154
155
 
156
157
158
159
160
 
161
162
163
 
423
424
425
426
 
427
428
429
 
132
133
134
 
135
136
137
138
 
152
153
154
 
155
156
157
158
159
 
160
161
162
163
 
423
424
425
 
426
427
428
429
@@ -132,7 +132,7 @@
  branch=branch, allparents=allparents)   self.graph = Graph(self.repo, grapher, self.max_file_size, include_mq=True)   self.rowcount = 0 - self.emit(SIGNAL('layoutChanged()')) + self.layoutChanged.emit()   self.ensureBuilt(row=self.fill_step)   self.showMessage.emit('')   QTimer.singleShot(0, lambda: self.filled.emit()) @@ -152,12 +152,12 @@
  if validcols:   self._columns = tuple(validcols)   self.datacache = {} - self.emit(SIGNAL("layoutChanged()")) + self.layoutChanged.emit()     def invalidate(self):   self.reloadConfig()   self.datacache = {} - self.emit(SIGNAL("layoutChanged()")) + self.layoutChanged.emit()     def branch(self):   return self.filterbranch @@ -423,7 +423,7 @@
  'empty the list'   self.graph = None   self.datacache = {} - self.emit(SIGNAL("layoutChanged()")) + self.layoutChanged.emit()     def gettags(self, ctx, gnode):   if ctx.rev() is None:
 
533
534
535
536
537
 
 
538
539
540
 
533
534
535
 
 
536
537
538
539
540
@@ -533,8 +533,8 @@
    BB = QDialogButtonBox   bb = QDialogButtonBox(BB.Ok|BB.Cancel) - self.connect(bb, SIGNAL("accepted()"), self, SLOT("accept()")) - self.connect(bb, SIGNAL("rejected()"), self, SLOT("reject()")) + bb.accepted.connect(self.accept) + bb.rejected.connect(self.reject)   layout.addWidget(bb)   self.bb = bb