changeset 278:f7cdd5b31aed new-branches

Add "Start new branch" function. I'm not quite satisfied with the location of this one
author Chris Cannam
date Wed, 09 Feb 2011 12:03:15 +0000 (2011-02-09)
parents b6e4643d6c05
children 5b4aa1c24407
files changesetitem.cpp changesetitem.h changesetscene.cpp changesetscene.h hgaction.h hgtabwidget.cpp hgtabwidget.h historywidget.cpp historywidget.h mainwindow.cpp mainwindow.h
diffstat 11 files changed, 56 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/changesetitem.cpp	Wed Feb 09 12:02:53 2011 +0000
+++ b/changesetitem.cpp	Wed Feb 09 12:03:15 2011 +0000
@@ -153,6 +153,10 @@
 
     menu->addSeparator();
 
+    QAction *branch = menu->addAction(tr("Start new branch..."));
+    branch->setEnabled(m_current);
+    connect(branch, SIGNAL(triggered()), this, SLOT(newBranchActivated()));
+
     QAction *tag = menu->addAction(tr("Add tag..."));
     connect(tag, SIGNAL(triggered()), this, SLOT(tagActivated()));
 
@@ -190,6 +194,7 @@
 void ChangesetItem::diffToCurrentActivated() { emit diffToCurrent(getId()); }
 void ChangesetItem::mergeActivated() { emit mergeFrom(getId()); }
 void ChangesetItem::tagActivated() { emit tag(getId()); }
+void ChangesetItem::newBranchActivated() { emit newBranch(getId()); }
 
 void
 ChangesetItem::paint(QPainter *paint, const QStyleOptionGraphicsItem *option,
--- a/changesetitem.h	Wed Feb 09 12:02:53 2011 +0000
+++ b/changesetitem.h	Wed Feb 09 12:03:15 2011 +0000
@@ -64,6 +64,7 @@
     void diffToCurrent(QString);
     void diffToParent(QString child, QString parent);
     void mergeFrom(QString);
+    void newBranch(QString);
     void tag(QString);
 
 public slots:
@@ -77,6 +78,7 @@
     void diffToCurrentActivated();
     void mergeActivated();
     void tagActivated();
+    void newBranchActivated();
 
 protected:
     virtual void mousePressEvent(QGraphicsSceneMouseEvent *);
--- a/changesetscene.cpp	Wed Feb 09 12:02:53 2011 +0000
+++ b/changesetscene.cpp	Wed Feb 09 12:03:15 2011 +0000
@@ -48,6 +48,9 @@
     connect(item, SIGNAL(mergeFrom(QString)),
             this, SIGNAL(mergeFrom(QString)));
 
+    connect(item, SIGNAL(newBranch(QString)),
+            this, SIGNAL(newBranch(QString)));
+
     connect(item, SIGNAL(tag(QString)),
             this, SIGNAL(tag(QString)));
 }
--- a/changesetscene.h	Wed Feb 09 12:02:53 2011 +0000
+++ b/changesetscene.h	Wed Feb 09 12:03:15 2011 +0000
@@ -46,6 +46,7 @@
     void diffToParent(QString id, QString parent);
     void diffToCurrent(QString id);
     void mergeFrom(QString id);
+    void newBranch(QString id);
     void tag(QString id);
 
 private slots:
--- a/hgaction.h	Wed Feb 09 12:02:53 2011 +0000
+++ b/hgaction.h	Wed Feb 09 12:03:15 2011 +0000
@@ -53,6 +53,7 @@
     ACT_RESOLVE_MARK,
     ACT_RETRY_MERGE,
     ACT_TAG,
+    ACT_NEW_BRANCH,
     ACT_HG_IGNORE,
 };
 
--- a/hgtabwidget.cpp	Wed Feb 09 12:02:53 2011 +0000
+++ b/hgtabwidget.cpp	Wed Feb 09 12:03:15 2011 +0000
@@ -72,6 +72,9 @@
     connect(m_historyWidget, SIGNAL(mergeFrom(QString)),
             this, SIGNAL(mergeFrom(QString)));
 
+    connect(m_historyWidget, SIGNAL(newBranch(QString)),
+            this, SIGNAL(newBranch(QString)));
+
     connect(m_historyWidget, SIGNAL(tag(QString)),
             this, SIGNAL(tag(QString)));
 }
