diff mainwindow.cpp @ 235:2f4d401ce47c

* Better handling for case where we've just created a new branch but not yet committed it (i.e. no heads are on our current branch)
author Chris Cannam
date Fri, 07 Jan 2011 21:58:38 +0000
parents e67bd8abc3e3
children c9a7e4ec2f78
line wrap: on
line diff
--- a/mainwindow.cpp	Thu Jan 06 16:06:53 2011 +0000
+++ b/mainwindow.cpp	Fri Jan 07 21:58:38 2011 +0000
@@ -2037,6 +2037,7 @@
     bool haveMerge = false;
     bool emptyRepo = false;
     bool noWorkingCopy = false;
+    bool newBranch = false;
     int currentBranchHeads = 0;
 
     if (currentParents.size() == 1) {
@@ -2046,14 +2047,18 @@
             DEBUG << "head branch " << head->branch() << ", current branch " << currentBranch << endl;
             if (head->isOnBranch(currentBranch)) {
                 ++currentBranchHeads;
-                if (parent->id() == head->id()) {
-                    parentIsHead = true;
-                }
+            }
+            if (parent->id() == head->id()) {
+                parentIsHead = true;
             }
         }
         if (currentBranchHeads == 2 && parentIsHead) {
             canMerge = true;
         }
+        if (currentBranchHeads == 0 && parentIsHead) {
+            // Just created a new branch
+            newBranch = true;
+        }
         if (!parentIsHead) {
             canUpdate = true;
             DEBUG << "parent id = " << parent->id() << endl;
@@ -2104,6 +2109,8 @@
         hgTabs->setState(tr("Have unresolved files following merge on %1").arg(branchText));
     } else if (haveMerge) {
         hgTabs->setState(tr("Have merged but not yet committed on %1").arg(branchText));
+    } else if (newBranch) {
+        hgTabs->setState(tr("On %1.  New branch: has not yet been committed").arg(branchText));
     } else if (canUpdate) {
         if (hgTabs->haveChangesToCommit()) {
             // have uncommitted changes