Mercurial > hg > easyhg
diff 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 |
line wrap: on
line diff
--- a/hgrunner.cpp Fri Dec 03 12:32:59 2010 +0000 +++ b/hgrunner.cpp Fri Dec 03 13:36:53 2010 +0000 @@ -26,6 +26,7 @@ #include <QVBoxLayout> #include <QSettings> #include <QInputDialog> +#include <QDir> #include <iostream> #include <errno.h> @@ -45,6 +46,8 @@ setTextVisible(false); setVisible(false); m_isRunning = false; + + unbundleExtension(); } HgRunner::~HgRunner() @@ -56,6 +59,27 @@ } } +bool HgRunner::unbundleExtension() +{ + QString bundled = ":easyhg.py"; + QString home = QProcessEnvironment::systemEnvironment().value("HOME"); + QString target = QString("%1/.easyhg").arg(home); + if (!QDir().mkpath(target)) { + DEBUG << "Failed to make unbundle path " << target << endl; + std::cerr << "Failed to make unbundle path " << target.toStdString() << std::endl; + return false; + } + QFile bf(bundled); + m_extensionPath = QString("%1/easyhg.py").arg(target); + if (!bf.copy(m_extensionPath)) { + DEBUG << "Failed to unbundle extension to " << target << endl; + std::cerr << "Failed to unbundle extension to " << m_extensionPath.toStdString() << std::endl; + return false; + } + DEBUG << "Unbundled extension to " << m_extensionPath << endl; + return true; +} + void HgRunner::requestAction(HgAction action) { DEBUG << "requestAction " << action.action << endl; @@ -296,6 +320,18 @@ if (executable == "") { // This is a Hg command executable = getHgBinaryName(); + + if (action.mayBeInteractive()) { + params.push_front("ui.interactive=true"); + params.push_front("--config"); + params.push_front(QString("extensions.easyhg=%1").arg(m_extensionPath)); + params.push_front("--config"); + interactive = true; + } + + //!!! want an option to use the mercurial_keyring extension as well + +/* #ifdef Q_OS_WIN32 // This at least means we won't block on the non-working password prompt params.push_front("--noninteractive"); @@ -309,6 +345,7 @@ params.push_front("--noninteractive"); } #endif +*/ } m_isRunning = true;