# HG changeset patch # User Chris Cannam # Date 1298989349 0 # Node ID 4811eb34e819d08921a6e1265dc50f699d09cade # Parent 7f50c040e13dcee72f02426d373bc0de71957208 Add Start New Branch and Cancel New Branch to uncommitted item menu; add branch name to Commit dialog diff -r 7f50c040e13d -r 4811eb34e819 changesetscene.cpp --- a/changesetscene.cpp Mon Feb 28 14:24:14 2011 +0000 +++ b/changesetscene.cpp Tue Mar 01 14:22:29 2011 +0000 @@ -77,6 +77,13 @@ connect(item, SIGNAL(showWork()), this, SIGNAL(showWork())); + + connect(item, SIGNAL(newBranch()), + this, SIGNAL(newBranch())); + + connect(item, SIGNAL(noBranch()), + this, SIGNAL(noBranch())); + } void diff -r 7f50c040e13d -r 4811eb34e819 changesetscene.h --- a/changesetscene.h Mon Feb 28 14:24:14 2011 +0000 +++ b/changesetscene.h Tue Mar 01 14:22:29 2011 +0000 @@ -44,6 +44,8 @@ void diffWorkingFolder(); void showSummary(); void showWork(); + void newBranch(); + void noBranch(); void updateTo(QString id); void diffToParent(QString id, QString parent); diff -r 7f50c040e13d -r 4811eb34e819 easyhg_en.qm Binary file easyhg_en.qm has changed diff -r 7f50c040e13d -r 4811eb34e819 easyhg_en.ts --- a/easyhg_en.ts Mon Feb 28 14:24:14 2011 +0000 +++ b/easyhg_en.ts Tue Mar 01 14:22:29 2011 +0000 @@ -588,10 +588,10 @@ - You are about to commit %n file(s). + You are about to commit %n file(s) to %1. - You are about to commit %n file. - You are about to commit %n files. + You are about to commit %n file to %1. + You are about to commit %n files to %1. diff -r 7f50c040e13d -r 4811eb34e819 grapher.cpp --- a/grapher.cpp Mon Feb 28 14:24:14 2011 +0000 +++ b/grapher.cpp Tue Mar 01 14:22:29 2011 +0000 @@ -233,6 +233,7 @@ } } + // Normally the children will lay out themselves, but we can do // a better job in some special cases: @@ -431,18 +432,32 @@ // Add uncommitted item and connecting line as necessary if (!m_uncommittedParents.empty()) { + m_uncommitted = new UncommittedItem(); m_uncommitted->setBranch(uncommittedBranch); m_uncommitted->setZValue(10); m_scene->addUncommittedItem(m_uncommitted); + + bool haveParentOnBranch = false; foreach (QString p, m_uncommittedParents) { ConnectionItem *conn = new ConnectionItem(); conn->setConnectionType(ConnectionItem::Merge); - conn->setParent(m_items[p]); + ChangesetItem *pitem = m_items[p]; + conn->setParent(pitem); conn->setChild(m_uncommitted); conn->setZValue(0); m_scene->addItem(conn); + if (pitem) { + if (pitem->getChangeset()->branch() == uncommittedBranch) { + haveParentOnBranch = true; + } + } } + + // If the uncommitted item has no parents on the same branch, + // tell it it has a new branch (the "show branch" flag is set + // elsewhere for this item) + m_uncommitted->setIsNewBranch(!haveParentOnBranch); } // Add the branch labels diff -r 7f50c040e13d -r 4811eb34e819 hgtabwidget.cpp --- a/hgtabwidget.cpp Mon Feb 28 14:24:14 2011 +0000 +++ b/hgtabwidget.cpp Tue Mar 01 14:22:29 2011 +0000 @@ -52,6 +52,12 @@ connect(m_historyWidget, SIGNAL(showSummary()), this, SIGNAL(showSummary())); + connect(m_historyWidget, SIGNAL(newBranch()), + this, SIGNAL(newBranch())); + + connect(m_historyWidget, SIGNAL(noBranch()), + this, SIGNAL(noBranch())); + connect(m_historyWidget, SIGNAL(diffWorkingFolder()), this, SIGNAL(diffWorkingFolder())); diff -r 7f50c040e13d -r 4811eb34e819 hgtabwidget.h --- a/hgtabwidget.h Mon Feb 28 14:24:14 2011 +0000 +++ b/hgtabwidget.h Tue Mar 01 14:22:29 2011 +0000 @@ -87,6 +87,8 @@ void revert(); void diffWorkingFolder(); void showSummary(); + void newBranch(); + void noBranch(); void updateTo(QString id); void diffToParent(QString id, QString parent); diff -r 7f50c040e13d -r 4811eb34e819 historywidget.cpp --- a/historywidget.cpp Mon Feb 28 14:24:14 2011 +0000 +++ b/historywidget.cpp Tue Mar 01 14:22:29 2011 +0000 @@ -268,6 +268,12 @@ connect(scene, SIGNAL(showWork()), this, SIGNAL(showWork())); + + connect(scene, SIGNAL(newBranch()), + this, SIGNAL(newBranch())); + + connect(scene, SIGNAL(noBranch()), + this, SIGNAL(noBranch())); connect(scene, SIGNAL(updateTo(QString)), this, SIGNAL(updateTo(QString))); diff -r 7f50c040e13d -r 4811eb34e819 historywidget.h --- a/historywidget.h Mon Feb 28 14:24:14 2011 +0000 +++ b/historywidget.h Tue Mar 01 14:22:29 2011 +0000 @@ -51,6 +51,8 @@ void diffWorkingFolder(); void showSummary(); void showWork(); + void newBranch(); + void noBranch(); void updateTo(QString id); void diffToParent(QString id, QString parent); diff -r 7f50c040e13d -r 4811eb34e819 mainwindow.cpp --- a/mainwindow.cpp Mon Feb 28 14:24:14 2011 +0000 +++ b/mainwindow.cpp Tue Mar 01 14:22:29 2011 +0000 @@ -429,14 +429,21 @@ QString cf(tr("Commit files")); + QString branchText; + if (m_currentBranch == "" || m_currentBranch == "default") { + branchText = tr("the default branch"); + } else { + branchText = tr("branch \"%1\"").arg(m_currentBranch); + } + if (ConfirmCommentDialog::confirmAndGetLongComment (this, cf, tr("

