Wrapped "revert" "rename" "undo"
FossilOrigin-Name: 09f2c8f44189b490da880f56011b95fae223a5a9
This commit is contained in:
@ -229,6 +229,45 @@ bool Bridge::removeFiles(const QStringList& fileList, bool deleteLocal)
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Bridge::revertFiles(const QStringList& fileList)
|
||||
{
|
||||
if(fileList.empty())
|
||||
return false;
|
||||
|
||||
// Do Revert
|
||||
return runFossil(QStringList() << "revert" << QuotePaths(fileList));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Bridge::renameFile(const QString &beforePath, const QString &afterPath)
|
||||
{
|
||||
// Ensure we can rename the file
|
||||
if(!QFileInfo(beforePath).exists() || QFileInfo(afterPath).exists())
|
||||
return false;
|
||||
|
||||
// Do Rename
|
||||
if(!runFossil(QStringList() << "mv" << QuotePath(beforePath) << QuotePath(afterPath)))
|
||||
return false;
|
||||
|
||||
QString wkdir = getCurrentWorkspace() + QDir::separator();
|
||||
|
||||
// Also rename the file
|
||||
return QFile::rename(wkdir+beforePath, wkdir+afterPath);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Bridge::undo(QStringList &result, bool explainOnly)
|
||||
{
|
||||
QStringList params;
|
||||
params << "undo";
|
||||
|
||||
if(explainOnly)
|
||||
params << "--explain";
|
||||
|
||||
return runFossil(params, &result);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Bridge::stashList(stashmap_t& stashes)
|
||||
{
|
||||
|
@ -100,6 +100,9 @@ public:
|
||||
bool commitFiles(const QStringList &fileList, const QString &comment);
|
||||
bool addFiles(const QStringList& fileList);
|
||||
bool removeFiles(const QStringList& fileList, bool deleteLocal);
|
||||
bool revertFiles(const QStringList& fileList);
|
||||
bool renameFile(const QString& beforePath, const QString& afterPath);
|
||||
bool undo(QStringList& result, bool explainOnly);
|
||||
private:
|
||||
void log(const QString &text, bool isHTML=false)
|
||||
{
|
||||
|
@ -2117,7 +2117,11 @@ void MainWindow::on_actionRevert_triggered()
|
||||
return;
|
||||
|
||||
// Do Revert
|
||||
#ifndef BRIDGE_ENABLED
|
||||
runFossil(QStringList() << "revert" << QuotePaths(modified_files) );
|
||||
#else
|
||||
bridge.revertFiles(modified_files);
|
||||
#endif
|
||||
|
||||
refresh();
|
||||
}
|
||||
@ -2146,13 +2150,17 @@ void MainWindow::on_actionRename_triggered()
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef BRIDGE_ENABLED
|
||||
// Do Rename
|
||||
runFossil(QStringList() << "mv" << QuotePath(fi_before.filePath()) << QuotePath(fi_after.filePath()) );
|
||||
|
||||
QString wkdir = getCurrentWorkspace() + QDir::separator();
|
||||
|
||||
// Also rename the file
|
||||
QFile::rename( wkdir+fi_before.filePath(), wkdir+fi_after.filePath());
|
||||
QFile::rename(wkdir+fi_before.filePath(), wkdir+fi_after.filePath());
|
||||
#else
|
||||
bridge.renameFile(fi_before.filePath(), fi_after.filePath());
|
||||
#endif
|
||||
|
||||
refresh();
|
||||
}
|
||||
@ -2183,6 +2191,7 @@ void MainWindow::on_actionUndo_triggered()
|
||||
// Gather Undo actions
|
||||
QStringList res;
|
||||
|
||||
#ifndef BRIDGE_ENABLED
|
||||
if(!runFossil(QStringList() << "undo" << "--explain", &res ))
|
||||
return;
|
||||
|
||||
@ -2194,6 +2203,18 @@ void MainWindow::on_actionUndo_triggered()
|
||||
|
||||
// Do Undo
|
||||
runFossil(QStringList() << "undo" );
|
||||
#else
|
||||
bridge.undo(res, true);
|
||||
|
||||
if(res.length()>0 && res[0]=="No undo or redo is available")
|
||||
return;
|
||||
|
||||
if(!FileActionDialog::run(this, tr("Undo"), tr("The following actions will be undone.")+"\n"+tr("Are you sure?"), res))
|
||||
return;
|
||||
|
||||
// Do Undo
|
||||
bridge.undo(res, false);
|
||||
#endif
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
Reference in New Issue
Block a user