Fuel now uses the http port that Fossil reports when starting the web ui.
FossilOrigin-Name: 5c9a7defad9f6c77db2447df1d904e24001ec40e
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#include "Fossil.h"
|
||||
#include <QStringList>
|
||||
#include <QCoreApplication>
|
||||
#include <LoggedProcess.h>
|
||||
#include <QTextCodec>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
@@ -14,6 +13,9 @@ static const unsigned char UTF8_BOM[] = { 0xEF, 0xBB, 0xBF };
|
||||
// 19: [5c46757d4b9765] on 2012-04-22 04:41:15
|
||||
static const QRegExp REGEX_STASH("\\s*(\\d+):\\s+\\[(.*)\\] on (\\d+)-(\\d+)-(\\d+) (\\d+):(\\d+):(\\d+)", Qt::CaseInsensitive);
|
||||
|
||||
// Listening for HTTP requests on TCP port 8081
|
||||
static const QRegExp REGEX_PORT(".*TCP port ([0-9]+)\\n", Qt::CaseSensitive);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
RepoStatus Fossil::getRepoStatus()
|
||||
{
|
||||
@@ -1006,7 +1008,7 @@ bool Fossil::startUI(const QString &httpPort)
|
||||
if(!httpPort.isEmpty())
|
||||
params << "-P" << httpPort;
|
||||
|
||||
fossilUI.start(params);
|
||||
fossilUI.start(getFossilPath(), params);
|
||||
|
||||
if(!fossilUI.waitForStarted() || fossilUI.state()!=QProcess::Running)
|
||||
{
|
||||
@@ -1014,6 +1016,50 @@ bool Fossil::startUI(const QString &httpPort)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
|
||||
#else
|
||||
QTextCodec *codec = QTextCodec::codecForLocale();
|
||||
#endif
|
||||
|
||||
Q_ASSERT(codec);
|
||||
QTextDecoder *decoder = codec->makeDecoder();
|
||||
Q_ASSERT(decoder);
|
||||
|
||||
fossilUIPort.clear();
|
||||
|
||||
// Wait for fossil to report the http port
|
||||
QString buffer;
|
||||
while(true)
|
||||
{
|
||||
QProcess::ProcessState state = fossilUI.state();
|
||||
qint64 bytes_avail = fossilUI.logBytesAvailable();
|
||||
|
||||
if(state!=QProcess::Running && bytes_avail<1)
|
||||
break;
|
||||
|
||||
QByteArray input;
|
||||
fossilUI.getLogAndClear(input);
|
||||
|
||||
buffer += decoder->toUnicode(input);
|
||||
|
||||
// Normalize line endings
|
||||
buffer = buffer.replace("\r\n", "\n");
|
||||
buffer = buffer.replace("\r", "\n");
|
||||
|
||||
int index = REGEX_PORT.indexIn(buffer);
|
||||
if(index==-1)
|
||||
{
|
||||
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Extract port
|
||||
fossilUIPort = REGEX_PORT.cap(1).trimmed();
|
||||
|
||||
// Done parsing
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1029,4 +1075,13 @@ void Fossil::stopUI()
|
||||
#endif
|
||||
}
|
||||
fossilUI.close();
|
||||
fossilUIPort.clear();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
QString Fossil::getUIHttpAddress() const
|
||||
{
|
||||
if(fossilUIPort.isEmpty())
|
||||
return QString();
|
||||
return "http://127.0.0.1:"+fossilUIPort;
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ class QStringList;
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QObject>
|
||||
#include <QProcess>
|
||||
#include "LoggedProcess.h"
|
||||
#include "Utils.h"
|
||||
|
||||
typedef QMap<QString, QString> stashmap_t;
|
||||
@@ -125,6 +125,9 @@ public:
|
||||
const QString &getCurrentRevision() const { return currentRevision; }
|
||||
const QStringList &getCurrentTags() const { return currentTags; }
|
||||
|
||||
const QString &getUIHttpPort() const { return fossilUIPort; }
|
||||
QString getUIHttpAddress() const;
|
||||
|
||||
private:
|
||||
void log(const QString &text, bool isHTML=false)
|
||||
{
|
||||
@@ -142,7 +145,8 @@ private:
|
||||
QString projectName;
|
||||
QString currentRevision;
|
||||
QStringList currentTags;
|
||||
QProcess fossilUI;
|
||||
LoggedProcess fossilUI;
|
||||
QString fossilUIPort;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1083,7 +1083,7 @@ void MainWindow::fossilBrowse(const QString &fossilUrl)
|
||||
|
||||
bool use_internal = settings.GetValue(FUEL_SETTING_WEB_BROWSER).toInt() == 1;
|
||||
|
||||
QUrl url = QUrl(getFossilHttpAddress()+fossilUrl);
|
||||
QUrl url = QUrl(fossil().getUIHttpAddress()+fossilUrl);
|
||||
|
||||
if(use_internal)
|
||||
{
|
||||
@@ -1254,8 +1254,7 @@ void MainWindow::on_actionDiff_triggered()
|
||||
//------------------------------------------------------------------------------
|
||||
bool MainWindow::startUI()
|
||||
{
|
||||
QString port = settings.GetValue(FUEL_SETTING_HTTP_PORT).toString();
|
||||
bool started = fossil().startUI(port);
|
||||
bool started = fossil().startUI("");
|
||||
ui->actionFossilUI->setChecked(started);
|
||||
return started;
|
||||
}
|
||||
@@ -1724,13 +1723,6 @@ void MainWindow::on_actionViewAsFolders_triggered()
|
||||
updateFileView();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
QString MainWindow::getFossilHttpAddress()
|
||||
{
|
||||
QString port = settings.GetValue(FUEL_SETTING_HTTP_PORT).toString();
|
||||
return "http://127.0.0.1:"+port;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::onWorkspaceTreeViewSelectionChanged(const QItemSelection &/*selected*/, const QItemSelection &/*deselected*/)
|
||||
{
|
||||
|
@@ -48,7 +48,6 @@ private:
|
||||
void rebuildRecent();
|
||||
bool openWorkspace(const QString &path);
|
||||
void loadFossilSettings();
|
||||
QString getFossilHttpAddress();
|
||||
void updateWorkspaceView();
|
||||
void updateFileView();
|
||||
void selectRootDir();
|
||||
|
Reference in New Issue
Block a user