--- a/hgtabwidget.h	Wed Feb 09 12:02:53 2011 +0000
+++ b/hgtabwidget.h	Wed Feb 09 12:03:15 2011 +0000
@@ -93,6 +93,7 @@
     void diffToParent(QString id, QString parent);
     void diffToCurrent(QString id);
     void mergeFrom(QString id);
+    void newBranch(QString id);
     void tag(QString id);
 
 public slots:
--- a/historywidget.cpp	Wed Feb 09 12:02:53 2011 +0000
+++ b/historywidget.cpp	Wed Feb 09 12:03:15 2011 +0000
@@ -280,6 +280,9 @@
     connect(scene, SIGNAL(mergeFrom(QString)),
             this, SIGNAL(mergeFrom(QString)));
 
+    connect(scene, SIGNAL(newBranch(QString)),
+            this, SIGNAL(newBranch(QString)));
+
     connect(scene, SIGNAL(tag(QString)),
             this, SIGNAL(tag(QString)));
 }
--- a/historywidget.h	Wed Feb 09 12:02:53 2011 +0000
+++ b/historywidget.h	Wed Feb 09 12:03:15 2011 +0000
@@ -56,6 +56,7 @@
     void diffToParent(QString id, QString parent);
     void diffToCurrent(QString id);
     void mergeFrom(QString id);
+    void newBranch(QString id);
     void tag(QString id);
     
 private:
--- a/mainwindow.cpp	Wed Feb 09 12:02:53 2011 +0000
+++ b/mainwindow.cpp	Wed Feb 09 12:03:15 2011 +0000
@@ -447,14 +447,11 @@
 
 QString MainWindow::filterTag(QString tag)
 {
-    for(int i = 0; i < tag.size(); i++)
-    {
-        if (tag[i].isLower() || tag[i].isUpper() || tag[i].isDigit() || (tag[i] == QChar('.')))
-        {
+    for(int i = 0; i < tag.size(); i++) {
+        if (tag[i].isLower() || tag[i].isUpper() ||
+            tag[i].isDigit() || (tag[i] == QChar('.'))) {
             //ok
-        }
-        else
-        {
+        } else {
             tag[i] = QChar('_');
         }
     }
@@ -462,6 +459,26 @@
 }
 
 
+void MainWindow::hgNewBranch(QString id)
+{
+    QStringList params;
+    QString branch;
+
+    if (ConfirmCommentDialog::confirmAndGetShortComment
+        (this,
+         tr("New Branch"),
+         tr("Enter new branch name:"),
+         branch,
+         tr("Start Branch"))) {
+        if (!branch.isEmpty()) {//!!! do something better if it is empty
+
+            params << "branch" << filterTag(branch);
+            runner->requestAction(HgAction(ACT_NEW_BRANCH, workFolderPath, params));
+        }
+    }
+}
+
+
 void MainWindow::hgTag(QString id)
 {
     QStringList params;
@@ -1695,6 +1712,9 @@
     case ACT_INCOMING:
         // returns non-zero code and no output if the check was
         // successful but there are no changes pending
+
+        //!!! -- won't do, there may legitimately be warnings,
+        //!!! -- e.g. certificate not verified
         if (output.trimmed() == "") {
             showIncoming("");
             return;
@@ -1897,6 +1917,11 @@
         shouldHgStat = true;
         break;
 
+    case ACT_NEW_BRANCH:
+        shouldHgStat = true;
+        hgTabs->showWorkTab();
+        break;
+
     case ACT_DIFF_SUMMARY:
         QMessageBox::information(this, tr("Change summary"),
                                  format3(tr("Summary of uncommitted changes"),
@@ -2082,6 +2107,9 @@
     connect(hgTabs, SIGNAL(mergeFrom(QString)),
             this, SLOT(hgMergeFrom(QString)));
 
+    connect(hgTabs, SIGNAL(newBranch(QString)),
+            this, SLOT(hgNewBranch(QString)));
+
     connect(hgTabs, SIGNAL(tag(QString)),
             this, SLOT(hgTag(QString)));
 }    
--- a/mainwindow.h	Wed Feb 09 12:02:53 2011 +0000
+++ b/mainwindow.h	Wed Feb 09 12:03:15 2011 +0000
@@ -101,6 +101,7 @@
     void hgAnnotate();
     void hgResolveList();
     void hgTag(QString);
+    void hgNewBranch(QString);
     void hgServe();
     void hgIgnore();