comparison mainwindow.cpp @ 157:e411bb42d934

* Default merge comments
author Chris Cannam
date Thu, 02 Dec 2010 21:52:24 +0000
parents 4999dbf3a266
children 910c2c5d1873
comparison
equal deleted inserted replaced
156:4999dbf3a266 157:e411bb42d934
312 void MainWindow::hgCommit() 312 void MainWindow::hgCommit()
313 { 313 {
314 QStringList params; 314 QStringList params;
315 QString comment; 315 QString comment;
316 316
317 if (justMerged) {
318 comment = mergeCommitComment;
319 }
320
317 QStringList files = hgTabs->getSelectedCommittableFiles(); 321 QStringList files = hgTabs->getSelectedCommittableFiles();
318 QStringList reportFiles = files; 322 QStringList reportFiles = files;
319 if (reportFiles.empty()) reportFiles = hgTabs->getAllCommittableFiles(); 323 if (reportFiles.empty()) reportFiles = hgTabs->getAllCommittableFiles();
320 324
321 QString cf(tr("Commit files")); 325 QString cf(tr("Commit files"));
328 tr("<h3>%1</h3><p>%2").arg(cf) 332 tr("<h3>%1</h3><p>%2").arg(cf)
329 .arg(tr("You are about to commit %n file(s):", "", reportFiles.size())), 333 .arg(tr("You are about to commit %n file(s):", "", reportFiles.size())),
330 reportFiles, 334 reportFiles,
331 comment)) { 335 comment)) {
332 336
333 if ((justMerged == false) && //!!! review usage of justMerged, and how it interacts with asynchronous request queue 337 if (!justMerged && !files.empty()) {
334 !files.empty()) { 338 // User wants to commit selected file(s) (and this is not
335 // User wants to commit selected file(s) (and this is not merge commit, which would fail if we selected files) 339 // merge commit, which would fail if we selected files)
336 params << "commit" << "--message" << comment << "--user" << getUserInfo() << "--" << files; 340 params << "commit" << "--message" << comment
341 << "--user" << getUserInfo() << "--" << files;
337 } else { 342 } else {
338 // Commit all changes 343 // Commit all changes
339 params << "commit" << "--message" << comment << "--user" << getUserInfo(); 344 params << "commit" << "--message" << comment
345 << "--user" << getUserInfo();
340 } 346 }
341 347
342 runner->requestAction(HgAction(ACT_COMMIT, workFolderPath, params)); 348 runner->requestAction(HgAction(ACT_COMMIT, workFolderPath, params));
343 } 349 }
350
351 justMerged = false;
344 } 352 }
345 353
346 QString MainWindow::filterTag(QString tag) 354 QString MainWindow::filterTag(QString tag)
347 { 355 {
348 for(int i = 0; i < tag.size(); i++) 356 for(int i = 0; i < tag.size(); i++)
558 QStringList params; 566 QStringList params;
559 567
560 params << "merge"; 568 params << "merge";
561 569
562 runner->requestAction(HgAction(ACT_MERGE, workFolderPath, params)); 570 runner->requestAction(HgAction(ACT_MERGE, workFolderPath, params));
571
572 mergeCommitComment = tr("Merge");
563 } 573 }
564 574
565 575
566 void MainWindow::hgMergeFrom(QString id) 576 void MainWindow::hgMergeFrom(QString id)
567 { 577 {
569 579
570 params << "merge"; 580 params << "merge";
571 params << "--rev" << Changeset::hashOf(id); 581 params << "--rev" << Changeset::hashOf(id);
572 582
573 runner->requestAction(HgAction(ACT_MERGE, workFolderPath, params)); 583 runner->requestAction(HgAction(ACT_MERGE, workFolderPath, params));
584
585 mergeCommitComment = "";
586
587 foreach (Changeset *cs, currentHeads) {
588 if (cs->id() == id && !cs->isOnBranch(currentBranch)) {
589 if (cs->branch() == "" || cs->branch() == "default") {
590 mergeCommitComment = tr("Merge from the default branch");
591 } else {
592 mergeCommitComment = tr("Merge from branch \"%1\"").arg(cs->branch());
593 }
594 }
595 }
596
597 if (mergeCommitComment == "") {
598 mergeCommitComment = tr("Merge from %1").arg(id);
599 }
574 } 600 }
575 601
576 602
577 void MainWindow::hgCloneFromRemote() 603 void MainWindow::hgCloneFromRemote()
578 { 604 {
1642 //!!! Want "merge failed" report 1668 //!!! Want "merge failed" report
1643 1669
1644 if (canMerge) { 1670 if (canMerge) {
1645 hgTabs->setState(tr("<b>Awaiting merge</b> on %1").arg(branchText)); 1671 hgTabs->setState(tr("<b>Awaiting merge</b> on %1").arg(branchText));
1646 } else if (haveMerge) { 1672 } else if (haveMerge) {
1647 hgTabs->setState(tr("Have merged but not committed on %1").arg(branchText)); 1673 hgTabs->setState(tr("Have merged but not yet committed on %1").arg(branchText));
1648 } else if (canUpdate) { 1674 } else if (canUpdate) {
1649 hgTabs->setState(tr("On %1. Not at the head of the branch: consider updating").arg(branchText)); 1675 hgTabs->setState(tr("On %1. Not at the head of the branch: consider updating").arg(branchText));
1650 } else if (currentBranchHeads > 1) { 1676 } else if (currentBranchHeads > 1) {
1651 hgTabs->setState(tr("At one of %n heads of %1", "", currentBranchHeads).arg(branchText)); 1677 hgTabs->setState(tr("At one of %n heads of %1", "", currentBranchHeads).arg(branchText));
1652 } else { 1678 } else {