Wrapped "stash" and all remaining calls
We now use explicit calls for non-setting based fossil options (eg remote-url) FossilOrigin-Name: bbbd2f42e643fbd912b6b3a5cc0b744f14cd56b0
This commit is contained in:
@ -309,6 +309,48 @@ bool Bridge::getFossilSettings(QStringList &result)
|
||||
return runFossil(QStringList() << "settings", &result, RUNFLAGS_SILENT_ALL);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Bridge::setFossilSetting(const QString& name, const QString& value, bool global)
|
||||
{
|
||||
QStringList params;
|
||||
|
||||
if(value.isEmpty())
|
||||
params << "unset" << name;
|
||||
else
|
||||
params << "settings" << name << value;
|
||||
|
||||
if(global)
|
||||
params << "-global";
|
||||
|
||||
return runFossil(params);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Bridge::setRemoteUrl(const QString& url)
|
||||
{
|
||||
QString u = url;
|
||||
|
||||
if(url.isEmpty())
|
||||
u = "off";
|
||||
|
||||
// Run as silent to avoid displaying credentials in the log
|
||||
// FIXME: maybe use a QUrl instead
|
||||
return runFossil(QStringList() << "remote-url" << u, 0, RUNFLAGS_SILENT_INPUT);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Bridge::stashNew(const QStringList& fileList, const QString& name, bool revert)
|
||||
{
|
||||
// Do Stash
|
||||
// Snapshot just records the changes into the stash
|
||||
QString command = "snapshot";
|
||||
|
||||
// Save also reverts the stashed files
|
||||
if(revert)
|
||||
command = "save";
|
||||
|
||||
return runFossil(QStringList() << "stash" << command << "-m" << name << QuotePaths(fileList));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Bridge::stashList(stashmap_t& stashes)
|
||||
@ -348,6 +390,24 @@ bool Bridge::stashList(stashmap_t& stashes)
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Bridge::stashApply(const QString& name)
|
||||
{
|
||||
return runFossil(QStringList() << "stash" << "apply" << name);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Bridge::stashDrop(const QString& name)
|
||||
{
|
||||
return runFossil(QStringList() << "stash" << "apply" << name);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Bridge::stashDiff(const QString& name)
|
||||
{
|
||||
return runFossil(QStringList() << "stash" << "diff" << name, 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static QString ParseFossilQuery(QString line)
|
||||
{
|
||||
@ -459,6 +519,10 @@ bool Bridge::runFossilRaw(const QStringList &args, QStringList *output, int *exi
|
||||
QTextDecoder *decoder = codec->makeDecoder();
|
||||
Q_ASSERT(decoder);
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
size_t input_index = 0;
|
||||
#endif
|
||||
|
||||
while(true)
|
||||
{
|
||||
QProcess::ProcessState state = process.state();
|
||||
@ -483,7 +547,7 @@ bool Bridge::runFossilRaw(const QStringList &args, QStringList *output, int *exi
|
||||
|
||||
#ifdef QT_DEBUG // Log fossil output in debug builds
|
||||
if(!input.isEmpty())
|
||||
qDebug() << input;
|
||||
qDebug() << "[" << ++input_index << "] '" << input.data() << "'\n";
|
||||
#endif
|
||||
|
||||
buffer += decoder->toUnicode(input);
|
||||
@ -536,8 +600,8 @@ bool Bridge::runFossilRaw(const QStringList &args, QStringList *output, int *exi
|
||||
QStringList log_lines = buffer.left(last_line_start).split(EOL_MARK);
|
||||
for(int l=0; l<log_lines.length(); ++l)
|
||||
{
|
||||
// Do not output the last line if it not complete
|
||||
if(l==log_lines.length()-1 && buffer[buffer.length()-1] != EOL_MARK )
|
||||
// Do not output the last line if it not complete. The first one should be ok though
|
||||
if(l>0 && l==log_lines.length()-1 && buffer[buffer.length()-1] != EOL_MARK )
|
||||
continue;
|
||||
|
||||
QString line = log_lines[l].trimmed();
|
||||
|
10
src/Bridge.h
10
src/Bridge.h
@ -97,7 +97,6 @@ public:
|
||||
void stopUI();
|
||||
|
||||
bool listFiles(QStringList &files);
|
||||
bool stashList(stashmap_t &stashes);
|
||||
bool diffFile(const QString &repoFile);
|
||||
bool commitFiles(const QStringList &fileList, const QString &comment);
|
||||
bool addFiles(const QStringList& fileList);
|
||||
@ -107,6 +106,15 @@ public:
|
||||
bool undoRepository(QStringList& result, bool explainOnly);
|
||||
bool updateRepository(QStringList& result, bool explainOnly);
|
||||
bool getFossilSettings(QStringList& result);
|
||||
bool setFossilSetting(const QString &name, const QString &value, bool global);
|
||||
bool setRemoteUrl(const QString &url);
|
||||
|
||||
bool stashNew(const QStringList& fileList, const QString& name, bool revert);
|
||||
bool stashList(stashmap_t &stashes);
|
||||
bool stashApply(const QString& name);
|
||||
bool stashDrop(const QString& name);
|
||||
bool stashDiff(const QString& name);
|
||||
|
||||
private:
|
||||
void log(const QString &text, bool isHTML=false)
|
||||
{
|
||||
|
@ -1441,7 +1441,7 @@ QString MainWindow::getFossilPath()
|
||||
return fossil_exe;
|
||||
}
|
||||
#else
|
||||
|
||||
#if 1
|
||||
bool MainWindow::runFossil(const QStringList &args, QStringList *output, int runFlags)
|
||||
{
|
||||
// Make StatusBar message
|
||||
@ -1453,6 +1453,7 @@ bool MainWindow::runFossil(const QStringList &args, QStringList *output, int run
|
||||
return bridge.runFossil(args, output, runFlags);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::applySettings()
|
||||
@ -2314,7 +2315,9 @@ void MainWindow::loadFossilSettings()
|
||||
Settings::Setting::SettingType type = it->Type;
|
||||
|
||||
// Command types we issue directly on fossil
|
||||
if(type == Settings::Setting::TYPE_FOSSIL_COMMAND)
|
||||
|
||||
//if(type == Settings::Setting::TYPE_FOSSIL_COMMAND)
|
||||
if(name == FOSSIL_SETTING_REMOTE_URL)
|
||||
{
|
||||
// Retrieve existing url
|
||||
QStringList out;
|
||||
@ -2324,6 +2327,8 @@ void MainWindow::loadFossilSettings()
|
||||
continue;
|
||||
}
|
||||
|
||||
Q_ASSERT(type == Settings::Setting::TYPE_FOSSIL_GLOBAL || type == Settings::Setting::TYPE_FOSSIL_LOCAL);
|
||||
|
||||
// Otherwise it must be a fossil setting
|
||||
if(!kv.contains(name))
|
||||
continue;
|
||||
@ -2360,16 +2365,23 @@ void MainWindow::on_actionSettings_triggered()
|
||||
Settings::Setting::SettingType type = it.value().Type;
|
||||
|
||||
// Command types we issue directly on fossil
|
||||
if(type == Settings::Setting::TYPE_FOSSIL_COMMAND)
|
||||
// FIXME: major uglyness with settings management
|
||||
//if(type == Settings::Setting::TYPE_FOSSIL_COMMAND)
|
||||
if(name == FOSSIL_SETTING_REMOTE_URL)
|
||||
{
|
||||
// Run as silent to avoid displaying credentials in the log
|
||||
#ifndef BRIDGE_H
|
||||
runFossil(QStringList() << "remote-url" << QuotePath(it.value().Value.toString()), 0, RUNFLAGS_SILENT_INPUT);
|
||||
#else
|
||||
bridge.setRemoteUrl(it.value().Value.toString());
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
Q_ASSERT(type == Settings::Setting::TYPE_FOSSIL_GLOBAL || type == Settings::Setting::TYPE_FOSSIL_LOCAL);
|
||||
|
||||
QString value = it.value().Value.toString();
|
||||
#ifndef BRIDGE_H
|
||||
QStringList params;
|
||||
|
||||
if(value.isEmpty())
|
||||
@ -2381,6 +2393,9 @@ void MainWindow::on_actionSettings_triggered()
|
||||
params << "-global";
|
||||
|
||||
runFossil(params);
|
||||
#else
|
||||
bridge.setFossilSetting(name, value, type == Settings::Setting::TYPE_FOSSIL_GLOBAL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -2681,11 +2696,15 @@ void MainWindow::on_actionNewStash_triggered()
|
||||
}
|
||||
|
||||
// Do Stash
|
||||
#ifndef BRIDGE_ENABLED
|
||||
QString command = "snapshot";
|
||||
if(revert)
|
||||
command = "save";
|
||||
|
||||
runFossil(QStringList() << "stash" << command << "-m" << stash_name << QuotePaths(stashed_files) );
|
||||
#else
|
||||
bridge.stashNew(stashed_files, stash_name, revert);
|
||||
#endif
|
||||
refresh();
|
||||
}
|
||||
|
||||
@ -2705,7 +2724,11 @@ void MainWindow::on_actionApplyStash_triggered()
|
||||
stashmap_t::iterator id_it = stashMap.find(*it);
|
||||
Q_ASSERT(id_it!=stashMap.end());
|
||||
|
||||
#ifndef BRIDGE_ENABLED
|
||||
if(!runFossil(QStringList() << "stash" << "apply" << *id_it))
|
||||
#else
|
||||
if(!bridge.stashApply(*id_it))
|
||||
#endif
|
||||
{
|
||||
log(tr("Stash application aborted due to errors")+"\n");
|
||||
return;
|
||||
@ -2717,8 +2740,12 @@ void MainWindow::on_actionApplyStash_triggered()
|
||||
{
|
||||
stashmap_t::iterator id_it = stashMap.find(*it);
|
||||
Q_ASSERT(id_it!=stashMap.end());
|
||||
|
||||
#ifndef BRIDGE_ENABLED
|
||||
if(!runFossil(QStringList() << "stash" << "drop" << *id_it))
|
||||
#else
|
||||
if(!bridge.stashDrop(*id_it))
|
||||
#endif
|
||||
|
||||
{
|
||||
log(tr("Stash deletion aborted due to errors")+"\n");
|
||||
return;
|
||||
@ -2746,7 +2773,11 @@ void MainWindow::on_actionDeleteStash_triggered()
|
||||
stashmap_t::iterator id_it = stashMap.find(*it);
|
||||
Q_ASSERT(id_it!=stashMap.end());
|
||||
|
||||
#ifndef BRIDGE_ENABLED
|
||||
if(!runFossil(QStringList() << "stash" << "drop" << *id_it))
|
||||
#else
|
||||
if(!bridge.stashDrop(*id_it))
|
||||
#endif
|
||||
{
|
||||
log(tr("Stash deletion aborted due to errors")+"\n");
|
||||
return;
|
||||
@ -2769,7 +2800,11 @@ void MainWindow::on_actionDiffStash_triggered()
|
||||
Q_ASSERT(id_it!=stashMap.end());
|
||||
|
||||
// Run diff
|
||||
#ifndef BRIDGE_ENABLED
|
||||
runFossil(QStringList() << "stash" << "diff" << *id_it, 0);
|
||||
#else
|
||||
bridge.stashDiff(*id_it);
|
||||
#endif
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@ -2882,7 +2917,11 @@ void MainWindow::dropEvent(QDropEvent *event)
|
||||
return;
|
||||
|
||||
// Do Add
|
||||
#ifndef BRIDGE_ENABLED
|
||||
runFossil(QStringList() << "add" << QuotePaths(newfiles) );
|
||||
#else
|
||||
bridge.addFiles(newfiles);
|
||||
#endif
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
Reference in New Issue
Block a user