changeset 157:e411bb42d934

* Default merge comments
author Chris Cannam
date Thu, 02 Dec 2010 21:52:24 +0000
parents 4999dbf3a266
children 006630304b69
files mainwindow.cpp mainwindow.h
diffstat 2 files changed, 33 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mainwindow.cpp	Thu Dec 02 21:32:04 2010 +0000
+++ b/mainwindow.cpp	Thu Dec 02 21:52:24 2010 +0000
@@ -314,6 +314,10 @@
     QStringList params;
     QString comment;
 
+    if (justMerged) {
+        comment = mergeCommitComment;
+    }
+
     QStringList files = hgTabs->getSelectedCommittableFiles();
     QStringList reportFiles = files;
     if (reportFiles.empty()) reportFiles = hgTabs->getAllCommittableFiles();
@@ -330,17 +334,21 @@
          reportFiles,
          comment)) {
 
-        if ((justMerged == false) && //!!! review usage of justMerged, and how it interacts with asynchronous request queue
-            !files.empty()) {
-            // User wants to commit selected file(s) (and this is not merge commit, which would fail if we selected files)
-            params << "commit" << "--message" << comment << "--user" << getUserInfo() << "--" << files;
+        if (!justMerged && !files.empty()) {
+            // User wants to commit selected file(s) (and this is not
+            // merge commit, which would fail if we selected files)
+            params << "commit" << "--message" << comment
+                   << "--user" << getUserInfo() << "--" << files;
         } else {
             // Commit all changes
-            params << "commit" << "--message" << comment << "--user" << getUserInfo();
+            params << "commit" << "--message" << comment
+                   << "--user" << getUserInfo();
         }
         
         runner->requestAction(HgAction(ACT_COMMIT, workFolderPath, params));
     }
+    
+    justMerged = false;
 }
 
 QString MainWindow::filterTag(QString tag)
@@ -560,6 +568,8 @@
     params << "merge";
     
     runner->requestAction(HgAction(ACT_MERGE, workFolderPath, params));
+
+    mergeCommitComment = tr("Merge");
 }
 
 
@@ -571,6 +581,22 @@
     params << "--rev" << Changeset::hashOf(id);
     
     runner->requestAction(HgAction(ACT_MERGE, workFolderPath, params));
+
+    mergeCommitComment = "";
+
+    foreach (Changeset *cs, currentHeads) {
+        if (cs->id() == id && !cs->isOnBranch(currentBranch)) {
+            if (cs->branch() == "" || cs->branch() == "default") {
+                mergeCommitComment = tr("Merge from the default branch");
+            } else {
+                mergeCommitComment = tr("Merge from branch \"%1\"").arg(cs->branch());
+            }
+        }
+    }
+
+    if (mergeCommitComment == "") {
+        mergeCommitComment = tr("Merge from %1").arg(id);
+    }
 }
 
 
@@ -1644,7 +1670,7 @@
     if (canMerge) {
         hgTabs->setState(tr("<b>Awaiting merge</b> on %1").arg(branchText));
     } else if (haveMerge) {
-        hgTabs->setState(tr("Have merged but not committed on %1").arg(branchText));
+        hgTabs->setState(tr("Have merged but not yet committed on %1").arg(branchText));
     } else if (canUpdate) {
         hgTabs->setState(tr("On %1. Not at the head of the branch: consider updating").arg(branchText));
     } else if (currentBranchHeads > 1) {
--- a/mainwindow.h	Thu Dec 02 21:32:04 2010 +0000
+++ b/mainwindow.h	Thu Dec 02 21:52:24 2010 +0000
@@ -207,6 +207,7 @@
     QFileSystemWatcher *fsWatcher;
 
     bool justMerged;
+    QString mergeCommitComment;
 };
 
 #endif