Mercurial > hg > easyhg
changeset 514:306a62fe851e
Add "Close branch" menu option. Is currently available in some cases where it should not be, and using it exposes the fact that the chain of marked-closed changesets is not yet right in grapher.
author | Chris Cannam |
---|---|
date | Tue, 18 Oct 2011 16:50:05 +0100 |
parents | ddc7238fc3b0 |
children | fc35aa6d433e |
files | src/changesetitem.cpp src/changesetitem.h src/changesetscene.cpp src/changesetscene.h src/hgaction.h src/hgtabwidget.cpp src/hgtabwidget.h src/historywidget.cpp src/historywidget.h src/mainwindow.cpp src/mainwindow.h |
diffstat | 11 files changed, 66 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/changesetitem.cpp Tue Oct 18 12:49:39 2011 +0100 +++ b/src/changesetitem.cpp Tue Oct 18 16:50:05 2011 +0100 @@ -197,6 +197,10 @@ branch->setEnabled(m_current); connect(branch, SIGNAL(triggered()), this, SLOT(newBranchActivated())); + QAction *closebranch = menu->addAction(tr("Close branch...")); + closebranch->setEnabled(m_current); + connect(closebranch, SIGNAL(triggered()), this, SLOT(closeBranchActivated())); + QAction *tag = menu->addAction(tr("Add tag...")); connect(tag, SIGNAL(triggered()), this, SLOT(tagActivated())); @@ -240,6 +244,7 @@ void ChangesetItem::mergeActivated() { emit mergeFrom(getId()); } void ChangesetItem::tagActivated() { emit tag(getId()); } void ChangesetItem::newBranchActivated() { emit newBranch(getId()); } +void ChangesetItem::closeBranchActivated() { emit closeBranch(getId()); } void ChangesetItem::paint(QPainter *paint, const QStyleOptionGraphicsItem *, QWidget *)
--- a/src/changesetitem.h Tue Oct 18 12:49:39 2011 +0100 +++ b/src/changesetitem.h Tue Oct 18 16:50:05 2011 +0100 @@ -75,6 +75,7 @@ void showSummary(Changeset *); void mergeFrom(QString); void newBranch(QString); + void closeBranch(QString); void tag(QString); public slots: @@ -90,6 +91,7 @@ void mergeActivated(); void tagActivated(); void newBranchActivated(); + void closeBranchActivated(); protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent *);
--- a/src/changesetscene.cpp Tue Oct 18 12:49:39 2011 +0100 +++ b/src/changesetscene.cpp Tue Oct 18 16:50:05 2011 +0100 @@ -60,6 +60,9 @@ connect(item, SIGNAL(newBranch(QString)), this, SIGNAL(newBranch(QString))); + connect(item, SIGNAL(closeBranch(QString)), + this, SIGNAL(closeBranch(QString))); + connect(item, SIGNAL(tag(QString)), this, SIGNAL(tag(QString))); }
--- a/src/changesetscene.h Tue Oct 18 12:49:39 2011 +0100 +++ b/src/changesetscene.h Tue Oct 18 16:50:05 2011 +0100 @@ -66,6 +66,7 @@ void diffToCurrent(QString id); void mergeFrom(QString id); void newBranch(QString id); + void closeBranch(QString id); void tag(QString id); private slots:
--- a/src/hgaction.h Tue Oct 18 12:49:39 2011 +0100 +++ b/src/hgaction.h Tue Oct 18 16:50:05 2011 +0100 @@ -43,6 +43,7 @@ ACT_CLONEFROMREMOTE, ACT_INIT, ACT_COMMIT, + ACT_CLOSE_BRANCH, ACT_ANNOTATE, ACT_UNCOMMITTED_SUMMARY, ACT_DIFF_SUMMARY,
--- a/src/hgtabwidget.cpp Tue Oct 18 12:49:39 2011 +0100 +++ b/src/hgtabwidget.cpp Tue Oct 18 16:50:05 2011 +0100 @@ -122,6 +122,9 @@ connect(m_historyWidget, SIGNAL(newBranch(QString)), this, SIGNAL(newBranch(QString))); + connect(m_historyWidget, SIGNAL(closeBranch(QString)), + this, SIGNAL(closeBranch(QString))); + connect(m_historyWidget, SIGNAL(tag(QString)), this, SIGNAL(tag(QString))); }
--- a/src/hgtabwidget.h Tue Oct 18 12:49:39 2011 +0100 +++ b/src/hgtabwidget.h Tue Oct 18 16:50:05 2011 +0100 @@ -92,6 +92,7 @@ void diffToCurrent(QString id); void mergeFrom(QString id); void newBranch(QString id); + void closeBranch(QString id); void tag(QString id); void annotateFiles(QStringList);
--- a/src/historywidget.cpp Tue Oct 18 12:49:39 2011 +0100 +++ b/src/historywidget.cpp Tue Oct 18 16:50:05 2011 +0100 @@ -338,6 +338,9 @@ connect(scene, SIGNAL(newBranch(QString)), this, SIGNAL(newBranch(QString))); + connect(scene, SIGNAL(closeBranch(QString)), + this, SIGNAL(closeBranch(QString))); + connect(scene, SIGNAL(tag(QString)), this, SIGNAL(tag(QString))); }
--- a/src/historywidget.h Tue Oct 18 12:49:39 2011 +0100 +++ b/src/historywidget.h Tue Oct 18 16:50:05 2011 +0100 @@ -64,6 +64,7 @@ void diffToCurrent(QString id); void mergeFrom(QString id); void newBranch(QString id); + void closeBranch(QString id); void tag(QString id); private slots:
--- a/src/mainwindow.cpp Tue Oct 18 12:49:39 2011 +0100 +++ b/src/mainwindow.cpp Tue Oct 18 16:50:05 2011 +0100 @@ -326,7 +326,7 @@ void MainWindow::hgQueryHeadsActive() { QStringList params; - params << "heads" << "--active"; + params << "heads"; m_runner->requestAction(HgAction(ACT_QUERY_HEADS_ACTIVE, m_workFolderPath, params)); } @@ -543,6 +543,41 @@ m_runner->requestAction(HgAction(ACT_NEW_BRANCH, m_workFolderPath, params)); } +void MainWindow::hgCloseBranch() +{ + QStringList params; + + //!!! how to ensure this doesn't happen when uncommitted changes present? + + QString cf(tr("Close branch")); + QString comment; + + QString defaultWarning; + + QString branchText; + if (m_currentBranch == "" || m_currentBranch == "default") { + branchText = tr("the default branch"); + defaultWarning = tr("<p><b>Warning:</b> you are asking to close the default branch. This is not usually a good idea!</p>"); + } else { + branchText = tr("branch \"%1\"").arg(m_currentBranch); + } + + if (ConfirmCommentDialog::confirmAndGetLongComment + (this, + cf, + tr("<h3>%1</h3><p>%2%3").arg(cf) + .arg(tr("You are about to close %1.<p>This branch will be marked as closed, will be hidden from the history view, and will no longer accept commits.<p>Please enter your comment for the commit log:").arg(branchText)) + .arg(defaultWarning), + comment, + tr("C&lose branch"))) { + + params << "commit" << "--message" << comment + << "--user" << getUserInfo() << "--close-branch"; + + m_runner->requestAction(HgAction(ACT_CLOSE_BRANCH, m_workFolderPath, params)); + } +} + void MainWindow::hgTag(QString id) { QStringList params; @@ -2365,6 +2400,12 @@ m_shouldHgStat = true; break; + case ACT_CLOSE_BRANCH: + m_hgTabs->clearSelections(); + m_justMerged = false; + m_shouldHgStat = true; + break; + case ACT_REVERT: hgMarkFilesResolved(m_lastRevertedFiles); m_justMerged = false; @@ -2621,6 +2662,9 @@ connect(m_hgTabs, SIGNAL(newBranch(QString)), this, SLOT(hgNewBranch())); + connect(m_hgTabs, SIGNAL(closeBranch(QString)), + this, SLOT(hgCloseBranch())); + connect(m_hgTabs, SIGNAL(tag(QString)), this, SLOT(hgTag(QString)));