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;