comparison hgrunner.cpp @ 161:5b2046f67a56

* Start using trivial new easyhg extension (requires PyQt)
author Chris Cannam
date Fri, 03 Dec 2010 13:36:53 +0000
parents 0ad212075b36
children 910c2c5d1873
comparison
equal deleted inserted replaced
160:98fa31128e9d 161:5b2046f67a56
24 #include <QDialog> 24 #include <QDialog>
25 #include <QLabel> 25 #include <QLabel>
26 #include <QVBoxLayout> 26 #include <QVBoxLayout>
27 #include <QSettings> 27 #include <QSettings>
28 #include <QInputDialog> 28 #include <QInputDialog>
29 #include <QDir>
29 30
30 #include <iostream> 31 #include <iostream>
31 #include <errno.h> 32 #include <errno.h>
32 #include <stdio.h> 33 #include <stdio.h>
33 #include <stdlib.h> 34 #include <stdlib.h>
43 m_proc = 0; 44 m_proc = 0;
44 45
45 setTextVisible(false); 46 setTextVisible(false);
46 setVisible(false); 47 setVisible(false);
47 m_isRunning = false; 48 m_isRunning = false;
49
50 unbundleExtension();
48 } 51 }
49 52
50 HgRunner::~HgRunner() 53 HgRunner::~HgRunner()
51 { 54 {
52 closeTerminal(); 55 closeTerminal();
53 if (m_proc) { 56 if (m_proc) {
54 m_proc->kill(); 57 m_proc->kill();
55 m_proc->deleteLater(); 58 m_proc->deleteLater();
56 } 59 }
57 } 60 }
61
62 bool HgRunner::unbundleExtension()
63 {
64 QString bundled = ":easyhg.py";
65 QString home = QProcessEnvironment::systemEnvironment().value("HOME");
66 QString target = QString("%1/.easyhg").arg(home);
67 if (!QDir().mkpath(target)) {
68 DEBUG << "Failed to make unbundle path " << target << endl;
69 std::cerr << "Failed to make unbundle path " << target.toStdString() << std::endl;
70 return false;
71 }
72 QFile bf(bundled);
73 m_extensionPath = QString("%1/easyhg.py").arg(target);
74 if (!bf.copy(m_extensionPath)) {
75 DEBUG << "Failed to unbundle extension to " << target << endl;
76 std::cerr << "Failed to unbundle extension to " << m_extensionPath.toStdString() << std::endl;
77 return false;
78 }
79 DEBUG << "Unbundled extension to " << m_extensionPath << endl;
80 return true;
81 }
58 82
59 void HgRunner::requestAction(HgAction action) 83 void HgRunner::requestAction(HgAction action)
60 { 84 {
61 DEBUG << "requestAction " << action.action << endl; 85 DEBUG << "requestAction " << action.action << endl;
62 bool pushIt = true; 86 bool pushIt = true;
294 QStringList params = action.params; 318 QStringList params = action.params;
295 319
296 if (executable == "") { 320 if (executable == "") {
297 // This is a Hg command 321 // This is a Hg command
298 executable = getHgBinaryName(); 322 executable = getHgBinaryName();
323
324 if (action.mayBeInteractive()) {
325 params.push_front("ui.interactive=true");
326 params.push_front("--config");
327 params.push_front(QString("extensions.easyhg=%1").arg(m_extensionPath));
328 params.push_front("--config");
329 interactive = true;
330 }
331
332 //!!! want an option to use the mercurial_keyring extension as well
333
334 /*
299 #ifdef Q_OS_WIN32 335 #ifdef Q_OS_WIN32
300 // This at least means we won't block on the non-working password prompt 336 // This at least means we won't block on the non-working password prompt
301 params.push_front("--noninteractive"); 337 params.push_front("--noninteractive");
302 #else 338 #else
303 // password prompt should work here 339 // password prompt should work here
307 interactive = true; 343 interactive = true;
308 } else { 344 } else {
309 params.push_front("--noninteractive"); 345 params.push_front("--noninteractive");
310 } 346 }
311 #endif 347 #endif
348 */
312 } 349 }
313 350
314 m_isRunning = true; 351 m_isRunning = true;
315 setRange(0, 0); 352 setRange(0, 0);
316 if (!action.shouldBeFast()) show(); 353 if (!action.shouldBeFast()) show();