Mercurial > hg > easyhg
changeset 161:5b2046f67a56
* Start using trivial new easyhg extension (requires PyQt)
author | Chris Cannam |
---|---|
date | Fri, 03 Dec 2010 13:36:53 +0000 |
parents | 98fa31128e9d |
children | 910c2c5d1873 |
files | easyhg.qrc filestates.h hgrunner.cpp hgrunner.h |
diffstat | 4 files changed, 43 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/easyhg.qrc Fri Dec 03 12:32:59 2010 +0000 +++ b/easyhg.qrc Fri Dec 03 13:36:53 2010 +0000 @@ -22,6 +22,7 @@ <file>images/hdd_unmount.png</file> <file>images/hdd_unmount-64.png</file> <file>images/fileopen.png</file> + <file>easyhg.py</file> <file>easyhg_en.qm</file> </qresource> </RCC>
--- a/filestates.h Fri Dec 03 12:32:59 2010 +0000 +++ b/filestates.h Fri Dec 03 13:36:53 2010 +0000 @@ -35,7 +35,7 @@ Unknown, Removed, Missing, - InConflict + InConflict, FirstState = Clean, LastState = InConflict
--- 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;
--- a/hgrunner.h Fri Dec 03 12:32:59 2010 +0000 +++ b/hgrunner.h Fri Dec 03 13:36:53 2010 +0000 @@ -65,6 +65,8 @@ void openTerminal(); void closeTerminal(); + bool unbundleExtension(); + int m_ptyMasterFd; int m_ptySlaveFd; QString m_ptySlaveFilename; @@ -77,6 +79,8 @@ QString m_userName; QString m_realm; + + QString m_extensionPath; typedef std::deque<HgAction> ActionQueue; ActionQueue m_queue;