Added merge support
FossilOrigin-Name: ac65fbf8d33a9e64fb97bd8652a43b4d11c8e538
This commit is contained in:
@ -531,6 +531,43 @@ bool Fossil::branchList(QStringList& branches, QStringList& activeBranches)
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Fossil::branchNew(const QString& name, const QString& revisionBasis, bool isPrivate)
|
||||
{
|
||||
QStringList params;
|
||||
|
||||
params <<"branch" << "new" << name << revisionBasis;
|
||||
|
||||
if(isPrivate)
|
||||
params << "--private";
|
||||
|
||||
QStringList res;
|
||||
|
||||
if(!runFossil(params, &res))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Fossil::branchMerge(QStringList &res, const QString& revision, bool integrate, bool testOnly)
|
||||
{
|
||||
QStringList params;
|
||||
|
||||
params <<"merge";
|
||||
|
||||
if(integrate)
|
||||
params << "--integrate";
|
||||
|
||||
if(testOnly)
|
||||
params << "--dry-run";
|
||||
|
||||
params << revision;
|
||||
|
||||
if(!runFossil(params, &res))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static QString ParseFossilQuery(QString line)
|
||||
{
|
||||
|
@ -116,6 +116,8 @@ public:
|
||||
bool tagDelete(const QString& name, const QString& revision);
|
||||
|
||||
bool branchList(QStringList& branches, QStringList& activeBranches);
|
||||
bool branchNew(const QString& name, const QString& revisionBasis, bool isPrivate=false);
|
||||
bool branchMerge(QStringList& res, const QString& revision, bool integrate, bool testOnly);
|
||||
|
||||
const QString &getCurrentRevision() const { return currentRevision; }
|
||||
const QStringList &getCurrentTags() const { return currentTags; }
|
||||
|
@ -18,7 +18,8 @@
|
||||
#include "UpdateDialog.h"
|
||||
#include "Utils.h"
|
||||
|
||||
#define LATEST_VERSION "Latest"
|
||||
#define LATEST_VERSION "Latest Revision"
|
||||
#define CURRENT_VERSION "Current Revision"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
enum
|
||||
@ -147,6 +148,8 @@ MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspaceP
|
||||
|
||||
// StashMenu
|
||||
menuStashes = new QMenu(this);
|
||||
menuStashes->addAction(ui->actionNewStash);
|
||||
menuStashes->addAction(separator);
|
||||
menuStashes->addAction(ui->actionApplyStash);
|
||||
menuStashes->addAction(ui->actionDiffStash);
|
||||
menuStashes->addAction(ui->actionDeleteStash);
|
||||
@ -154,9 +157,16 @@ MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspaceP
|
||||
// TagsMenu
|
||||
menuTags = new QMenu(this);
|
||||
menuTags->addAction(ui->actionNewTag);
|
||||
menuTags->addAction(separator);
|
||||
menuTags->addAction(ui->actionDeleteTag);
|
||||
menuTags->addAction(ui->actionUpdateRevision);
|
||||
|
||||
// BranchesMenu
|
||||
menuBranches = new QMenu(this);
|
||||
menuBranches->addAction(ui->actionNewBranch);
|
||||
menuBranches->addAction(separator);
|
||||
menuBranches->addAction(ui->actionMergeBranch);
|
||||
menuBranches->addAction(ui->actionUpdateRevision);
|
||||
|
||||
// Recent Workspaces
|
||||
// Locate a sequence of two separator actions in file menu
|
||||
@ -586,10 +596,7 @@ void MainWindow::scanWorkspace()
|
||||
updateFileView();
|
||||
|
||||
// Build default versions list
|
||||
const QString latest = tr(LATEST_VERSION);
|
||||
|
||||
versionList.clear();
|
||||
versionList.append(latest);
|
||||
versionList += getWorkspace().getBranches();
|
||||
versionList += getWorkspace().getTags().keys();
|
||||
|
||||
@ -1474,7 +1481,13 @@ void MainWindow::on_actionUpdate_triggered()
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::on_actionUpdateRevision_triggered()
|
||||
{
|
||||
updateRevision("");
|
||||
QStringList selected = selectedBranches + selectedTags;
|
||||
|
||||
QString revision;
|
||||
if(!selected.isEmpty())
|
||||
revision = selected.first();
|
||||
|
||||
updateRevision(revision);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@ -1610,6 +1623,8 @@ void MainWindow::onWorkspaceTreeViewSelectionChanged(const QItemSelection &/*sel
|
||||
return;
|
||||
|
||||
stringset_t new_dirs;
|
||||
selectedTags.clear();
|
||||
selectedBranches.clear();
|
||||
|
||||
foreach(const QModelIndex &id, indices)
|
||||
{
|
||||
@ -2039,6 +2054,8 @@ void MainWindow::on_workspaceTreeView_customContextMenuRequested(const QPoint &)
|
||||
menu = menuStashes;
|
||||
else if (tv.Type == TreeViewItem::TYPE_TAG || tv.Type == TreeViewItem::TYPE_TAGS)
|
||||
menu = menuTags;
|
||||
else if (tv.Type == TreeViewItem::TYPE_BRANCH || tv.Type == TreeViewItem::TYPE_BRANCHES)
|
||||
menu = menuBranches;
|
||||
|
||||
if(menu)
|
||||
{
|
||||
@ -2221,11 +2238,14 @@ void MainWindow::on_actionNewTag_triggered()
|
||||
QString revision = fossil().getCurrentRevision();
|
||||
|
||||
QString name;
|
||||
if(!UpdateDialog::runNewTag(this, tr("New tag"), versionList, revision, revision, name))
|
||||
if(!UpdateDialog::runNewTag(this, tr("New Tag"), versionList, revision, revision, name))
|
||||
return;
|
||||
|
||||
if(name.isEmpty() || getWorkspace().getTags().contains(name) || getWorkspace().getBranches().contains(name))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("Invalid name."), QMessageBox::Ok );
|
||||
return;
|
||||
}
|
||||
|
||||
fossil().tagNew(name, revision);
|
||||
refresh();
|
||||
@ -2253,11 +2273,58 @@ void MainWindow::on_actionDeleteTag_triggered()
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::on_actionNewBranch_triggered()
|
||||
{
|
||||
// Default to current revision
|
||||
QString revision = fossil().getCurrentRevision();
|
||||
|
||||
QString branch_name;
|
||||
if(!UpdateDialog::runNewTag(this, tr("New Branch"), versionList, revision, revision, branch_name))
|
||||
return;
|
||||
|
||||
if(branch_name.isEmpty() || getWorkspace().getTags().contains(branch_name) || getWorkspace().getBranches().contains(branch_name))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("Invalid name."), QMessageBox::Ok );
|
||||
return;
|
||||
}
|
||||
|
||||
if(!fossil().branchNew(branch_name, revision, false))
|
||||
return;
|
||||
|
||||
if(QMessageBox::Yes == DialogQuery(this, tr("New Branch"), tr("Would you like to check-out the branch '%0' ?").arg(branch_name)))
|
||||
updateRevision(branch_name);
|
||||
else
|
||||
refresh();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::MergeRevision(const QString &defaultRevision)
|
||||
{
|
||||
QStringList res;
|
||||
QString revision = defaultRevision;
|
||||
|
||||
bool integrate = false;
|
||||
revision = UpdateDialog::runMerge(this, tr("Merge"), versionList, revision, integrate);
|
||||
|
||||
if(revision.isEmpty())
|
||||
return;
|
||||
|
||||
// Do test merge
|
||||
if(!fossil().branchMerge(res, revision, integrate, true))
|
||||
return;
|
||||
|
||||
if(!FileActionDialog::run(this, tr("Merge"), tr("The following changesd will be made.")+"\n"+tr("Are you sure?"), res))
|
||||
return;
|
||||
|
||||
// Do update
|
||||
fossil().branchMerge(res, revision, integrate, false);
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::on_actionMergeBranch_triggered()
|
||||
{
|
||||
QString revision;
|
||||
|
||||
if(!selectedBranches.isEmpty())
|
||||
revision = selectedBranches.first();
|
||||
MergeRevision(revision);
|
||||
}
|
||||
|
@ -51,6 +51,8 @@ private:
|
||||
void updateWorkspaceView();
|
||||
void updateFileView();
|
||||
void selectRootDir();
|
||||
void MergeRevision(const QString& defaultRevision);
|
||||
|
||||
void fossilBrowse(const QString &fossilUrl);
|
||||
void dragEnterEvent(class QDragEnterEvent *event);
|
||||
void dropEvent(class QDropEvent *event);
|
||||
@ -112,15 +114,10 @@ private slots:
|
||||
void on_textBrowser_customContextMenuRequested(const QPoint &pos);
|
||||
void on_fileTableView_customContextMenuRequested(const QPoint &pos);
|
||||
void on_workspaceTreeView_customContextMenuRequested(const QPoint &pos);
|
||||
|
||||
void on_actionUpdateRevision_triggered();
|
||||
|
||||
void on_actionNewTag_triggered();
|
||||
|
||||
void on_actionDeleteTag_triggered();
|
||||
|
||||
void on_actionNewBranch_triggered();
|
||||
|
||||
void on_actionMergeBranch_triggered();
|
||||
|
||||
private:
|
||||
@ -160,7 +157,7 @@ private:
|
||||
QMenu *menuWorkspace;
|
||||
QMenu *menuStashes;
|
||||
QMenu *menuTags;
|
||||
//QMenu *menuBranches;
|
||||
QMenu *menuBranches;
|
||||
|
||||
bool operationAborted;
|
||||
stringset_t selectedDirs; // The directory selected in the tree
|
||||
|
@ -28,20 +28,51 @@ QString UpdateDialog::runUpdate(QWidget *parent, const QString &title, const QSt
|
||||
{
|
||||
UpdateDialog dlg(parent, completions, defaultValue);
|
||||
dlg.setWindowTitle(title);
|
||||
dlg.ui->label_3->setVisible(false);
|
||||
dlg.ui->lblName->setVisible(false);
|
||||
dlg.ui->lineName->setVisible(false);
|
||||
dlg.ui->lblIntegrate->setVisible(false);
|
||||
dlg.ui->chkIntegrate->setVisible(false);
|
||||
|
||||
dlg.adjustSize();
|
||||
|
||||
if(dlg.exec() != QDialog::Accepted)
|
||||
return QString("");
|
||||
return dlg.ui->cmbRevision->currentText().trimmed();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
QString UpdateDialog::runMerge(QWidget *parent, const QString &title, const QStringList &completions, const QString &defaultValue, bool &integrate)
|
||||
{
|
||||
UpdateDialog dlg(parent, completions, defaultValue);
|
||||
dlg.setWindowTitle(title);
|
||||
dlg.ui->lblName->setVisible(false);
|
||||
dlg.ui->lineName->setVisible(false);
|
||||
dlg.ui->lblIntegrate->setVisible(true);
|
||||
dlg.ui->chkIntegrate->setVisible(true);
|
||||
dlg.ui->chkIntegrate->setChecked(integrate);
|
||||
dlg.adjustSize();
|
||||
|
||||
if(dlg.exec() != QDialog::Accepted)
|
||||
return QString("");
|
||||
|
||||
integrate = dlg.ui->chkIntegrate->checkState() == Qt::Checked;
|
||||
|
||||
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);
|
||||
|
||||
dlg.ui->lblName->setVisible(true);
|
||||
dlg.ui->lineName->setVisible(true);
|
||||
dlg.ui->lblIntegrate->setVisible(false);
|
||||
dlg.ui->chkIntegrate->setVisible(false);
|
||||
dlg.adjustSize();
|
||||
|
||||
if(dlg.exec() != QDialog::Accepted)
|
||||
return false;
|
||||
|
||||
|
@ -17,6 +17,7 @@ public:
|
||||
~UpdateDialog();
|
||||
|
||||
static QString runUpdate(QWidget *parent, const QString &title, const QStringList &completions, const QString &defaultValue);
|
||||
static QString runMerge(QWidget* parent, const QString& title, const QStringList& completions, const QString& defaultValue, bool& integrate);
|
||||
static bool runNewTag(QWidget *parent, const QString &title, const QStringList &completions, const QString &defaultValue, QString &revision, QString &name);
|
||||
|
||||
private:
|
||||
|
@ -148,7 +148,7 @@ void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifie
|
||||
type = WorkspaceFile::TYPE_UNCHANGED;
|
||||
else if(status_text=="CONFLICT")
|
||||
type = WorkspaceFile::TYPE_CONFLICTED;
|
||||
else if(status_text=="UPDATED_BY_MERGE")
|
||||
else if(status_text=="UPDATED_BY_MERGE" || status_text=="ADDED_BY_MERGE" || status_text=="ADDED_BY_INTEGRATE" || status_text=="UPDATED_BY_INTEGRATE")
|
||||
type = WorkspaceFile::TYPE_MERGED;
|
||||
|
||||
// Filter unwanted file types
|
||||
|
Reference in New Issue
Block a user