comparison mainwindow.cpp @ 354:f08ecba0f17b

Merge from branch "feature_104"
author Chris Cannam
date Thu, 17 Mar 2011 12:51:32 +0000
parents 93feb59187f5
children 368b96a87c43
comparison
equal deleted inserted replaced
352:383223b1dd34 354:f08ecba0f17b
1720 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."), 1720 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."),
1721 output); 1721 output);
1722 } 1722 }
1723 } 1723 }
1724 1724
1725 void MainWindow::reportAuthFailed(QString output)
1726 {
1727 MoreInformationDialog::warning
1728 (this,
1729 tr("Authorization failed"),
1730 tr("Authorization failed"),
1731 tr("You may have entered an incorrect user name or password, or the remote URL may be wrong.<br><br>Or you may lack the necessary permissions on the remote repository.<br><br>Check with the administrator of your remote repository if necessary."),
1732 output);
1733 }
1734
1725 void MainWindow::commandStarting(HgAction action) 1735 void MainWindow::commandStarting(HgAction action)
1726 { 1736 {
1727 // Annoyingly, hg stat actually modifies the working directory -- 1737 // Annoyingly, hg stat actually modifies the working directory --
1728 // it creates files called hg-checklink and hg-checkexec to test 1738 // it creates files called hg-checklink and hg-checkexec to test
1729 // properties of the filesystem. For safety's sake, suspend the 1739 // properties of the filesystem. For safety's sake, suspend the
1745 setstr = tr("Preferences"); 1755 setstr = tr("Preferences");
1746 #else 1756 #else
1747 setstr = tr("Settings"); 1757 setstr = tr("Settings");
1748 #endif 1758 #endif
1749 1759
1750 // Some commands we just have to ignore bad return values from: 1760 // Some commands we just have to ignore bad return values from,
1761 // and some output gets special treatment.
1762
1763 // Note our fallback case should always be to report a
1764 // non-specific error and show the text -- in case output scraping
1765 // fails (as it surely will). Note also that we must force the
1766 // locale in order to ensure the output is scrapable; this happens
1767 // in HgRunner and may break some system encodings.
1751 1768
1752 switch(action.action) { 1769 switch(action.action) {
1753 case ACT_NONE: 1770 case ACT_NONE:
1754 // uh huh 1771 // uh huh
1755 return; 1772 return;
1775 // if clone fails, we have no repo 1792 // if clone fails, we have no repo
1776 m_workFolderPath = ""; 1793 m_workFolderPath = "";
1777 enableDisableActions(); 1794 enableDisableActions();
1778 break; // go on to default report 1795 break; // go on to default report
1779 case ACT_INCOMING: 1796 case ACT_INCOMING:
1780 // returns non-zero code and no output if the check was 1797 if (output.contains("authorization failed")) {
1781 // successful but there are no changes pending 1798 reportAuthFailed(output);
1782 { 1799 return;
1800 } else {
1801 // Incoming returns non-zero code and no output if the
1802 // check was successful but there are no changes
1803 // pending. This is the only case where we need to remove
1804 // warning messages, because it's the only case where a
1805 // non-zero code can be returned even though the command
1806 // has for our purposes succeeded
1783 QString replaced = output; 1807 QString replaced = output;
1784 while (1) { 1808 while (1) {
1785 QString r1 = replaced; 1809 QString r1 = replaced;
1786 r1.replace(QRegExp("warning: [^\\n]*"), ""); 1810 r1.replace(QRegExp("warning: [^\\n]*"), "");
1787 if (r1 == replaced) break; 1811 if (r1 == replaced) break;
1788 replaced = r1.trimmed(); 1812 replaced = r1.trimmed();
1789 } 1813 }
1790 // DEBUG << "incoming: text is " << output << endl;
1791 // DEBUG << "replaced is " << replaced << endl;
1792 if (replaced == "") { 1814 if (replaced == "") {
1793 showIncoming(""); 1815 showIncoming("");
1794 return; 1816 return;
1795 } 1817 }
1818 }
1819 break; // go on to default report
1820 case ACT_PULL:
1821 if (output.contains("authorization failed")) {
1822 reportAuthFailed(output);
1823 return;
1824 }
1825 break; // go on to default report
1826 case ACT_PUSH:
1827 if (output.contains("creates new remote heads")) {
1828 reportNewRemoteHeads(output);
1829 return;
1830 } else if (output.contains("authorization failed")) {
1831 reportAuthFailed(output);
1832 return;
1796 } 1833 }
1797 break; // go on to default report 1834 break; // go on to default report
1798 case ACT_QUERY_HEADS: 1835 case ACT_QUERY_HEADS:
1799 // fails if repo is empty; we don't care (if there's a genuine 1836 // fails if repo is empty; we don't care (if there's a genuine
1800 // problem, something else will fail too). Pretend it 1837 // problem, something else will fail too). Pretend it
1806 case ACT_CHGSETDIFF: 1843 case ACT_CHGSETDIFF:
1807 // external program, unlikely to be anything useful in stderr 1844 // external program, unlikely to be anything useful in stderr
1808 // and some return with failure codes when something as basic 1845 // and some return with failure codes when something as basic
1809 // as the user closing the window via the wm happens 1846 // as the user closing the window via the wm happens
1810 return; 1847 return;
1811 case ACT_PUSH:
1812 if (output.contains("creates new remote heads")) {
1813 reportNewRemoteHeads(output);
1814 return;
1815 }
1816 break; // go on to default report
1817 case ACT_MERGE: 1848 case ACT_MERGE:
1818 case ACT_RETRY_MERGE: 1849 case ACT_RETRY_MERGE:
1819 MoreInformationDialog::information 1850 MoreInformationDialog::information
1820 (this, tr("Merge"), tr("Merge failed"), 1851 (this, tr("Merge"), tr("Merge failed"),
1821 tr("Some files were not merged successfully.<p>You can Merge again to repeat the interactive merge; use Revert to abandon the merge entirely; or edit the files that are in conflict in an editor and, when you are happy with them, choose Mark Resolved in each file's right-button menu."), 1852 tr("Some files were not merged successfully.<p>You can Merge again to repeat the interactive merge; use Revert to abandon the merge entirely; or edit the files that are in conflict in an editor and, when you are happy with them, choose Mark Resolved in each file's right-button menu."),