Added support for tagging revisions
FossilOrigin-Name: 579a9a1fb06478cd37359eb106dcabc9c9c5fa5c
This commit is contained in:
@ -18,6 +18,8 @@
|
||||
#include "UpdateDialog.h"
|
||||
#include "Utils.h"
|
||||
|
||||
#define LATEST_VERSION "Latest"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
enum
|
||||
{
|
||||
@ -176,6 +178,13 @@ MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspaceP
|
||||
menuStashes->addAction(ui->actionDiffStash);
|
||||
menuStashes->addAction(ui->actionDeleteStash);
|
||||
|
||||
// TagsMenu
|
||||
menuTags = new QMenu(this);
|
||||
menuTags->addAction(ui->actionNewTag);
|
||||
menuTags->addAction(ui->actionDeleteTag);
|
||||
menuTags->addAction(ui->actionUpdateRevision);
|
||||
|
||||
|
||||
// Recent Workspaces
|
||||
// Locate a sequence of two separator actions in file menu
|
||||
QList<QAction*> file_actions = ui->menuFile->actions();
|
||||
@ -603,6 +612,14 @@ void MainWindow::scanWorkspace()
|
||||
updateWorkspaceView();
|
||||
updateFileView();
|
||||
|
||||
// Build default versions list
|
||||
const QString latest = tr(LATEST_VERSION);
|
||||
|
||||
versionList.clear();
|
||||
versionList.append(latest);
|
||||
versionList += getWorkspace().getBranches();
|
||||
versionList += getWorkspace().getTags();
|
||||
|
||||
setBusy(false);
|
||||
setStatus("");
|
||||
}
|
||||
@ -1479,44 +1496,6 @@ 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()
|
||||
{
|
||||
@ -2071,6 +2050,8 @@ void MainWindow::on_workspaceTreeView_customContextMenuRequested(const QPoint &)
|
||||
menu = menuWorkspace;
|
||||
else if (tv.Type == TreeViewItem::TYPE_STASH || tv.Type == TreeViewItem::TYPE_STASHES)
|
||||
menu = menuStashes;
|
||||
else if (tv.Type == TreeViewItem::TYPE_TAG || tv.Type == TreeViewItem::TYPE_TAGS)
|
||||
menu = menuTags;
|
||||
|
||||
if(menu)
|
||||
{
|
||||
@ -2206,3 +2187,71 @@ QMessageBox::StandardButton MainWindow::MainWinUICallback::Query(const QString &
|
||||
return DialogQuery(mainWindow, title, query, buttons);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::updateRevision(const QString &revision)
|
||||
{
|
||||
const QString latest = tr(LATEST_VERSION);
|
||||
QString defaultval = latest;
|
||||
|
||||
if(!revision.isEmpty())
|
||||
defaultval = revision;
|
||||
|
||||
QString selected_revision = UpdateDialog::runUpdate(this, tr("Update workspace"), versionList, defaultval).trimmed();
|
||||
|
||||
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::on_actionNewTag_triggered()
|
||||
{
|
||||
// Default to current revision
|
||||
QString revision = fossil().getCurrentRevision();
|
||||
|
||||
QString name;
|
||||
if(!UpdateDialog::runNewTag(this, tr("New tag"), versionList, revision, revision, name))
|
||||
return;
|
||||
|
||||
if(name.isEmpty() || getWorkspace().getTags().contains(name) || getWorkspace().getBranches().contains(name))
|
||||
return;
|
||||
|
||||
fossil().tagNew(name, revision);
|
||||
refresh();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::on_actionDeleteTag_triggered()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::on_actionNewBranch_triggered()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::on_actionMergeBranch_triggered()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -115,6 +115,14 @@ private slots:
|
||||
|
||||
void on_actionUpdateRevision_triggered();
|
||||
|
||||
void on_actionNewTag_triggered();
|
||||
|
||||
void on_actionDeleteTag_triggered();
|
||||
|
||||
void on_actionNewBranch_triggered();
|
||||
|
||||
void on_actionMergeBranch_triggered();
|
||||
|
||||
private:
|
||||
class MainWinUICallback : public UICallback
|
||||
{
|
||||
@ -151,9 +159,12 @@ private:
|
||||
class QShortcut *abortShortcut;
|
||||
QMenu *menuWorkspace;
|
||||
QMenu *menuStashes;
|
||||
QMenu *menuTags;
|
||||
//QMenu *menuBranches;
|
||||
|
||||
bool operationAborted;
|
||||
stringset_t selectedDirs; // The directory selected in the tree
|
||||
QStringList versionList;
|
||||
|
||||
Workspace workspace;
|
||||
Workspace & getWorkspace() { return workspace; }
|
||||
|
@ -24,11 +24,28 @@ UpdateDialog::~UpdateDialog()
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
QString UpdateDialog::run(QWidget *parent, const QStringList &completions, const QString &defaultValue)
|
||||
QString UpdateDialog::runUpdate(QWidget *parent, const QString &title, const QStringList &completions, const QString &defaultValue)
|
||||
{
|
||||
UpdateDialog dlg(parent, completions, defaultValue);
|
||||
dlg.setWindowTitle(title);
|
||||
dlg.ui->label_3->setVisible(false);
|
||||
dlg.ui->lineName->setVisible(false);
|
||||
|
||||
if(dlg.exec() != QDialog::Accepted)
|
||||
return QString("");
|
||||
return dlg.ui->cmbRevision->currentText();
|
||||
return dlg.ui->cmbRevision->currentText().trimmed();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool UpdateDialog::runNewTag(QWidget *parent, const QString &title, const QStringList &completions, const QString &defaultValue, QString &revision, QString &name)
|
||||
{
|
||||
UpdateDialog dlg(parent, completions, defaultValue);
|
||||
dlg.setWindowTitle(title);
|
||||
|
||||
if(dlg.exec() != QDialog::Accepted)
|
||||
return false;
|
||||
|
||||
revision = dlg.ui->cmbRevision->currentText().trimmed();
|
||||
name = dlg.ui->lineName->text().trimmed();
|
||||
return true;
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ public:
|
||||
explicit UpdateDialog(QWidget *parent, const QStringList &completions, const QString &defaultValue);
|
||||
~UpdateDialog();
|
||||
|
||||
static QString run(QWidget *parent, const QStringList &completions, const QString &defaultValue);
|
||||
|
||||
static QString runUpdate(QWidget *parent, const QString &title, const QStringList &completions, const QString &defaultValue);
|
||||
static bool runNewTag(QWidget *parent, const QString &title, const QStringList &completions, const QString &defaultValue, QString &revision, QString &name);
|
||||
|
||||
private:
|
||||
Ui::UpdateDialog *ui;
|
||||
|
Reference in New Issue
Block a user