# HG changeset patch # User Chris Cannam # Date 1318953005 -3600 # Node ID 306a62fe851ebbe886452533573a3412ea6dca99 # Parent ddc7238fc3b0eefee8361d56eb5413961c73bd71 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. diff -r ddc7238fc3b0 -r 306a62fe851e src/changesetitem.cpp --- 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 *) diff -r ddc7238fc3b0 -r 306a62fe851e src/changesetitem.h --- 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 *); diff -r ddc7238fc3b0 -r 306a62fe851e src/changesetscene.cpp --- 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))); } diff -r ddc7238fc3b0 -r 306a62fe851e src/changesetscene.h --- 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: diff -r ddc7238fc3b0 -r 306a62fe851e src/hgaction.h --- 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, diff -r ddc7238fc3b0 -r 306a62fe851e src/hgtabwidget.cpp --- 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))); } diff -r ddc7238fc3b0 -r 306a62fe851e src/hgtabwidget.h --- 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); diff -r ddc7238fc3b0 -r 306a62fe851e src/historywidget.cpp --- 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))); } diff -r ddc7238fc3b0 -r 306a62fe851e src/historywidget.h --- 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: diff -r ddc7238fc3b0 -r 306a62fe851e src/mainwindow.cpp --- 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("
Warning: you are asking to close the default branch. This is not usually a good idea!
"); + } else { + branchText = tr("branch \"%1\"").arg(m_currentBranch); + } + + if (ConfirmCommentDialog::confirmAndGetLongComment + (this, + cf, + tr("%2%3").arg(cf) + .arg(tr("You are about to close %1.
This branch will be marked as closed, will be hidden from the history view, and will no longer accept commits.
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))); diff -r ddc7238fc3b0 -r 306a62fe851e src/mainwindow.h --- a/src/mainwindow.h Tue Oct 18 12:49:39 2011 +0100 +++ b/src/mainwindow.h Tue Oct 18 16:50:05 2011 +0100 @@ -95,6 +95,7 @@ void hgTag(QString); void hgNewBranch(); void hgNoBranch(); + void hgCloseBranch(); void hgServe(); void hgIgnore(); void hgEditIgnore();