comparison mainwindow.cpp @ 156:4999dbf3a266

* Another simplification to refresh logic, and some textual fixes
author Chris Cannam
date Thu, 02 Dec 2010 21:32:04 +0000
parents edab92f3ea0b
children e411bb42d934
comparison
equal deleted inserted replaced
155:edab92f3ea0b 156:4999dbf3a266
1377 // paths -> branch -> stat -> heads -> parents -> log 1377 // paths -> branch -> stat -> heads -> parents -> log
1378 // 1378 //
1379 // Note we want to call enableDisableActions only once, at the end 1379 // Note we want to call enableDisableActions only once, at the end
1380 // of whichever sequence is in use. 1380 // of whichever sequence is in use.
1381 1381
1382 bool noMore = false;
1383
1382 switch (action) { 1384 switch (action) {
1383 1385
1384 case ACT_QUERY_PATHS: 1386 case ACT_QUERY_PATHS:
1385 hgQueryBranch(); 1387 hgQueryBranch();
1386 break; 1388 break;
1408 case ACT_QUERY_PARENTS: 1410 case ACT_QUERY_PARENTS:
1409 if (needNewLog) { 1411 if (needNewLog) {
1410 hgLog(); 1412 hgLog();
1411 } else { 1413 } else {
1412 // we're done 1414 // we're done
1413 enableDisableActions(); 1415 noMore = true;
1414 } 1416 }
1415 break; 1417 break;
1416 1418
1417 case ACT_LOG: 1419 case ACT_LOG:
1418 // we're done 1420 // we're done
1419 enableDisableActions(); 1421 noMore = true;
1420 1422
1421 default: 1423 default:
1422 if (shouldHgStat) { 1424 if (shouldHgStat) {
1423 hgQueryPaths(); 1425 hgQueryPaths();
1424 } else { 1426 } else {
1425 enableDisableActions(); 1427 noMore = true;
1426 } 1428 }
1427 break; 1429 break;
1430 }
1431
1432 if (noMore) {
1433 enableDisableActions();
1434 hgTabs->updateHistory();
1428 } 1435 }
1429 } 1436 }
1430 1437
1431 void MainWindow::connectActions() 1438 void MainWindow::connectActions()
1432 { 1439 {
1585 // * our parent is one of those heads 1592 // * our parent is one of those heads
1586 // 1593 //
1587 // A default update makes sense if: 1594 // A default update makes sense if:
1588 // * there is only one parent and 1595 // * there is only one parent and
1589 // * the parent is not one of the current heads 1596 // * the parent is not one of the current heads
1590 //!!! test this 1597
1591 bool canMerge = false; 1598 bool canMerge = false;
1592 bool canUpdate = false; 1599 bool canUpdate = false;
1600 bool haveMerge = false;
1601 int currentBranchHeads = 0;
1602
1593 if (currentParents.size() == 1) { 1603 if (currentParents.size() == 1) {
1604 bool parentIsHead = false;
1594 Changeset *parent = currentParents[0]; 1605 Changeset *parent = currentParents[0];
1595 int currentBranchHeads = 0;
1596 bool parentIsHead = false;
1597 foreach (Changeset *head, currentHeads) { 1606 foreach (Changeset *head, currentHeads) {
1598 DEBUG << "head branch " << head->branch() << ", current branch " << currentBranch << endl; 1607 DEBUG << "head branch " << head->branch() << ", current branch " << currentBranch << endl;
1599 if (head->isOnBranch(currentBranch)) { 1608 if (head->isOnBranch(currentBranch)) {
1600 ++currentBranchHeads; 1609 ++currentBranchHeads;
1601 if (parent->id() == head->id()) { 1610 if (parent->id() == head->id()) {
1612 DEBUG << " head ids "<<endl; 1621 DEBUG << " head ids "<<endl;
1613 foreach (Changeset *h, currentHeads) { 1622 foreach (Changeset *h, currentHeads) {
1614 DEBUG << "head id = " << h->id() << endl; 1623 DEBUG << "head id = " << h->id() << endl;
1615 } 1624 }
1616 } 1625 }
1617 } 1626 } else {
1627 haveMerge = true;
1628 }
1629
1618 hgMergeAct->setEnabled(localRepoActionsEnabled && canMerge); 1630 hgMergeAct->setEnabled(localRepoActionsEnabled && canMerge);
1619 hgUpdateAct->setEnabled(localRepoActionsEnabled && canUpdate); 1631 hgUpdateAct->setEnabled(localRepoActionsEnabled && canUpdate);
1620 1632
1621 // Set the state field on the file status widget 1633 // Set the state field on the file status widget
1622 1634
1624 if (currentBranch == "" || currentBranch == "default") { 1636 if (currentBranch == "" || currentBranch == "default") {
1625 branchText = tr("the default branch"); 1637 branchText = tr("the default branch");
1626 } else { 1638 } else {
1627 branchText = tr("branch \"%1\"").arg(currentBranch); 1639 branchText = tr("branch \"%1\"").arg(currentBranch);
1628 } 1640 }
1629 if (canUpdate) { 1641
1642 //!!! Want "merge failed" report
1643
1644 if (canMerge) {
1645 hgTabs->setState(tr("<b>Awaiting merge</b> on %1").arg(branchText));
1646 } else if (haveMerge) {
1647 hgTabs->setState(tr("Have merged but not committed on %1").arg(branchText));
1648 } else if (canUpdate) {
1630 hgTabs->setState(tr("On %1. Not at the head of the branch: consider updating").arg(branchText)); 1649 hgTabs->setState(tr("On %1. Not at the head of the branch: consider updating").arg(branchText));
1631 } else if (canMerge) { 1650 } else if (currentBranchHeads > 1) {
1632 hgTabs->setState(tr("<b>Awaiting merge</b> on %1").arg(branchText)); 1651 hgTabs->setState(tr("At one of %n heads of %1", "", currentBranchHeads).arg(branchText));
1633 } else { 1652 } else {
1634 hgTabs->setState(tr("At the head of %1").arg(branchText)); 1653 hgTabs->setState(tr("At the head of %1").arg(branchText));
1635 } 1654 }
1636
1637 hgTabs->updateHistory();
1638 } 1655 }
1639 1656
1640 void MainWindow::createActions() 1657 void MainWindow::createActions()
1641 { 1658 {
1642 //File actions 1659 //File actions