Mercurial > hg > easyhg
comparison hgrunner.cpp @ 239:661f5808aa0a
* Overhaul settings-defaults mechanism, and add Restore Defaults button to settings dialog
author | Chris Cannam |
---|---|
date | Mon, 10 Jan 2011 15:18:21 +0000 |
parents | e2f2c6e3c01b |
children | 53ad43d5a463 |
comparison
equal
deleted
inserted
replaced
238:e2f2c6e3c01b | 239:661f5808aa0a |
---|---|
44 QProgressBar(parent), | 44 QProgressBar(parent), |
45 m_myDirPath(myDirPath) | 45 m_myDirPath(myDirPath) |
46 { | 46 { |
47 m_proc = 0; | 47 m_proc = 0; |
48 | 48 |
49 setTextVisible(false); | |
50 setVisible(false); | |
51 m_isRunning = false; | |
52 | |
53 (void)findExtension(); | |
54 (void)findHgBinaryName(); | |
55 } | |
56 | |
57 HgRunner::~HgRunner() | |
58 { | |
59 closeTerminal(); | |
60 if (m_proc) { | |
61 m_proc->kill(); | |
62 m_proc->deleteLater(); | |
63 } | |
64 } | |
65 | |
66 QString HgRunner::findExtension() | |
67 { | |
68 // Always unbundle the extension: even if it already exists (in | 49 // Always unbundle the extension: even if it already exists (in |
69 // case we're upgrading) and even if we're not going to use it (so | 50 // case we're upgrading) and even if we're not going to use it (so |
70 // that it's available in case someone wants to use it later, | 51 // that it's available in case someone wants to use it later, |
71 // e.g. to fix a malfunctioning setup). But the path we actually | 52 // e.g. to fix a malfunctioning setup). But the path we actually |
72 // prefer is the one in the settings first, if it exists; then the | 53 // prefer is the one in the settings first, if it exists; then the |
73 // unbundled one; then anything in the path if for some reason | 54 // unbundled one; then anything in the path if for some reason |
74 // unbundling failed | 55 // unbundling failed |
75 | 56 unbundleExtension(); |
76 QSettings settings; | 57 |
77 settings.beginGroup("Locations"); | 58 setTextVisible(false); |
78 | 59 setVisible(false); |
79 QString unbundled = unbundleExtension(); | 60 m_isRunning = false; |
80 QString extpath = settings.value("extensionpath", "").toString(); | 61 } |
81 if (extpath != "" && QFile(extpath).exists()) return extpath; | 62 |
82 | 63 HgRunner::~HgRunner() |
83 extpath = unbundled; | 64 { |
84 if (extpath == "") { | 65 closeTerminal(); |
85 extpath = findInPath("easyhg.py", m_myDirPath, false); | 66 if (m_proc) { |
86 } | 67 m_proc->kill(); |
87 | 68 m_proc->deleteLater(); |
88 settings.setValue("extensionpath", extpath); | 69 } |
89 return extpath; | 70 } |
90 } | |
91 | 71 |
92 QString HgRunner::getUnbundledFileName() | 72 QString HgRunner::getUnbundledFileName() |
93 { | 73 { |
94 QString home = QDir::homePath(); | 74 QString home = QDir::homePath(); |
95 QString target = QString("%1/.easyhg").arg(home); | 75 QString target = QString("%1/.easyhg").arg(home); |
173 } | 153 } |
174 if (pushIt) m_queue.push_back(action); | 154 if (pushIt) m_queue.push_back(action); |
175 checkQueue(); | 155 checkQueue(); |
176 } | 156 } |
177 | 157 |
178 QString HgRunner::findHgBinaryName() | 158 QString HgRunner::getHgBinaryName() |
179 { | 159 { |
180 QSettings settings; | 160 QSettings settings; |
181 settings.beginGroup("Locations"); | 161 settings.beginGroup("Locations"); |
182 QString hg = settings.value("hgbinary", "").toString(); | 162 return settings.value("hgbinary", "").toString(); |
183 if (hg == "") { | 163 } |
184 hg = findInPath("hg", m_myDirPath, true); | 164 |
185 } | 165 QString HgRunner::getExtensionLocation() |
186 if (hg != "") { | 166 { |
187 settings.setValue("hgbinary", hg); | 167 QSettings settings; |
188 } | 168 settings.beginGroup("Locations"); |
189 return hg; | 169 QString extpath = settings.value("extensionpath", "").toString(); |
190 } | 170 if (extpath != "" && QFile(extpath).exists()) return extpath; |
171 return ""; | |
172 } | |
191 | 173 |
192 void HgRunner::started() | 174 void HgRunner::started() |
193 { | 175 { |
194 DEBUG << "started" << endl; | 176 DEBUG << "started" << endl; |
195 /* | 177 /* |
401 bool interactive = false; | 383 bool interactive = false; |
402 QStringList params = action.params; | 384 QStringList params = action.params; |
403 | 385 |
404 if (executable == "") { | 386 if (executable == "") { |
405 // This is a Hg command | 387 // This is a Hg command |
406 executable = findHgBinaryName(); | 388 executable = getHgBinaryName(); |
407 | 389 |
408 if (action.mayBeInteractive()) { | 390 if (action.mayBeInteractive()) { |
409 params.push_front("ui.interactive=true"); | 391 params.push_front("ui.interactive=true"); |
410 params.push_front("--config"); | 392 params.push_front("--config"); |
411 | 393 |
412 QSettings settings; | 394 QSettings settings; |
413 settings.beginGroup("General"); | 395 settings.beginGroup("General"); |
414 if (settings.value("useextension", true).toBool()) { | 396 if (settings.value("useextension", true).toBool()) { |
415 QString extpath = findExtension(); | 397 QString extpath = getExtensionLocation(); |
416 params.push_front(QString("extensions.easyhg=%1").arg(extpath)); | 398 params.push_front(QString("extensions.easyhg=%1").arg(extpath)); |
417 params.push_front("--config"); | 399 params.push_front("--config"); |
418 } | 400 } |
419 interactive = true; | 401 interactive = true; |
420 } | 402 } |