Mercurial > hg > easyhg
comparison hgrunner.cpp @ 110:0f039d3cc38e
* Separate out the hgrunner output into stdout and stderr again (merging them was a failed experiment)
author | Chris Cannam |
---|---|
date | Fri, 26 Nov 2010 14:50:10 +0000 |
parents | 1721c580c10e |
children | 151209bc5bd6 |
comparison
equal
deleted
inserted
replaced
109:1721c580c10e | 110:0f039d3cc38e |
---|---|
48 env.insert("LANG", "en_US.utf8"); | 48 env.insert("LANG", "en_US.utf8"); |
49 env.insert("LC_ALL", "en_US.utf8"); | 49 env.insert("LC_ALL", "en_US.utf8"); |
50 env.insert("HGPLAIN", "1"); | 50 env.insert("HGPLAIN", "1"); |
51 m_proc->setProcessEnvironment(env); | 51 m_proc->setProcessEnvironment(env); |
52 | 52 |
53 m_proc->setProcessChannelMode(QProcess::MergedChannels); | |
54 | |
55 setTextVisible(false); | 53 setTextVisible(false); |
56 setVisible(false); | 54 setVisible(false); |
57 m_isRunning = false; | 55 m_isRunning = false; |
58 | 56 |
59 m_output.clear(); | |
60 | |
61 connect(m_proc, SIGNAL(started()), this, SLOT(started())); | 57 connect(m_proc, SIGNAL(started()), this, SLOT(started())); |
62 connect(m_proc, SIGNAL(finished(int, QProcess::ExitStatus)), | 58 connect(m_proc, SIGNAL(finished(int, QProcess::ExitStatus)), |
63 this, SLOT(finished(int, QProcess::ExitStatus))); | 59 this, SLOT(finished(int, QProcess::ExitStatus))); |
64 connect(m_proc, SIGNAL(readyRead()), this, SLOT(dataReady())); | 60 connect(m_proc, SIGNAL(readyReadStandardOutput()), |
61 this, SLOT(dataReadyStdout())); | |
62 connect(m_proc, SIGNAL(readyReadStandardError()), | |
63 this, SLOT(dataReadyStderr())); | |
65 } | 64 } |
66 | 65 |
67 HgRunner::~HgRunner() | 66 HgRunner::~HgRunner() |
68 { | 67 { |
69 if (m_ptySlaveFilename != "") { | 68 if (m_ptySlaveFilename != "") { |
200 if (realmRe.indexIn(text) >= 0) { | 199 if (realmRe.indexIn(text) >= 0) { |
201 noteRealm(realmRe.cap(1)); | 200 noteRealm(realmRe.cap(1)); |
202 } | 201 } |
203 } | 202 } |
204 | 203 |
205 void HgRunner::dataReady() | 204 void HgRunner::dataReadyStdout() |
206 { | 205 { |
207 DEBUG << "dataReady" << endl; | 206 DEBUG << "dataReadyStdout" << endl; |
208 QString chunk = QString::fromUtf8(m_proc->readAll()); | 207 QString chunk = QString::fromUtf8(m_proc->readAllStandardOutput()); |
209 m_output += chunk; | 208 m_stdout += chunk; |
209 checkPrompts(chunk); | |
210 } | |
211 | |
212 void HgRunner::dataReadyStderr() | |
213 { | |
214 DEBUG << "dataReadyStderr" << endl; | |
215 QString chunk = QString::fromUtf8(m_proc->readAllStandardError()); | |
216 m_stderr += chunk; | |
210 checkPrompts(chunk); | 217 checkPrompts(chunk); |
211 } | 218 } |
212 | 219 |
213 void HgRunner::finished(int procExitCode, QProcess::ExitStatus procExitStatus) | 220 void HgRunner::finished(int procExitCode, QProcess::ExitStatus procExitStatus) |
214 { | 221 { |
228 DEBUG << "HgRunner::finished: WARNING: completed action is ACT_NONE" << endl; | 235 DEBUG << "HgRunner::finished: WARNING: completed action is ACT_NONE" << endl; |
229 } | 236 } |
230 | 237 |
231 if (procExitCode == 0 && procExitStatus == QProcess::NormalExit) { | 238 if (procExitCode == 0 && procExitStatus == QProcess::NormalExit) { |
232 DEBUG << "HgRunner::finished: Command completed successfully" << endl; | 239 DEBUG << "HgRunner::finished: Command completed successfully" << endl; |
233 //!!! NB this is all output not stdout as it should be | 240 emit commandCompleted(completedAction, m_stdout); |
234 emit commandCompleted(completedAction, m_output); | |
235 } else { | 241 } else { |
236 DEBUG << "HgRunner::finished: Command failed" << endl; | 242 DEBUG << "HgRunner::finished: Command failed" << endl; |
237 //!!! NB this is all output not stderr as it should be | 243 emit commandFailed(completedAction, m_stderr); |
238 emit commandFailed(completedAction, m_output); | |
239 } | 244 } |
240 | 245 |
241 checkQueue(); | 246 checkQueue(); |
242 } | 247 } |
243 /* | 248 /* |
294 #endif | 299 #endif |
295 | 300 |
296 m_isRunning = true; | 301 m_isRunning = true; |
297 setRange(0, 0); | 302 setRange(0, 0); |
298 show(); | 303 show(); |
299 m_output.clear(); | 304 m_stdout.clear(); |
305 m_stderr.clear(); | |
300 m_realm = ""; | 306 m_realm = ""; |
301 m_userName = ""; | 307 m_userName = ""; |
302 | 308 |
303 if (!action.workingDir.isEmpty()) { | 309 if (!action.workingDir.isEmpty()) { |
304 m_proc->setWorkingDirectory(action.workingDir); | 310 m_proc->setWorkingDirectory(action.workingDir); |