Wrapped "ls" and "stash ls"
FossilOrigin-Name: 8d81e12735d7c999ea5fca07c4c1683b68a5ad66
This commit is contained in:
@ -11,8 +11,15 @@
|
||||
|
||||
static const unsigned char UTF8_BOM[] = { 0xEF, 0xBB, 0xBF };
|
||||
|
||||
#include "Utils.h"
|
||||
// 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);
|
||||
|
||||
#define FOSSIL_CHECKOUT1 "_FOSSIL_"
|
||||
#define FOSSIL_CHECKOUT2 ".fslckout"
|
||||
#define FOSSIL_EXT "fossil"
|
||||
#define PATH_SEP "/"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Bridge::RepoStatus Bridge::getRepoStatus()
|
||||
{
|
||||
QStringList res;
|
||||
@ -96,6 +103,50 @@ bool Bridge::closeRepository()
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Bridge::listFiles(QStringList &files)
|
||||
{
|
||||
return runFossil(QStringList() << "ls" << "-l", &files, RUNFLAGS_SILENT_ALL);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Bridge::stashList(stashmap_t& stashes)
|
||||
{
|
||||
stashes.clear();
|
||||
QStringList res;
|
||||
|
||||
if(!runFossil(QStringList() << "stash" << "ls", &res, RUNFLAGS_SILENT_ALL))
|
||||
return false;
|
||||
|
||||
for(QStringList::iterator line_it=res.begin(); line_it!=res.end(); )
|
||||
{
|
||||
QString line = *line_it;
|
||||
|
||||
int index = REGEX_STASH.indexIn(line);
|
||||
if(index==-1)
|
||||
break;
|
||||
|
||||
QString id = REGEX_STASH.cap(1);
|
||||
++line_it;
|
||||
|
||||
QString name;
|
||||
// Finish at an anonymous stash or start of a new stash ?
|
||||
if(line_it==res.end() || REGEX_STASH.indexIn(*line_it)!=-1)
|
||||
name = line.trimmed();
|
||||
else // Named stash
|
||||
{
|
||||
// Parse stash name
|
||||
name = (*line_it);
|
||||
name = name.trimmed();
|
||||
++line_it;
|
||||
}
|
||||
|
||||
stashes.insert(name, id);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static QString ParseFossilQuery(QString line)
|
||||
{
|
||||
@ -111,7 +162,6 @@ static QString ParseFossilQuery(QString line)
|
||||
return line;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Bridge::runFossil(const QStringList &args, QStringList *output, int runFlags)
|
||||
{
|
||||
@ -122,7 +172,6 @@ bool Bridge::runFossil(const QStringList &args, QStringList *output, int runFlag
|
||||
return exit_code == EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Run fossil. Returns true if execution was successful regardless if fossil
|
||||
// issued an error
|
||||
@ -420,12 +469,7 @@ QString Bridge::getFossilPath()
|
||||
}
|
||||
|
||||
|
||||
#define FOSSIL_CHECKOUT1 "_FOSSIL_"
|
||||
#define FOSSIL_CHECKOUT2 ".fslckout"
|
||||
#define FOSSIL_EXT "fossil"
|
||||
#define PATH_SEP "/"
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Bridge::isWorkspace(const QString &path)
|
||||
{
|
||||
if(path.length()==0)
|
||||
|
@ -7,6 +7,7 @@ class QStringList;
|
||||
#include <QProcess>
|
||||
#include <QTextBrowser>
|
||||
|
||||
typedef QMap<QString, QString> stashmap_t;
|
||||
|
||||
class Bridge : public QObject
|
||||
{
|
||||
@ -90,6 +91,8 @@ public:
|
||||
bool startUI(const QString &httpPort);
|
||||
void stopUI();
|
||||
|
||||
bool listFiles(QStringList& files);
|
||||
bool stashList(stashmap_t &stashes);
|
||||
|
||||
private:
|
||||
void log(const QString &text, bool isHTML=false)
|
||||
|
@ -25,8 +25,6 @@
|
||||
#include "Utils.h"
|
||||
#include "LoggedProcess.h"
|
||||
|
||||
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))
|
||||
|
||||
#define PATH_SEP "/"
|
||||
|
||||
static const unsigned char UTF8_BOM[] = { 0xEF, 0xBB, 0xBF };
|
||||
@ -701,7 +699,11 @@ void MainWindow::scanWorkspace()
|
||||
|
||||
// Retrieve the status of files tracked by fossil
|
||||
QStringList res;
|
||||
#ifndef BRIDGE_ENABLED
|
||||
if(!runFossil(QStringList() << "ls" << "-l", &res, RUNFLAGS_SILENT_ALL))
|
||||
#else
|
||||
if(!bridge.listFiles(res))
|
||||
#endif
|
||||
return;
|
||||
|
||||
bool scan_files = ui->actionViewUnknown->isChecked();
|
||||
@ -823,6 +825,7 @@ void MainWindow::scanWorkspace()
|
||||
}
|
||||
|
||||
// Load the stash
|
||||
#ifndef BRIDGE_ENABLED
|
||||
stashMap.clear();
|
||||
res.clear();
|
||||
if(!runFossil(QStringList() << "stash" << "ls", &res, RUNFLAGS_SILENT_ALL))
|
||||
@ -853,7 +856,9 @@ void MainWindow::scanWorkspace()
|
||||
|
||||
stashMap.insert(name, id);
|
||||
}
|
||||
|
||||
#else
|
||||
bridge.stashList(stashMap);
|
||||
#endif
|
||||
|
||||
// Update the file item model
|
||||
_done:
|
||||
|
@ -283,7 +283,6 @@ private:
|
||||
// Repository State
|
||||
typedef QList<RepoFile*> filelist_t;
|
||||
typedef QMap<QString, RepoFile*> filemap_t;
|
||||
typedef QMap<QString, QString> stashmap_t;
|
||||
filemap_t workspaceFiles;
|
||||
stringset_t pathSet;
|
||||
stashmap_t stashMap;
|
||||
|
@ -8,6 +8,7 @@ QMessageBox::StandardButton DialogQuery(QWidget *parent, const QString &title, c
|
||||
QString QuotePath(const QString &path);
|
||||
QStringList QuotePaths(const QStringList &paths);
|
||||
|
||||
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint);
|
||||
|
Reference in New Issue
Block a user