]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Make 'arc diff X' in mercurial match git by using the GCA of X as the base
authordurham <durham@fb.com>
Fri, 8 Feb 2013 15:09:30 +0000 (07:09 -0800)
committerdurham <durham@fb.com>
Fri, 8 Feb 2013 15:09:30 +0000 (07:09 -0800)
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
src/workflow/ArcanistDiffWorkflow.php

index cf3fbb196edaec9b2541c96604a097d63c69d0d1..79af82f174c7d5b66c8c773e70e1f84f0558097c 100644 (file)
@@ -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;
     }
 
index 619322bba5f9b52a2db50ad29d24e86ffc75e4d8..bd2d84d261a37bfb7db70802eaa294989fbbbf1d 100644 (file)
@@ -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