# HG changeset patch # User Chris Cannam # Date 1292503204 0 # Node ID 4dc802a4d5ae471fc2724298782a3ad2dd29ca1b # Parent a6d336837ebe53fc89a2bf434c3901d9f47b44e2 * Add more helpful reports when a push fails because it would create new heads diff -r a6d336837ebe -r 4dc802a4d5ae mainwindow.cpp --- a/mainwindow.cpp Thu Dec 16 12:03:09 2010 +0000 +++ b/mainwindow.cpp Thu Dec 16 12:40:04 2010 +0000 @@ -1246,6 +1246,42 @@ QMessageBox::information(this, "Pull complete", report); } +void MainWindow::reportNewRemoteHeads(QString output) +{ + bool headsAreLocal = false; + + if (currentParents.size() == 1) { + int currentBranchHeads = 0; + bool parentIsHead = false; + Changeset *parent = currentParents[0]; + foreach (Changeset *head, currentHeads) { + if (head->isOnBranch(currentBranch)) { + ++currentBranchHeads; + } + if (parent->id() == head->id()) { + parentIsHead = true; + } + } + if (currentBranchHeads == 2 && parentIsHead) { + headsAreLocal = true; + } + } + + if (headsAreLocal) { + QMessageBox::warning + (this, tr("Push failed"), + format3(tr("Push failed"), + tr("Your local repository could not be pushed to the remote repository.

You may need to merge the changes locally first.

The output of the push command was:"), + output)); + } else { + QMessageBox::warning + (this, tr("Push failed"), + format3(tr("Push failed"), + tr("Your local repository could not be pushed to the remote repository.

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.

The output of the push command was:"), + output)); + } +} + void MainWindow::commandFailed(HgAction action, QString output) { DEBUG << "MainWindow::commandFailed" << endl; @@ -1274,7 +1310,11 @@ // and some return with failure codes when something as basic // as the user closing the window via the wm happens return; - + case ACT_PUSH: + if (output.contains("creates new remote heads")) { + reportNewRemoteHeads(output); + return; + } default: break; } diff -r a6d336837ebe -r 4dc802a4d5ae mainwindow.h --- a/mainwindow.h Thu Dec 16 12:03:09 2010 +0000 +++ b/mainwindow.h Thu Dec 16 12:40:04 2010 +0000 @@ -114,6 +114,7 @@ void createStatusBar(); void readSettings(); void splitChangeSets(QStringList *list, QString hgLogOutput); + void reportNewRemoteHeads(QString); void presentLongStdoutToUser(QString stdo); QString listAllUpIpV4Addresses();