From 4c35af92830b3962631c41cedaeea8bbe7278d42 Mon Sep 17 00:00:00 2001 From: durham Date: Fri, 8 Feb 2013 07:09:30 -0800 Subject: [PATCH] Make 'arc diff X' in mercurial match git by using the GCA of X as the base Summary: Previously 'arc diff X' with mercurial meant to use X as the base to diff against. Now it means use gca(X,working directory) as the base to diff against. This matches the git behavior. Test Plan: Ran 'arc diff master' on a repo where master was ahead of the feature branch. Verified that the diff result included only the diffs in the feature branch. Reviewers: epriestley, sid0, bos, dschleimer Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4865 --- src/repository/api/ArcanistMercurialAPI.php | 7 +++++-- src/workflow/ArcanistDiffWorkflow.php | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/repository/api/ArcanistMercurialAPI.php b/src/repository/api/ArcanistMercurialAPI.php index cf3fbb19..79af82f1 100644 --- a/src/repository/api/ArcanistMercurialAPI.php +++ b/src/repository/api/ArcanistMercurialAPI.php @@ -85,12 +85,15 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI { protected function buildBaseCommit($symbolic_commit) { if ($symbolic_commit !== null) { try { - $commit = $this->getCanonicalRevisionName($symbolic_commit); + $commit = $this->getCanonicalRevisionName( + hgsprintf('ancestor(%s,.)', $symbolic_commit)); } catch (Exception $ex) { throw new ArcanistUsageException( "Commit '{$commit}' is not a valid Mercurial commit identifier."); } - $this->setBaseCommitExplanation("you specified it explicitly."); + + $this->setBaseCommitExplanation("it is the greatest common ancestor of ". + "the working directory and the commit you specified explicitly."); return $commit; } diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php index 619322bb..bd2d84d2 100644 --- a/src/workflow/ArcanistDiffWorkflow.php +++ b/src/workflow/ArcanistDiffWorkflow.php @@ -41,9 +41,9 @@ EOTEXT Supports: git, svn, hg Generate a Differential diff or revision from local changes. - Under git, you can specify a commit (like __HEAD^^^__ or __master__) - and Differential will generate a diff against the merge base of that - commit and HEAD. + Under git and mercurial, you can specify a commit (like __HEAD^^^__ + or __master__) and Differential will generate a diff against the + merge base of that commit and your current working directory parent. Under svn, you can choose to include only some of the modified files in the working copy in the diff by specifying their paths. If you