diff mainwindow.cpp @ 311:4811eb34e819 new-branches-with-status-outside-tabs

Add Start New Branch and Cancel New Branch to uncommitted item menu; add branch name to Commit dialog
author Chris Cannam
date Tue, 01 Mar 2011 14:22:29 +0000
parents 7f50c040e13d
children f98c8ece3035
line wrap: on
line diff
--- 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("<h3>%1</h3><p>%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("<h3>%1</h3><p>%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)));