Mercurial > hg > easyhg
changeset 172:b6dd1ee0e486
* Fix failure to recognise local uncommitted changes when an untracked file was selected
* Win32: Look in installed location (currently just the location of the present .exe) for executables as well as in path
* Win32: Search for easyhg extension in same way as executables
* Win32: Set installed location to path when running hg commands (for dependent DLLs)
author | Chris Cannam |
---|---|
date | Wed, 15 Dec 2010 22:07:31 +0000 |
parents | aab308a3b304 |
children | a6d336837ebe |
files | common.cpp common.h debug.cpp easyhg.pro hgrunner.cpp hgrunner.h hgtabwidget.cpp hgtabwidget.h main.cpp mainwindow.cpp mainwindow.h |
diffstat | 11 files changed, 168 insertions(+), 128 deletions(-) [+] |
line wrap: on
line diff
--- a/common.cpp Tue Dec 14 21:16:52 2010 +0000 +++ b/common.cpp Wed Dec 15 22:07:31 2010 +0000 @@ -22,6 +22,7 @@ #include <QProcessEnvironment> #include <QStringList> #include <QDir> +#include <QRegExp> #include <sys/types.h> @@ -41,11 +42,15 @@ #include <signal.h> #endif -QString findExecutable(QString name) +QString findInPath(QString name, QString installPath, bool executableRequired) { bool found = false; if (name != "") { - if (name[0] != '/') { + if (name[0] != '/' +#ifdef Q_OS_WIN32 + && (QRegExp("^[a-zA-Z]:").indexIn(name) != 0) +#endif + ) { #ifdef Q_OS_WIN32 QChar pathSep = ';'; #else @@ -56,7 +61,14 @@ QProcessEnvironment::systemEnvironment().value("PATH"); DEBUG << "findExecutable: seeking location for binary " << name << ": system path is " << path << endl; + if (installPath != "") { + DEBUG << "findExecutable: install path is " << installPath + << ", adding to system path" << endl; + //!!! path = path + pathSep + installPath; + path = installPath + pathSep + path; + } #ifndef Q_OS_WIN32 + //!!! path = path + ":/usr/local/bin"; DEBUG << "... adding /usr/local/bin just in case (fix and add settings dlg please)" << endl; @@ -65,10 +77,15 @@ foreach (QString element, elements) { QString full = QDir(element).filePath(name); QFileInfo fi(full); - if (fi.exists() && fi.isFile() && fi.isExecutable()) { - name = full; - found = true; - break; + DEBUG << "findExecutable: looking at " << full << endl; + if (fi.exists() && fi.isFile()) { + DEBUG << "findExecutable: it's a file" << endl; + if (!executableRequired || fi.isExecutable()) { + name = full; + DEBUG << "findExecutable: found at " << name << endl; + found = true; + break; + } } } } @@ -76,7 +93,7 @@ #ifdef Q_OS_WIN32 if (!found) { if (!name.endsWith(".exe")) { - return findExecutable(name + ".exe"); + return findInPath(name + ".exe", installPath, executableRequired); } } #endif
--- a/common.h Tue Dec 14 21:16:52 2010 +0000 +++ b/common.h Wed Dec 15 22:07:31 2010 +0000 @@ -25,7 +25,7 @@ #define REPOMENU_TITLE "Repository actions" #define WORKFOLDERMENU_TITLE "Workfolder actions" -extern QString findExecutable(QString name); +extern QString findInPath(QString name, QString installPath, bool executable); extern QString getSystem(); extern QString getHgDirName();
--- a/debug.cpp Tue Dec 14 21:16:52 2010 +0000 +++ b/debug.cpp Wed Dec 15 22:07:31 2010 +0000 @@ -40,7 +40,7 @@ prefix = new char[20]; sprintf(prefix, "[%lu]", (unsigned long)QCoreApplication::applicationPid()); logFile = new QFile(QDir::homePath() + "/.easyhg.log"); - if (logFile->open(QIODevice::WriteOnly)) { + if (logFile->open(QIODevice::WriteOnly | QIODevice::Truncate)) { QDebug(QtDebugMsg) << (const char *)prefix << "Opened debug log file " << logFile->fileName();
--- a/easyhg.pro Tue Dec 14 21:16:52 2010 +0000 +++ b/easyhg.pro Wed Dec 15 22:07:31 2010 +0000 @@ -1,93 +1,93 @@ - -CONFIG += debug - -TEMPLATE = app -TARGET = easyhg -unix { - DESTDIR = . -} - -TRANSLATIONS = easyhg_en.ts - -OBJECTS_DIR = o -MOC_DIR = o - -HEADERS = mainwindow.h \ - hgtabwidget.h \ - common.h \ - grapher.h \ - hgrunner.h \ - changeset.h \ - changesetitem.h \ - changesetdetailitem.h \ - logparser.h \ - panner.h \ - panned.h \ - connectionitem.h \ - textabbrev.h \ - dateitem.h \ - colourset.h \ - debug.h \ - recentfiles.h \ - startupdialog.h \ - repositorydialog.h \ - multichoicedialog.h \ - selectablelabel.h \ - filestates.h \ - filestatuswidget.h \ - confirmcommentdialog.h \ - hgaction.h \ - historywidget.h \ - changesetscene.h \ - incomingdialog.h \ - uncommitteditem.h -SOURCES = main.cpp \ - mainwindow.cpp \ - hgtabwidget.cpp \ - hgrunner.cpp \ - grapher.cpp \ - common.cpp \ - changeset.cpp \ - changesetdetailitem.cpp \ - changesetitem.cpp \ - logparser.cpp \ - panner.cpp \ - panned.cpp \ - connectionitem.cpp \ - textabbrev.cpp \ - dateitem.cpp \ - colourset.cpp \ - debug.cpp \ - recentfiles.cpp \ - startupdialog.cpp \ - repositorydialog.cpp \ - multichoicedialog.cpp \ - selectablelabel.cpp \ - filestates.cpp \ - filestatuswidget.cpp \ - confirmcommentdialog.cpp \ - historywidget.cpp \ - changesetscene.cpp \ - incomingdialog.cpp \ - uncommitteditem.cpp - -macx-* { - SOURCES += common_osx.mm - LIBS += -framework Foundation -} - -linux* { - LIBS += -lutil -} - -win* { - LIBS += -lSecur32 -} - -# ! [0] -RESOURCES = easyhg.qrc -win32 { - RC_FILE = easyhg.rc -} - -QT += network + +CONFIG += debug + +TEMPLATE = app +TARGET = easyhg +unix { + DESTDIR = . +} + +TRANSLATIONS = easyhg_en.ts + +OBJECTS_DIR = o +MOC_DIR = o + +HEADERS = mainwindow.h \ + hgtabwidget.h \ + common.h \ + grapher.h \ + hgrunner.h \ + changeset.h \ + changesetitem.h \ + changesetdetailitem.h \ + logparser.h \ + panner.h \ + panned.h \ + connectionitem.h \ + textabbrev.h \ + dateitem.h \ + colourset.h \ + debug.h \ + recentfiles.h \ + startupdialog.h \ + repositorydialog.h \ + multichoicedialog.h \ + selectablelabel.h \ + filestates.h \ + filestatuswidget.h \ + confirmcommentdialog.h \ + hgaction.h \ + historywidget.h \ + changesetscene.h \ + incomingdialog.h \ + uncommitteditem.h +SOURCES = main.cpp \ + mainwindow.cpp \ + hgtabwidget.cpp \ + hgrunner.cpp \ + grapher.cpp \ + common.cpp \ + changeset.cpp \ + changesetdetailitem.cpp \ + changesetitem.cpp \ + logparser.cpp \ + panner.cpp \ + panned.cpp \ + connectionitem.cpp \ + textabbrev.cpp \ + dateitem.cpp \ + colourset.cpp \ + debug.cpp \ + recentfiles.cpp \ + startupdialog.cpp \ + repositorydialog.cpp \ + multichoicedialog.cpp \ + selectablelabel.cpp \ + filestates.cpp \ + filestatuswidget.cpp \ + confirmcommentdialog.cpp \ + historywidget.cpp \ + changesetscene.cpp \ + incomingdialog.cpp \ + uncommitteditem.cpp + +macx-* { + SOURCES += common_osx.mm + LIBS += -framework Foundation +} + +linux* { + LIBS += -lutil +} + +win* { + LIBS += -lSecur32 +} + +# ! [0] +RESOURCES = easyhg.qrc +#win32 { +# RC_FILE = easyhg.rc +#} + +QT += network
--- a/hgrunner.cpp Tue Dec 14 21:16:52 2010 +0000 +++ b/hgrunner.cpp Wed Dec 15 22:07:31 2010 +0000 @@ -39,7 +39,9 @@ #include <fcntl.h> #endif -HgRunner::HgRunner(QWidget * parent): QProgressBar(parent) +HgRunner::HgRunner(QString myDirPath, QWidget * parent) : + QProgressBar(parent), + m_myDirPath(myDirPath) { m_proc = 0; @@ -47,7 +49,7 @@ setVisible(false); m_isRunning = false; - unbundleExtension(); + findExtension(); } HgRunner::~HgRunner() @@ -59,6 +61,16 @@ } } +void HgRunner::findExtension() +{ + m_extensionPath = findInPath("easyhg.py", m_myDirPath, false); + if (m_extensionPath == "easyhg.py") { + if (!unbundleExtension()) { + m_extensionPath = ""; + } + } +} + bool HgRunner::unbundleExtension() { QString bundled = ":easyhg.py"; @@ -108,7 +120,7 @@ QSettings settings; QString hg = settings.value("hgbinary", "").toString(); if (hg == "") { - hg = findExecutable("hg"); + hg = findInPath("hg", m_myDirPath, true); } if (hg != "hg") { settings.setValue("hgbinary", hg); @@ -342,7 +354,14 @@ m_proc = new QProcess; - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + +#ifdef Q_OS_WIN32 + if (m_myDirPath != "") { + env.insert("PATH", m_myDirPath + ";" + env.value("PATH")); + } +#endif + env.insert("LANG", "en_US.utf8"); env.insert("LC_ALL", "en_US.utf8"); env.insert("HGPLAIN", "1");
--- a/hgrunner.h Tue Dec 14 21:16:52 2010 +0000 +++ b/hgrunner.h Wed Dec 15 22:07:31 2010 +0000 @@ -33,7 +33,7 @@ Q_OBJECT public: - HgRunner(QWidget * parent = 0); + HgRunner(QString myDirPath, QWidget * parent = 0); ~HgRunner(); void requestAction(HgAction action); @@ -65,6 +65,7 @@ void openTerminal(); void closeTerminal(); + void findExtension(); bool unbundleExtension(); int m_ptyMasterFd; @@ -79,7 +80,8 @@ QString m_userName; QString m_realm; - + + QString m_myDirPath; QString m_extensionPath; typedef std::deque<HgAction> ActionQueue;
--- a/hgtabwidget.cpp Tue Dec 14 21:16:52 2010 +0000 +++ b/hgtabwidget.cpp Wed Dec 15 22:07:31 2010 +0000 @@ -81,8 +81,7 @@ void HgTabWidget::setCurrent(QStringList ids, QString branch) { - bool showUncommitted = false; - if (canRevert()) showUncommitted = true; + bool showUncommitted = haveChangesToCommit(); m_historyWidget->setCurrent(ids, branch, showUncommitted); } @@ -132,6 +131,11 @@ return !m_fileStatusWidget->getSelectedUnresolvedFiles().empty(); } +bool HgTabWidget::haveChangesToCommit() const +{ + return m_fileStatusWidget->haveChangesToCommit(); +} + QStringList HgTabWidget::getAllSelectedFiles() const { return m_fileStatusWidget->getAllSelectedFiles();
--- a/hgtabwidget.h Tue Dec 14 21:16:52 2010 +0000 +++ b/hgtabwidget.h Wed Dec 15 22:07:31 2010 +0000 @@ -60,6 +60,7 @@ bool canAdd() const; bool canRemove() const; bool canResolve() const; + bool haveChangesToCommit() const; QStringList getAllSelectedFiles() const;
--- a/main.cpp Tue Dec 14 21:16:52 2010 +0000 +++ b/main.cpp Wed Dec 15 22:07:31 2010 +0000 @@ -44,7 +44,11 @@ app.installTranslator(&translator); QStringList args = app.arguments(); - MainWindow mainWin; + + QString myDirPath = QFileInfo(QDir::current().absoluteFilePath(args[0])) + .canonicalPath(); + + MainWindow mainWin(myDirPath); mainWin.show(); if (args.size() == 2) {
--- a/mainwindow.cpp Tue Dec 14 21:16:52 2010 +0000 +++ b/mainwindow.cpp Wed Dec 15 22:07:31 2010 +0000 @@ -41,7 +41,8 @@ #include "incomingdialog.h" -MainWindow::MainWindow() +MainWindow::MainWindow(QString myDirPath) : + m_myDirPath(myDirPath) { QString wndTitle; @@ -54,7 +55,7 @@ createToolBars(); createStatusBar(); - runner = new HgRunner(this); + runner = new HgRunner(myDirPath, this); connect(runner, SIGNAL(commandCompleted(HgAction, QString)), this, SLOT(commandCompleted(HgAction, QString))); connect(runner, SIGNAL(commandFailed(HgAction, QString)), @@ -399,7 +400,7 @@ bases << "opendiff" << "kompare" << "kdiff3" << "meld"; bool found = false; foreach (QString base, bases) { - diff = findExecutable(base); + diff = findInPath(base, m_myDirPath, true); if (diff != base) { found = true; break; @@ -423,7 +424,7 @@ bases << "fmdiff3" << "meld" << "diffuse" << "kdiff3"; bool found = false; foreach (QString base, bases) { - merge = findExecutable(base); + merge = findInPath(base, m_myDirPath, true); if (merge != base) { found = true; break; @@ -1570,9 +1571,6 @@ connect(hgPullAct, SIGNAL(triggered()), this, SLOT(hgPull())); connect(hgPushAct, SIGNAL(triggered()), this, SLOT(hgPush())); -// connect(hgTabs, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int))); - -// connect(hgUpdateToRevAct, SIGNAL(triggered()), this, SLOT(hgUpdateToRev())); connect(hgAnnotateAct, SIGNAL(triggered()), this, SLOT(hgAnnotate())); connect(hgServeAct, SIGNAL(triggered()), this, SLOT(hgServe())); connect(clearSelectionsAct, SIGNAL(triggered()), this, SLOT(clearSelections())); @@ -1608,13 +1606,6 @@ this, SLOT(hgTag(QString))); } -/*!!! -void MainWindow::tabChanged(int currTab) -{ - tabPage = currTab; - -} -*/ void MainWindow::enableDisableActions() { DEBUG << "MainWindow::enableDisableActions" << endl; @@ -1725,7 +1716,7 @@ hgMergeAct->setEnabled(localRepoActionsEnabled && (canMerge || hgTabs->canResolve())); hgUpdateAct->setEnabled(localRepoActionsEnabled && - (canUpdate && !hgTabs->canRevert())); + (canUpdate && !hgTabs->haveChangesToCommit())); // Set the state field on the file status widget @@ -1745,7 +1736,7 @@ } else if (haveMerge) { hgTabs->setState(tr("Have merged but not yet committed on %1").arg(branchText)); } else if (canUpdate) { - if (hgTabs->canRevert()) { + if (hgTabs->haveChangesToCommit()) { // have uncommitted changes hgTabs->setState(tr("On %1. Not at the head of the branch").arg(branchText)); } else {
--- a/mainwindow.h Tue Dec 14 21:16:52 2010 +0000 +++ b/mainwindow.h Wed Dec 15 22:07:31 2010 +0000 @@ -38,7 +38,7 @@ Q_OBJECT public: - MainWindow(); + MainWindow(QString myDirPath); HgTabWidget *hgTabs; void writeSettings(); @@ -153,6 +153,8 @@ bool remoteRepoActionsEnabled; bool localRepoActionsEnabled; + QString m_myDirPath; + //File menu actions QAction *openAct; QAction *settingsAct;