Include conflicting files into message when rebasing change edit fails

Release-Notes: skip
Bug: Google b/364179875
Change-Id: I96d65cbb5e0e962ab1d35e52d07a50e2302ec642
Signed-off-by: Edwin Kempin <ekempin@google.com>
(cherry picked from commit a1af20fa11de3ff00a1a4867487d574fa54178d7)
diff --git a/java/com/google/gerrit/server/edit/ChangeEditModifier.java b/java/com/google/gerrit/server/edit/ChangeEditModifier.java
index 36b8629..4c856e9 100644
--- a/java/com/google/gerrit/server/edit/ChangeEditModifier.java
+++ b/java/com/google/gerrit/server/edit/ChangeEditModifier.java
@@ -17,6 +17,7 @@
 import static com.google.gerrit.server.project.ProjectCache.illegalState;
 import static com.google.gerrit.server.update.context.RefUpdateContext.RefUpdateType.CHANGE_MODIFICATION;
 
+import com.google.common.collect.ImmutableList;
 import com.google.errorprone.annotations.CanIgnoreReturnValue;
 import com.google.gerrit.common.Nullable;
 import com.google.gerrit.entities.BooleanProjectConfig;
@@ -44,6 +45,7 @@
 import com.google.gerrit.server.edit.tree.TreeCreator;
 import com.google.gerrit.server.edit.tree.TreeModification;
 import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
+import com.google.gerrit.server.git.MergeUtil;
 import com.google.gerrit.server.index.change.ChangeIndexer;
 import com.google.gerrit.server.notedb.ChangeNotes;
 import com.google.gerrit.server.permissions.ChangePermission;
@@ -81,6 +83,7 @@
 import org.eclipse.jgit.merge.MergeChunk;
 import org.eclipse.jgit.merge.MergeResult;
 import org.eclipse.jgit.merge.MergeStrategy;
+import org.eclipse.jgit.merge.ResolveMerger;
 import org.eclipse.jgit.merge.ThreeWayMerger;
 import org.eclipse.jgit.revwalk.RevCommit;
 import org.eclipse.jgit.revwalk.RevWalk;
@@ -563,9 +566,17 @@
     boolean successful = merger.merge(basePatchSetCommit, editCommitId);
 
     if (!successful) {
+      List<String> conflicts = ImmutableList.of();
+      if (merger instanceof ResolveMerger) {
+        conflicts = ((ResolveMerger) merger).getUnmergedPaths();
+      }
+
       throw new MergeConflictException(
-          "Rebasing change edit onto another patchset results in merge conflicts. Download the edit"
-              + " patchset and rebase manually to preserve changes.");
+          String.format(
+              "Rebasing change edit onto another patchset results in merge conflicts.\n\n"
+                  + "%s\n\n"
+                  + "Download the edit patchset and rebase manually to preserve changes.",
+              MergeUtil.createConflictMessage(conflicts)));
     }
     return merger.getResultTreeId();
   }
diff --git a/javatests/com/google/gerrit/acceptance/edit/ChangeEditIT.java b/javatests/com/google/gerrit/acceptance/edit/ChangeEditIT.java
index e1bc7e6..b55cfee 100644
--- a/javatests/com/google/gerrit/acceptance/edit/ChangeEditIT.java
+++ b/javatests/com/google/gerrit/acceptance/edit/ChangeEditIT.java
@@ -296,8 +296,11 @@
     assertThat(exception)
         .hasMessageThat()
         .isEqualTo(
-            "Rebasing change edit onto another patchset results in merge conflicts."
-                + " Download the edit patchset and rebase manually to preserve changes.");
+            String.format(
+                "Rebasing change edit onto another patchset results in merge conflicts.\n\n"
+                    + "merge conflict(s):\n%s\n\n"
+                    + "Download the edit patchset and rebase manually to preserve changes.",
+                FILE_NAME));
   }
 
   @Test