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

status: make wctx refresh a threaded function

Changeset 26553de702b5

Parent c9295981642d

by Steve Borho

Changes to one file · Browse files at 26553de702b5 Showing diff from parent c9295981642d Diff from another changeset...

 
21
22
23
24
25
26
27
 
43
44
45
46
47
48
 
 
 
 
49
50
51
 
61
62
63
 
64
65
66
 
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
 
270
271
272
273
274
275
276
 
380
381
382
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
384
385
 
21
22
23
 
24
25
26
 
42
43
44
 
 
 
45
46
47
48
49
50
51
 
61
62
63
64
65
66
67
 
214
215
216
217
218
219
 
220
221
222
223
224
225
226
227
228
229
230
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
232
233
234
235
236
237
 
255
256
257
 
258
259
260
 
364
365
366
367
368
369
370
371
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
399
400
401
402
403
404
405
406
407
408
409
410
411
@@ -21,7 +21,6 @@
   # Technical Debt  # We need a real icon set for file status types -# Thread refreshWctx, connect to an external progress bar  # Thread rowSelected, connect to an external progress bar  # Show subrepos better  # Chunk selection @@ -43,9 +42,10 @@
 class StatusWidget(QWidget):   '''Working copy status widget   SIGNALS: - loadComplete() - errorMessage(QString) - titleTextChanged(QString) + loadBegin() - for progress bar + loadComplete() - for progress bar + errorMessage(QString) - for status bar + titleTextChanged(QString) - for window title   '''   def __init__(self, pats, opts, root=None, parent=None):   QWidget.__init__(self, parent) @@ -61,6 +61,7 @@
  self.ms = {}   self.curRow = None   self.patchecked = {} + self.refreshing = None     # determine the user configured status colors   # (in the future, we could support full rich-text tags) @@ -213,40 +214,24 @@
  return super(StatusWidget, self).keyPressEvent(event)     def refreshWctx(self): + if self.refreshing: + return   self.te.clear() - hglib.invalidaterepo(self.repo) + self.fnamelabel.clear() + self.emit(SIGNAL('loadBegin()')) + self.refreshing = StatusThread(self.repo, self.pats, self.opts) + self.connect(self.refreshing, SIGNAL('finished'), self.reloadComplete) + # re-emit error messages from this object + self.connect(self.refreshing, SIGNAL('errorMessage'), + lambda msg: self.emit(SIGNAL('errorMessage'), msg)) + self.refreshing.start() + + def reloadComplete(self, wctx):   self.ms = merge.mergestate(self.repo) - extract = lambda x, y: dict(zip(x, map(y.get, x))) - stopts = extract(('unknown', 'ignored', 'clean'), self.opts) - try: - if self.pats: - m = cmdutil.match(self.repo, self.pats) - status = self.repo.status(match=m, **stopts) - # Record all matched files as initially checked - for i, stat in enumerate(StatusType.preferredOrder): - if stat == 'S': - continue - val = statusTypes[stat] - if self.opts[val.name]: - d = dict([(fn, True) for fn in status[i]]) - self.patchecked.update(d) - wctx = context.workingctx(self.repo, changes=status) - else: - wctx = self.repo[None] - wctx.status(**stopts) - except (OSError, IOError, util.Abort), e: - err = hglib.tounicode(e) - self.emit(SIGNAL('errorMessage'), QString(err)) - try: - wctx.dirtySubrepos = [] - for s in wctx.substate: - if wctx.sub(s).dirty(): - wctx.dirtySubrepos.append(s) - except (OSError, IOError, util.Abort, error.ConfigError), e: - err = hglib.tounicode(e) - self.emit(SIGNAL('errorMessage'), QString(err))   self.wctx = wctx   self.updateModel() + self.emit(SIGNAL('loadComplete()')) + self.refreshing = None     def updateModel(self):   self.tv.setSortingEnabled(False) @@ -270,7 +255,6 @@
  self.connect(self.le, SIGNAL('textEdited(QString)'), tm.setFilter)   self.connect(tm, SIGNAL('checkToggled()'), self.updateCheckCount)   self.updateCheckCount() - self.emit(SIGNAL('loadComplete()'))     def updateCheckCount(self):   text = _('Checkmarked file count: %d') % len(self.getChecked()) @@ -380,6 +364,48 @@
  self.te.setHtml(text + diff)     +class StatusThread(QThread): + '''Background thread for generating a workingctx''' + def __init__(self, repo, pats, opts, parent=None): + super(StatusThread, self).__init__() + self.repo = repo + self.pats = pats + self.opts = opts + + def run(self): + hglib.invalidaterepo(self.repo) + extract = lambda x, y: dict(zip(x, map(y.get, x))) + stopts = extract(('unknown', 'ignored', 'clean'), self.opts) + try: + if self.pats: + m = cmdutil.match(self.repo, self.pats) + status = self.repo.status(match=m, **stopts) + # Record all matched files as initially checked + for i, stat in enumerate(StatusType.preferredOrder): + if stat == 'S': + continue + val = statusTypes[stat] + if self.opts[val.name]: + d = dict([(fn, True) for fn in status[i]]) + self.patchecked.update(d) + wctx = context.workingctx(self.repo, changes=status) + else: + wctx = self.repo[None] + wctx.status(**stopts) + except (OSError, IOError, util.Abort), e: + err = hglib.tounicode(e) + self.emit(SIGNAL('errorMessage'), QString(err)) + try: + wctx.dirtySubrepos = [] + for s in wctx.substate: + if wctx.sub(s).dirty(): + wctx.dirtySubrepos.append(s) + except (OSError, IOError, util.Abort, error.ConfigError), e: + err = hglib.tounicode(e) + self.emit(SIGNAL('errorMessage'), QString(err)) + self.emit(SIGNAL('finished'), wctx) + +  class WctxFileTree(QTreeView):   def __init__(self, repo, parent=None):   QTreeView.__init__(self, parent)