comparison 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
comparison
equal deleted inserted replaced
234:482802b6d306 235:2f4d401ce47c
2035 bool canMerge = false; 2035 bool canMerge = false;
2036 bool canUpdate = false; 2036 bool canUpdate = false;
2037 bool haveMerge = false; 2037 bool haveMerge = false;
2038 bool emptyRepo = false; 2038 bool emptyRepo = false;
2039 bool noWorkingCopy = false; 2039 bool noWorkingCopy = false;
2040 bool newBranch = false;
2040 int currentBranchHeads = 0; 2041 int currentBranchHeads = 0;
2041 2042
2042 if (currentParents.size() == 1) { 2043 if (currentParents.size() == 1) {
2043 bool parentIsHead = false; 2044 bool parentIsHead = false;
2044 Changeset *parent = currentParents[0]; 2045 Changeset *parent = currentParents[0];
2045 foreach (Changeset *head, currentHeads) { 2046 foreach (Changeset *head, currentHeads) {
2046 DEBUG << "head branch " << head->branch() << ", current branch " << currentBranch << endl; 2047 DEBUG << "head branch " << head->branch() << ", current branch " << currentBranch << endl;
2047 if (head->isOnBranch(currentBranch)) { 2048 if (head->isOnBranch(currentBranch)) {
2048 ++currentBranchHeads; 2049 ++currentBranchHeads;
2049 if (parent->id() == head->id()) { 2050 }
2050 parentIsHead = true; 2051 if (parent->id() == head->id()) {
2051 } 2052 parentIsHead = true;
2052 } 2053 }
2053 } 2054 }
2054 if (currentBranchHeads == 2 && parentIsHead) { 2055 if (currentBranchHeads == 2 && parentIsHead) {
2055 canMerge = true; 2056 canMerge = true;
2057 }
2058 if (currentBranchHeads == 0 && parentIsHead) {
2059 // Just created a new branch
2060 newBranch = true;
2056 } 2061 }
2057 if (!parentIsHead) { 2062 if (!parentIsHead) {
2058 canUpdate = true; 2063 canUpdate = true;
2059 DEBUG << "parent id = " << parent->id() << endl; 2064 DEBUG << "parent id = " << parent->id() << endl;
2060 DEBUG << " head ids "<<endl; 2065 DEBUG << " head ids "<<endl;
2102 hgTabs->setState(tr("<b>Awaiting merge</b> on %1").arg(branchText)); 2107 hgTabs->setState(tr("<b>Awaiting merge</b> on %1").arg(branchText));
2103 } else if (!hgTabs->getAllUnresolvedFiles().empty()) { 2108 } else if (!hgTabs->getAllUnresolvedFiles().empty()) {
2104 hgTabs->setState(tr("Have unresolved files following merge on %1").arg(branchText)); 2109 hgTabs->setState(tr("Have unresolved files following merge on %1").arg(branchText));
2105 } else if (haveMerge) { 2110 } else if (haveMerge) {
2106 hgTabs->setState(tr("Have merged but not yet committed on %1").arg(branchText)); 2111 hgTabs->setState(tr("Have merged but not yet committed on %1").arg(branchText));
2112 } else if (newBranch) {
2113 hgTabs->setState(tr("On %1. New branch: has not yet been committed").arg(branchText));
2107 } else if (canUpdate) { 2114 } else if (canUpdate) {
2108 if (hgTabs->haveChangesToCommit()) { 2115 if (hgTabs->haveChangesToCommit()) {
2109 // have uncommitted changes 2116 // have uncommitted changes
2110 hgTabs->setState(tr("On %1. Not at the head of the branch").arg(branchText)); 2117 hgTabs->setState(tr("On %1. Not at the head of the branch").arg(branchText));
2111 } else { 2118 } else {