From 94f78cf87c78b2e70651137b59a76294d828a623 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 5 Jun 2020 13:15:43 -0700 Subject: [PATCH] Provide more information about merge progress in "arc land" under Git Summary: Ref T13546. Communicate more progress information and provide additional details when merge conflicts occur. Test Plan: Hit a merge conflict, saw more helpful output. Maniphest Tasks: T13546 Differential Revision: https://secure.phabricator.com/D21318 --- src/land/engine/ArcanistGitLandEngine.php | 52 +++++++++++++++++++---- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/src/land/engine/ArcanistGitLandEngine.php b/src/land/engine/ArcanistGitLandEngine.php index 74a17ad4..76cf4771 100644 --- a/src/land/engine/ArcanistGitLandEngine.php +++ b/src/land/engine/ArcanistGitLandEngine.php @@ -235,11 +235,13 @@ final class ArcanistGitLandEngine protected function executeMerge(ArcanistLandCommitSet $set, $into_commit) { $api = $this->getRepositoryAPI(); + $log = $this->getLogEngine(); $this->updateWorkingCopy($into_commit); $commits = $set->getCommits(); - $source_commit = last($commits)->getHash(); + $max_commit = last($commits); + $source_commit = $max_commit->getHash(); // NOTE: See T11435 for some history. See PHI1727 for a case where a user // modified their working copy while running "arc land". This attempts to @@ -263,10 +265,15 @@ final class ArcanistGitLandEngine $this->getDisplayHash($into_commit))); } - list($original_author, $original_date) = $this->getAuthorAndDate( - $source_commit); + $log->writeStatus( + pht('MERGING'), + pht( + '%s %s', + $this->getDisplayHash($source_commit), + $max_commit->getDisplaySummary())); try { + if ($this->isSquashStrategy()) { // NOTE: We're explicitly specifying "--ff" to override the presence // of "merge.ff" options in user configuration. @@ -280,17 +287,44 @@ final class ArcanistGitLandEngine $source_commit); } } catch (CommandException $ex) { + + // TODO: If we previously succeeded with at least one merge, we could + // provide a hint that "--incremental" can do some of the work. + $api->execManualLocal('merge --abort'); $api->execManualLocal('reset --hard HEAD --'); - throw new PhutilArgumentUsageException( - pht( - 'Local "%s" does not merge cleanly into "%s". Merge or rebase '. - 'local changes so they can merge cleanly.', - $source_commit, - $into_commit)); + $direct_symbols = $max_commit->getDirectSymbols(); + $indirect_symbols = $max_commit->getIndirectSymbols(); + if ($direct_symbols) { + $message = pht( + 'Local commit "%s" (%s) does not merge cleanly into "%s". '. + 'Merge or rebase local changes so they can merge cleanly.', + $this->getDisplayHash($source_commit), + $this->getDisplaySymbols($direct_symbols), + $this->getDisplayHash($into_commit)); + } else if ($indirect_symbols) { + $message = pht( + 'Local commit "%s" (reachable from: %s) does not merge cleanly '. + 'into "%s". Merge or rebase local changes so they can merge '. + 'cleanly.', + $this->getDisplayHash($source_commit), + $this->getDisplaySymbols($indirect_symbols), + $this->getDisplayHash($into_commit)); + } else { + $message = pht( + 'Local commit "%s" does not merge cleanly into "%s". Merge or '. + 'rebase local changes so they can merge cleanly.', + $this->getDisplayHash($source_commit), + $this->getDisplayHash($into_commit)); + } + + throw new PhutilArgumentUsageException($message); } + list($original_author, $original_date) = $this->getAuthorAndDate( + $source_commit); + $revision_ref = $set->getRevisionRef(); $commit_message = $revision_ref->getCommitMessage();