%1

%2%3").arg(cf) - .arg(tr("You are about to commit the following files.")) + .arg(tr("You are about to commit the following files to %1.").arg(branchText)) .arg(subsetNote), tr("

%1

%2%3").arg(cf) - .arg(tr("You are about to commit %n file(s).", "", reportFiles.size())) + .arg(tr("You are about to commit %n file(s) to %1.", "", reportFiles.size()).arg(branchText)) .arg(subsetNote), reportFiles, comment, @@ -472,7 +479,7 @@ } -void MainWindow::hgNewBranch(QString id) +void MainWindow::hgNewBranch() { QStringList params; QString branch; @@ -492,6 +499,19 @@ } +void MainWindow::hgNoBranch() +{ + if (m_currentParents.empty()) return; + + QString parentBranch = m_currentParents[0]->branch(); + if (parentBranch == "") parentBranch = "default"; + + QStringList params; + params << "branch" << parentBranch; + m_runner->requestAction(HgAction(ACT_NEW_BRANCH, m_workFolderPath, params)); +} + + void MainWindow::hgTag(QString id) { QStringList params; @@ -2173,6 +2193,12 @@ connect(m_hgTabs, SIGNAL(showSummary()), this, SLOT(hgShowSummary())); + + connect(m_hgTabs, SIGNAL(newBranch()), + this, SLOT(hgNewBranch())); + + connect(m_hgTabs, SIGNAL(noBranch()), + this, SLOT(hgNoBranch())); connect(m_hgTabs, SIGNAL(updateTo(QString)), this, SLOT(hgUpdateToRev(QString))); @@ -2190,7 +2216,7 @@ this, SLOT(hgMergeFrom(QString))); connect(m_hgTabs, SIGNAL(newBranch(QString)), - this, SLOT(hgNewBranch(QString))); + this, SLOT(hgNewBranch())); connect(m_hgTabs, SIGNAL(tag(QString)), this, SLOT(hgTag(QString))); diff -r 7f50c040e13d -r 4811eb34e819 mainwindow.h --- a/mainwindow.h Mon Feb 28 14:24:14 2011 +0000 +++ b/mainwindow.h Tue Mar 01 14:22:29 2011 +0000 @@ -90,7 +90,8 @@ void hgAnnotate(); void hgResolveList(); void hgTag(QString); - void hgNewBranch(QString); + void hgNewBranch(); + void hgNoBranch(); void hgServe(); void hgIgnore(); diff -r 7f50c040e13d -r 4811eb34e819 uncommitteditem.cpp --- a/uncommitteditem.cpp Mon Feb 28 14:24:14 2011 +0000 +++ b/uncommitteditem.cpp Tue Mar 01 14:22:29 2011 +0000 @@ -29,7 +29,8 @@ #include UncommittedItem::UncommittedItem() : - m_showBranch(false), m_column(0), m_row(0), m_wide(false) + m_showBranch(false), m_isNewBranch(false), + m_column(0), m_row(0), m_wide(false) { m_font = QFont(); m_font.setPixelSize(11); @@ -87,6 +88,14 @@ QAction *revert = menu->addAction(tr("Revert...")); connect(revert, SIGNAL(triggered()), this, SIGNAL(revert())); + menu->addSeparator(); + + QAction *branch = menu->addAction(tr("Start new branch...")); + connect(branch, SIGNAL(triggered()), this, SIGNAL(newBranch())); + QAction *nobranch = menu->addAction(tr("Cancel new branch")); + nobranch->setEnabled(m_isNewBranch); + connect(nobranch, SIGNAL(triggered()), this, SIGNAL(noBranch())); + menu->exec(QCursor::pos()); ungrabMouse(); diff -r 7f50c040e13d -r 4811eb34e819 uncommitteditem.h --- a/uncommitteditem.h Mon Feb 28 14:24:14 2011 +0000 +++ b/uncommitteditem.h Tue Mar 01 14:22:29 2011 +0000 @@ -36,6 +36,9 @@ bool showBranch() const { return m_showBranch; } void setShowBranch(bool s) { m_showBranch = s; } + + bool isNewBranch() const { return m_isNewBranch; } + void setIsNewBranch(bool s) { m_isNewBranch = s; } int column() const { return m_column; } int row() const { return m_row; } @@ -51,6 +54,8 @@ void diff(); void showSummary(); void showWork(); + void newBranch(); + void noBranch(); protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent *); @@ -61,6 +66,7 @@ QString m_branch; bool m_showBranch; + bool m_isNewBranch; QFont m_font; int m_column; int m_row;