Added "Update to Revision" Action
FossilOrigin-Name: 203cae37a6553c26a3844dcfdd3386eae9be288f
This commit is contained in:
@ -286,7 +286,7 @@ bool Fossil::undoRepository(QStringList &result, bool explainOnly)
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Fossil::updateRepository(QStringList &result, bool explainOnly)
|
||||
bool Fossil::updateRepository(QStringList &result, const QString &revision, bool explainOnly)
|
||||
{
|
||||
QStringList params;
|
||||
params << "update";
|
||||
@ -294,6 +294,12 @@ bool Fossil::updateRepository(QStringList &result, bool explainOnly)
|
||||
if(explainOnly)
|
||||
params << "--nochange";
|
||||
|
||||
if(revision.isEmpty())
|
||||
params << "--latest";
|
||||
else
|
||||
params << revision;
|
||||
|
||||
|
||||
result.clear();
|
||||
return runFossil(params, &result);
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public:
|
||||
bool pullRepository();
|
||||
bool cloneRepository(const QString &repository, const QUrl &url, const QUrl &proxyUrl);
|
||||
bool undoRepository(QStringList& result, bool explainOnly);
|
||||
bool updateRepository(QStringList& result, bool explainOnly);
|
||||
bool updateRepository(QStringList& result, const QString& revision, bool explainOnly);
|
||||
bool getFossilVersion(QString &version);
|
||||
|
||||
bool uiRunning() const;
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "CommitDialog.h"
|
||||
#include "FileActionDialog.h"
|
||||
#include "CloneDialog.h"
|
||||
#include "UpdateDialog.h"
|
||||
#include "Utils.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -1455,10 +1456,10 @@ void MainWindow::on_actionUpdate_triggered()
|
||||
QStringList res;
|
||||
|
||||
// Do test update
|
||||
if(!fossil().updateRepository(res, true))
|
||||
if(!fossil().updateRepository(res, "", true))
|
||||
return;
|
||||
|
||||
// Fixme: parse "changes: None. Already up-to-date" and avoid dialog
|
||||
// FIXME: parse "changes: None. Already up-to-date" and avoid dialog
|
||||
|
||||
if(res.length()==0)
|
||||
return;
|
||||
@ -1467,11 +1468,55 @@ void MainWindow::on_actionUpdate_triggered()
|
||||
return;
|
||||
|
||||
// Do update
|
||||
fossil().updateRepository(res, false);
|
||||
fossil().updateRepository(res, "", false);
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::on_actionUpdateRevision_triggered()
|
||||
{
|
||||
updateRevision("");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::updateRevision(const QString &revision)
|
||||
{
|
||||
QStringList versions;
|
||||
versions.append(tr("Latest version"));
|
||||
versions += getWorkspace().getBranches();
|
||||
versions += getWorkspace().getTags();
|
||||
const QString latest = tr("Latest version");
|
||||
QString defaultval = latest;
|
||||
|
||||
if(!revision.isEmpty())
|
||||
defaultval = revision;
|
||||
|
||||
QString selected_revision = UpdateDialog::run(this, versions, defaultval);
|
||||
|
||||
if(selected_revision.isEmpty())
|
||||
return;
|
||||
else if(selected_revision == latest)
|
||||
selected_revision = ""; // Empty revision is "latest"
|
||||
|
||||
QStringList res;
|
||||
|
||||
// Do test update
|
||||
if(!fossil().updateRepository(res, selected_revision, true))
|
||||
return;
|
||||
|
||||
// FIXME: parse "changes: None. Already up-to-date" and avoid dialog
|
||||
if(res.length()==0)
|
||||
return;
|
||||
|
||||
if(!FileActionDialog::run(this, tr("Update"), tr("The following files will be updated.")+"\n"+tr("Are you sure?"), res))
|
||||
return;
|
||||
|
||||
// Do update
|
||||
fossil().updateRepository(res, selected_revision, false);
|
||||
refresh();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::loadFossilSettings()
|
||||
{
|
||||
@ -2160,3 +2205,4 @@ QMessageBox::StandardButton MainWindow::MainWinUICallback::Query(const QString &
|
||||
{
|
||||
return DialogQuery(mainWindow, title, query, buttons);
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ private:
|
||||
void scanWorkspace();
|
||||
void applySettings();
|
||||
void updateSettings();
|
||||
void updateRevision(const QString& revision);
|
||||
const QString &getCurrentWorkspace();
|
||||
void setCurrentWorkspace(const QString &workspace);
|
||||
void log(const QString &text, bool isHTML=false);
|
||||
@ -112,6 +113,8 @@ private slots:
|
||||
void on_fileTableView_customContextMenuRequested(const QPoint &pos);
|
||||
void on_workspaceTreeView_customContextMenuRequested(const QPoint &pos);
|
||||
|
||||
void on_actionUpdateRevision_triggered();
|
||||
|
||||
private:
|
||||
class MainWinUICallback : public UICallback
|
||||
{
|
||||
|
34
src/UpdateDialog.cpp
Normal file
34
src/UpdateDialog.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include "UpdateDialog.h"
|
||||
#include "ui_UpdateDialog.h"
|
||||
#include "Utils.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
UpdateDialog::UpdateDialog(QWidget *parent, const QStringList &completions, const QString &defaultValue) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::UpdateDialog),
|
||||
completer(completions, parent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->cmbRevision->setCompleter(&completer);
|
||||
|
||||
ui->cmbRevision->addItems(completions);
|
||||
|
||||
if(!defaultValue.isEmpty())
|
||||
ui->cmbRevision->setCurrentText(defaultValue);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
UpdateDialog::~UpdateDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
QString UpdateDialog::run(QWidget *parent, const QStringList &completions, const QString &defaultValue)
|
||||
{
|
||||
UpdateDialog dlg(parent, completions, defaultValue);
|
||||
|
||||
if(dlg.exec() != QDialog::Accepted)
|
||||
return QString("");
|
||||
return dlg.ui->cmbRevision->currentText();
|
||||
}
|
27
src/UpdateDialog.h
Normal file
27
src/UpdateDialog.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef UPDATEDIALOG_H
|
||||
#define UPDATEDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QCompleter>
|
||||
|
||||
namespace Ui {
|
||||
class UpdateDialog;
|
||||
}
|
||||
|
||||
class UpdateDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit UpdateDialog(QWidget *parent, const QStringList &completions, const QString &defaultValue);
|
||||
~UpdateDialog();
|
||||
|
||||
static QString run(QWidget *parent, const QStringList &completions, const QString &defaultValue);
|
||||
|
||||
|
||||
private:
|
||||
Ui::UpdateDialog *ui;
|
||||
QCompleter completer;
|
||||
};
|
||||
|
||||
#endif // UPDATEDIALOG_H
|
Reference in New Issue
Block a user