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

purge: move wctx.status() to a thread, improve user interface

Changeset 03a5ab2848fc

Parent ba00e790bc52

by Steve Borho

Changes to 2 files · Browse files at 03a5ab2848fc Showing diff from parent ba00e790bc52 Diff from another changeset...

 
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
 
60
61
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
64
65
66
 
 
67
68
69
 
85
86
87
88
89
90
91
 
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
 
 
 
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
 
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
 
128
129
130
 
131
132
133
 
172
173
174
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
176
@@ -20,34 +20,34 @@
 class PurgeDialog(QDialog):     progress = pyqtSignal(QString, object, QString, QString, object) + showMessage = pyqtSignal(QString)   - def __init__(self, repo, unknown, ignored, parent): + def __init__(self, repo, parent):   QDialog.__init__(self, parent)   f = self.windowFlags()   self.setWindowFlags(f & ~Qt.WindowContextHelpButtonHint)   self.setLayout(QVBoxLayout()) - if unknown: - cb = QCheckBox(_('Delete %d unknown files') % len(unknown)) - cb.setChecked(True) - self.layout().addWidget(cb) - self.ucb = cb - if ignored: - cb = QCheckBox(_('Delete %d ignored files') % len(ignored)) - cb.setChecked(True) - self.layout().addWidget(cb) - self.icb = cb + cb = QCheckBox(_('No unknown files found')) + cb.setChecked(False) + cb.setEnabled(False) + self.layout().addWidget(cb) + self.ucb = cb + cb = QCheckBox(_('No ignored files found')) + cb.setChecked(False) + cb.setEnabled(False) + self.layout().addWidget(cb) + self.icb = cb   self.foldercb = QCheckBox(_('Delete empty folders'))   self.foldercb.setChecked(True)   self.layout().addWidget(self.foldercb)   self.hgfilecb = QCheckBox(_('Preserve files beginning with .hg'))   self.hgfilecb.setChecked(True)   self.layout().addWidget(self.hgfilecb) - self.files = (unknown, ignored)     self.stbar = cmdui.ThgStatusBar(self)   self.stbar.setSizeGripEnabled(False) - self.stbar.setVisible(False)   self.progress.connect(self.stbar.progress) + self.showMessage.connect(self.stbar.showMessage)   self.layout().addWidget(self.stbar)     BB = QDialogButtonBox @@ -60,10 +60,53 @@
  self.setWindowTitle('%s - purge' % repo.displayname)   self.repo = repo   + self.bb.setEnabled(False) + self.progress.emit(*cmdui.startProgress(_('Checking'), '...')) + QTimer.singleShot(0, self.checkStatus) + + def checkStatus(self): + repo = self.repo + class CheckThread(QThread): + def __init__(self, parent): + QThread.__init__(self, parent) + self.files = (None, None) + self.error = None + + def run(self): + try: + wctx = repo[None] + wctx.status(ignored=True, unknown=True) + self.files = wctx.unknown(), wctx.ignored() + except Exception, e: + self.error = str(e) + + def completed(): + self.th.wait() + self.files = self.th.files + self.bb.setEnabled(True) + self.progress.emit(*cmdui.stopProgress(_('Checking'))) + if self.th.error: + self.showMessage.emit(hglib.tounicode(self.th.error)) + else: + self.showMessage.emit('Ready to purge.') + U, I = self.files + if U: + self.ucb.setText(_('Delete %d unknown files') % len(U)) + self.ucb.setChecked(True) + self.ucb.setEnabled(True) + if I: + self.icb.setText(_('Delete %d ignored files') % len(I)) + self.icb.setChecked(True) + self.icb.setEnabled(True) + + self.th = CheckThread(self) + self.th.finished.connect(completed) + self.th.start() +   def accept(self):   U, I = self.files - unknown = len(U) and self.ucb.isChecked() - ignored = len(I) and self.icb.isChecked() + unknown = self.ucb.isChecked() + ignored = self.icb.isChecked()   delf = self.foldercb.isChecked()   keep = self.hgfilecb.isChecked()   @@ -85,7 +128,6 @@
  directories = []   failures = []   - self.stbar.setVisible(True)   match = cmdutil.match(repo, [], {})   match.dir = directories.append   status = repo.status(match=match, ignored=ignored, unknown=unknown) @@ -130,18 +172,5 @@
 def run(ui, *pats, **opts):   from tortoisehg.hgqt import thgrepo   from tortoisehg.util import paths - try: - repo = thgrepo.repository(ui, path=paths.find_root()) - wctx = repo[None] - wctx.status(ignored=True, unknown=True) - except Exception, e: - qtlib.InfoMsgBox(_('Repository Error'), - _('Unable to query unrevisioned files\n') + - hglib.tounicode(str(e))) - return None - U, I = wctx.unknown(), wctx.ignored() - if not U and not I: - qtlib.InfoMsgBox(_('No unrevisioned files'), - _('There are no purgable unrevisioned files')) - return None - return PurgeDialog(repo, U, I, None) + repo = thgrepo.repository(ui, path=paths.find_root()) + return PurgeDialog(repo, None)
 
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
 
511
512
 
513
514
515
 
494
495
496
 
 
 
 
 
 
 
 
 
 
 
 
 
 
497
498
499
500
501
502
503
@@ -494,22 +494,10 @@
  self.runCommand(_('Rollback - TortoiseHg'), cmdline)     def purge(self): - try: - wctx = self.repo[None] - wctx.status(ignored=True, unknown=True) - except Exception, e: - InfoMsgBox(_('Repository Error'), - _('Unable to query unrevisioned files\n') + - hglib.tounicode(str(e))) - return - U, I = wctx.unknown(), wctx.ignored() - if not U and not I: - InfoMsgBox(_('No unrevisioned files'), - _('There are no purgable unrevisioned files')) - return - dlg = purge.PurgeDialog(self.repo, U, I, self) + dlg = purge.PurgeDialog(self.repo, self)   dlg.setWindowFlags(Qt.Sheet)   dlg.setWindowModality(Qt.WindowModal) + dlg.finished.connect(dlg.deleteLater)   dlg.exec_()     @pyqtSlot(unicode, dict)