comparison mainwindow.cpp @ 296:d40294e164da status_outside_tabs

Merge from the default branch
author Chris Cannam
date Tue, 22 Feb 2011 13:03:03 +0000
parents 3fbafca196e4 01a471e9cbe3
children 3bb6b63420ad
comparison
equal deleted inserted replaced
287:3fbafca196e4 296:d40294e164da
41 #include "debug.h" 41 #include "debug.h"
42 #include "logparser.h" 42 #include "logparser.h"
43 #include "confirmcommentdialog.h" 43 #include "confirmcommentdialog.h"
44 #include "incomingdialog.h" 44 #include "incomingdialog.h"
45 #include "settingsdialog.h" 45 #include "settingsdialog.h"
46 #include "moreinformationdialog.h"
46 #include "version.h" 47 #include "version.h"
47 #include "workstatuswidget.h" 48 #include "workstatuswidget.h"
48 49
49 50
50 MainWindow::MainWindow(QString myDirPath) : 51 MainWindow::MainWindow(QString myDirPath) :
545 { 546 {
546 QStringList params; 547 QStringList params;
547 548
548 params << "diff" << "--stat"; 549 params << "diff" << "--stat";
549 550
550 m_runner->requestAction(HgAction(ACT_DIFF_SUMMARY, m_workFolderPath, params)); 551 m_runner->requestAction(HgAction(ACT_UNCOMMITTED_SUMMARY, m_workFolderPath, params));
551 } 552 }
552 553
553 void MainWindow::hgFolderDiff() 554 void MainWindow::hgFolderDiff()
554 { 555 {
555 QString diff = getDiffBinaryName(); 556 QString diff = getDiffBinaryName();
598 params << "--program" << diff; 599 params << "--program" << diff;
599 params << "--rev" << Changeset::hashOf(parent) 600 params << "--rev" << Changeset::hashOf(parent)
600 << "--rev" << Changeset::hashOf(child); 601 << "--rev" << Changeset::hashOf(child);
601 602
602 m_runner->requestAction(HgAction(ACT_CHGSETDIFF, m_workFolderPath, params)); 603 m_runner->requestAction(HgAction(ACT_CHGSETDIFF, m_workFolderPath, params));
604 }
605
606
607 void MainWindow::hgShowSummaryFor(Changeset *cs)
608 {
609 QStringList params;
610
611 // This will pick a default parent if there is more than one
612 // (whereas with diff we need to supply one). But it does need a
613 // bit more parsing
614 params << "log" << "--stat" << "--rev" << Changeset::hashOf(cs->id());
615
616 m_runner->requestAction(HgAction(ACT_DIFF_SUMMARY, m_workFolderPath,
617 params, cs));
603 } 618 }
604 619
605 620
606 void MainWindow::hgUpdate() 621 void MainWindow::hgUpdate()
607 { 622 {
845 860
846 void MainWindow::hgPull() 861 void MainWindow::hgPull()
847 { 862 {
848 if (ConfirmCommentDialog::confirm 863 if (ConfirmCommentDialog::confirm
849 (this, tr("Confirm pull"), 864 (this, tr("Confirm pull"),
850 format3(tr("Confirm pull from remote repository"), 865 format3(tr("Pull from remote repository?"),
851 tr("You are about to pull changes from the following remote repository:"), 866 tr("You are about to pull changes from the following remote repository:"),
852 m_remoteRepoPath), 867 m_remoteRepoPath),
853 tr("Pull"))) { 868 tr("Pull"))) {
854 869
855 QStringList params; 870 QStringList params;
860 875
861 void MainWindow::hgPush() 876 void MainWindow::hgPush()
862 { 877 {
863 if (ConfirmCommentDialog::confirm 878 if (ConfirmCommentDialog::confirm
864 (this, tr("Confirm push"), 879 (this, tr("Confirm push"),
865 format3(tr("Confirm push to remote repository"), 880 format3(tr("Push to remote repository?"),
866 tr("You are about to push your changes to the following remote repository:"), 881 tr("You are about to push your changes to the following remote repository:"),
867 m_remoteRepoPath), 882 m_remoteRepoPath),
868 tr("Push"))) { 883 tr("Push"))) {
869 884
870 QStringList params; 885 QStringList params;
1529 if (!m_fsWatcherSuspended) { 1544 if (!m_fsWatcherSuspended) {
1530 hgStat(); 1545 hgStat();
1531 } 1546 }
1532 } 1547 }
1533 1548
1549 QString MainWindow::format1(QString head)
1550 {
1551 return QString("<qt><h3>%1</h3></qt>").arg(head);
1552 }
1553
1534 QString MainWindow::format3(QString head, QString intro, QString code) 1554 QString MainWindow::format3(QString head, QString intro, QString code)
1535 { 1555 {
1536 code = xmlEncode(code).replace("\n", "<br>") 1556 code = xmlEncode(code).replace("\n", "<br>")
1537 #ifndef Q_OS_WIN32 1557 #ifndef Q_OS_WIN32
1538 // The hard hyphen comes out funny on Windows 1558 // The hard hyphen comes out funny on Windows
1571 } 1591 }
1572 } 1592 }
1573 1593
1574 void MainWindow::showPushResult(QString output) 1594 void MainWindow::showPushResult(QString output)
1575 { 1595 {
1596 QString head;
1576 QString report; 1597 QString report;
1577 int n = extractChangeCount(output); 1598 int n = extractChangeCount(output);
1578 if (n > 0) { 1599 if (n > 0) {
1579 report = tr("Pushed %n changeset(s)", "", n); 1600 head = tr("Pushed %n changeset(s)", "", n);
1580 } else if (n == 0) { 1601 } else if (n == 0) {
1581 report = tr("No changes to push"); 1602 head = tr("No changes to push");
1603 report = tr("The remote repository already contains all changes that have been committed locally.");
1604 if (m_hgTabs->canCommit()) {
1605 report = tr("%1<p>You do have some uncommitted changes. If you wish to push those to the remote repository, commit them locally first.").arg(report);
1606 }
1582 } else { 1607 } else {
1583 report = tr("Push complete"); 1608 head = tr("Push complete");
1584 } 1609 }
1585 report = format3(report, tr("The push command output was:"), output);
1586 m_runner->hide(); 1610 m_runner->hide();
1587 QMessageBox::information(this, "Push complete", report); 1611
1612 MoreInformationDialog::information(this, tr("Push complete"),
1613 head, report, output);
1588 } 1614 }
1589 1615
1590 void MainWindow::showPullResult(QString output) 1616 void MainWindow::showPullResult(QString output)
1591 { 1617 {
1618 QString head;
1592 QString report; 1619 QString report;
1593 int n = extractChangeCount(output); 1620 int n = extractChangeCount(output);
1594 if (n > 0) { 1621 if (n > 0) {
1595 report = tr("Pulled %n changeset(s)", "", n); 1622 head = tr("Pulled %n changeset(s)", "", n);
1623 report = tr("New changes will be highlighted in the history. Update to bring these changes into your working copy.");
1596 } else if (n == 0) { 1624 } else if (n == 0) {
1597 report = tr("No changes to pull"); 1625 head = tr("No changes to pull");
1626 report = tr("Your local repository already contains all changes found in the remote repository.");
1598 } else { 1627 } else {
1599 report = tr("Pull complete"); 1628 head = tr("Pull complete");
1600 } 1629 }
1601 report = format3(report, tr("The pull command output was:"), output);
1602 m_runner->hide(); 1630 m_runner->hide();
1603 1631
1604 //!!! and something about updating 1632 MoreInformationDialog::information(this, tr("Pull complete"),
1605 1633 head, report, output);
1606 QMessageBox::information(this, "Pull complete", report);
1607 } 1634 }
1608 1635
1609 void MainWindow::reportNewRemoteHeads(QString output) 1636 void MainWindow::reportNewRemoteHeads(QString output)
1610 { 1637 {
1611 bool headsAreLocal = false; 1638 bool headsAreLocal = false;
1626 headsAreLocal = true; 1653 headsAreLocal = true;
1627 } 1654 }
1628 } 1655 }
1629 1656
1630 if (headsAreLocal) { 1657 if (headsAreLocal) {
1631 QMessageBox::warning 1658 MoreInformationDialog::warning
1632 (this, tr("Push failed"), 1659 (this,
1633 format3(tr("Push failed"), 1660 tr("Push failed"),
1634 tr("Your local repository could not be pushed to the remote repository.<br><br>You may need to merge the changes locally first.<br><br>The output of the push command was:"), 1661 tr("Push failed"),
1635 output)); 1662 tr("Your local repository could not be pushed to the remote repository.<br><br>You may need to merge the changes locally first."),
1663 output);
1636 } else { 1664 } else {
1637 QMessageBox::warning 1665 MoreInformationDialog::warning
1638 (this, tr("Push failed"), 1666 (this,
1639 format3(tr("Push failed"), 1667 tr("Push failed"),
1640 tr("Your local repository could not be pushed to the remote repository.<br><br>The remote repository may have been changed by someone else since you last pushed. Try pulling and merging their changes into your local repository first.<br><br>The output of the push command was:"), 1668 tr("Push failed"),
1641 output)); 1669 tr("Your local repository could not be pushed to the remote repository.<br><br>The remote repository may have been changed by someone else since you last pushed. Try pulling and merging their changes into your local repository first."),
1670 output);
1642 } 1671 }
1643 } 1672 }
1644 1673
1645 void MainWindow::commandStarting(HgAction action) 1674 void MainWindow::commandStarting(HgAction action)
1646 { 1675 {
1672 switch(action.action) { 1701 switch(action.action) {
1673 case ACT_NONE: 1702 case ACT_NONE:
1674 // uh huh 1703 // uh huh
1675 return; 1704 return;
1676 case ACT_TEST_HG: 1705 case ACT_TEST_HG:
1677 QMessageBox::warning 1706 MoreInformationDialog::warning
1678 (this, tr("Failed to run Mercurial"), 1707 (this,
1679 format3(tr("Failed to run Mercurial"), 1708 tr("Failed to run Mercurial"),
1680 tr("The Mercurial program either could not be found or failed to run.<br>Check that the Mercurial program path is correct in %1.<br><br>%2").arg(setstr).arg(output == "" ? QString("") : tr("The test command said:")), 1709 tr("Failed to run Mercurial"),
1681 output)); 1710 tr("The Mercurial program either could not be found or failed to run.<br>Check that the Mercurial program path is correct in %1.").arg(setstr),
1711 output);
1682 settings(); 1712 settings();
1683 return; 1713 return;
1684 case ACT_TEST_HG_EXT: 1714 case ACT_TEST_HG_EXT:
1685 QMessageBox::warning 1715 QMessageBox::warning
1686 (this, tr("Failed to run Mercurial"), 1716 (this,
1687 format3(tr("Failed to run Mercurial with extension enabled"), 1717 tr("Failed to run Mercurial"),
1688 tr("The Mercurial program failed to run with the EasyMercurial interaction extension enabled.<br>This may indicate an installation problem with EasyMercurial.<br><br>You may be able to continue working if you switch off &ldquo;Use EasyHg Mercurial Extension&rdquo; in %1. Note that remote repositories that require authentication may not work if you do this.<br><br>%2").arg(setstr).arg(output == "" ? QString("") : tr("The test command said:")), 1718 tr("Failed to run Mercurial with extension enabled"),
1689 output)); 1719 tr("The Mercurial program failed to run with the EasyMercurial interaction extension enabled.<br>This may indicate an installation problem with EasyMercurial.<br><br>You may be able to continue working if you switch off &ldquo;Use EasyHg Mercurial Extension&rdquo; in %1. Note that remote repositories that require authentication may not work if you do this.").arg(setstr),
1720 output);
1690 settings(); 1721 settings();
1691 return; 1722 return;
1692 case ACT_CLONEFROMREMOTE: 1723 case ACT_CLONEFROMREMOTE:
1693 // if clone fails, we have no repo 1724 // if clone fails, we have no repo
1694 m_workFolderPath = ""; 1725 m_workFolderPath = "";
1730 if (command == "") command = "hg"; 1761 if (command == "") command = "hg";
1731 foreach (QString arg, action.params) { 1762 foreach (QString arg, action.params) {
1732 command += " " + arg; 1763 command += " " + arg;
1733 } 1764 }
1734 1765
1766 //!!!
1767
1735 QString message = tr("<qt><h3>Command failed</h3>" 1768 QString message = tr("<qt><h3>Command failed</h3>"
1736 "<p>The following command failed:</p>" 1769 "<p>The following command failed:</p>"
1737 "<code>%1</code>" 1770 "<code>%1</code>"
1738 "%2</qt>") 1771 "%2</qt>")
1739 .arg(command) 1772 .arg(command)
1838 1871
1839 case ACT_CLONEFROMREMOTE: 1872 case ACT_CLONEFROMREMOTE:
1840 MultiChoiceDialog::addRecentArgument("local", m_workFolderPath); 1873 MultiChoiceDialog::addRecentArgument("local", m_workFolderPath);
1841 MultiChoiceDialog::addRecentArgument("remote", m_remoteRepoPath); 1874 MultiChoiceDialog::addRecentArgument("remote", m_remoteRepoPath);
1842 MultiChoiceDialog::addRecentArgument("remote", m_workFolderPath, true); 1875 MultiChoiceDialog::addRecentArgument("remote", m_workFolderPath, true);
1843 QMessageBox::information(this, tr("Clone"), tr("<qt><h3>Clone successful</h3><pre>%1</pre>").arg(xmlEncode(output))); 1876 MoreInformationDialog::information
1877 (this,
1878 tr("Clone"),
1879 tr("Clone successful"),
1880 tr("The remote repository was successfully cloned to the local folder <code>%1</code>.").arg(xmlEncode(m_workFolderPath)),
1881 output);
1844 enableDisableActions(); 1882 enableDisableActions();
1845 m_shouldHgStat = true; 1883 m_shouldHgStat = true;
1846 break; 1884 break;
1847 1885
1848 case ACT_LOG: 1886 case ACT_LOG:
1897 case ACT_TAG: 1935 case ACT_TAG:
1898 m_needNewLog = true; 1936 m_needNewLog = true;
1899 m_shouldHgStat = true; 1937 m_shouldHgStat = true;
1900 break; 1938 break;
1901 1939
1902 case ACT_DIFF_SUMMARY: 1940 case ACT_UNCOMMITTED_SUMMARY:
1903 QMessageBox::information(this, tr("Change summary"), 1941 QMessageBox::information(this, tr("Change summary"),
1904 format3(tr("Summary of uncommitted changes"), 1942 format3(tr("Summary of uncommitted changes"),
1905 "", 1943 "",
1906 output)); 1944 output));
1907 break; 1945 break;
1946
1947 case ACT_DIFF_SUMMARY:
1948 {
1949 // Output has log info first, diff following after a blank line
1950 output.replace("\r\n", "\n");
1951 QStringList olist = output.split("\n\n", QString::SkipEmptyParts);
1952 if (olist.size() > 1) output = olist[1];
1953
1954 Changeset *cs = (Changeset *)completedAction.extraData;
1955 if (cs) {
1956 QMessageBox::information
1957 (this, tr("Change summary"),
1958 format3(tr("Summary of changes"),
1959 cs->formatHtml(),
1960 output));
1961 } else if (output == "") {
1962 // Can happen, for a merge commit (depending on parent)
1963 QMessageBox::information(this, tr("Change summary"),
1964 format3(tr("Summary of changes"),
1965 tr("No changes"),
1966 output));
1967 } else {
1968 QMessageBox::information(this, tr("Change summary"),
1969 format3(tr("Summary of changes"),
1970 "",
1971 output));
1972 }
1973 break;
1974 }
1908 1975
1909 case ACT_FOLDERDIFF: 1976 case ACT_FOLDERDIFF:
1910 case ACT_CHGSETDIFF: 1977 case ACT_CHGSETDIFF:
1911 case ACT_SERVE: 1978 case ACT_SERVE:
1912 case ACT_HG_IGNORE: 1979 case ACT_HG_IGNORE:
1917 QMessageBox::information(this, tr("Update"), tr("<qt><h3>Update successful</h3><p>%1</p>").arg(xmlEncode(output))); 1984 QMessageBox::information(this, tr("Update"), tr("<qt><h3>Update successful</h3><p>%1</p>").arg(xmlEncode(output)));
1918 m_shouldHgStat = true; 1985 m_shouldHgStat = true;
1919 break; 1986 break;
1920 1987
1921 case ACT_MERGE: 1988 case ACT_MERGE:
1922 //!!! use format3? 1989 MoreInformationDialog::information
1923 QMessageBox::information(this, tr("Merge"), tr("<qt><h3>Merge successful</h3><pre>%1</pre>").arg(xmlEncode(output))); 1990 (this, tr("Merge"), tr("Merge successful"),
1991 tr("The merge succeeded. Remember to commit the result!"),
1992 output);
1924 m_shouldHgStat = true; 1993 m_shouldHgStat = true;
1925 m_justMerged = true; 1994 m_justMerged = true;
1926 break; 1995 break;
1927 1996
1928 case ACT_RETRY_MERGE: 1997 case ACT_RETRY_MERGE:
2078 connect(m_hgTabs, SIGNAL(diffToCurrent(QString)), 2147 connect(m_hgTabs, SIGNAL(diffToCurrent(QString)),
2079 this, SLOT(hgDiffToCurrent(QString))); 2148 this, SLOT(hgDiffToCurrent(QString)));
2080 2149
2081 connect(m_hgTabs, SIGNAL(diffToParent(QString, QString)), 2150 connect(m_hgTabs, SIGNAL(diffToParent(QString, QString)),
2082 this, SLOT(hgDiffToParent(QString, QString))); 2151 this, SLOT(hgDiffToParent(QString, QString)));
2152
2153 connect(m_hgTabs, SIGNAL(showSummary(Changeset *)),
2154 this, SLOT(hgShowSummaryFor(Changeset *)));
2083 2155
2084 connect(m_hgTabs, SIGNAL(mergeFrom(QString)), 2156 connect(m_hgTabs, SIGNAL(mergeFrom(QString)),
2085 this, SLOT(hgMergeFrom(QString))); 2157 this, SLOT(hgMergeFrom(QString)));
2086 2158
2087 connect(m_hgTabs, SIGNAL(tag(QString)), 2159 connect(m_hgTabs, SIGNAL(tag(QString)),