]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Fix arc lint on working copy changes in mercurial repos
authordurham <durham@fb.com>
Wed, 27 Feb 2013 00:15:29 +0000 (16:15 -0800)
committerdurham <durham@fb.com>
Wed, 27 Feb 2013 00:15:29 +0000 (16:15 -0800)
Summary:
Previously, running arc lint on a set of changes that only
existed in your working copy threw an exception in mercurial repos.
It was trying to use the revset "...." (i.e. the range from . to .),
which didn't parse. Even if I fix that it still doesn't work because
getRawDiffText did not include the working copy changes (which it does
in git).  I removed the check so the function now acts the same as in
git and arc lint works on working copy changes. I've seen this error before
in other places so hopefully this change will also fix any other areas,
that depended on getRawDiffText working the same as git.

The logic I removed was added in D1954 to support diffing against
uncommited changes.  That workflow should be unchanged.  arc diff will
still prompt the user if there are uncommited changes, and the user can
still choose to abort or continue.

Let me know if I missed something important which makes this a bad idea.

Test Plan:
Edited a file in the working directory of a hg repo.
arc lint
Verified lint ran successfully.

Also ran arc diff and land with and without working copy changes to make sure
they still work.  I'd kill for some tests in this area...

Reviewers: epriestley, vrana

Reviewed By: epriestley

CC: dschleimer, bos, sid0, aran, Korvin
Maniphest Tasks: T1631

Differential Revision: https://secure.phabricator.com/D5130

src/repository/api/ArcanistMercurialAPI.php
src/workflow/ArcanistDiffWorkflow.php

index bd9adbf2bfd13623687772635636d52fd3c68061..10de875f879ca2715044cb3876ddd9b8d676ff13 100644 (file)
@@ -9,7 +9,6 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
 
   private $branch;
   private $localCommitInfo;
-  private $includeDirectoryStateInDiffs;
   private $rawDiffCache = array();
 
   private $supportsRebase;
@@ -377,15 +376,7 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
   public function getRawDiffText($path) {
     $options = $this->getDiffOptions();
 
-    // NOTE: In Mercurial, "--rev x" means "diff between x and the working
-    // copy state", while "--rev x..." means "diff between x and the working
-    // copy commit" (i.e., from 'x' to '.'). The latter excludes any dirty
-    // changes in the working copy.
-
     $range = $this->getBaseCommit();
-    if (!$this->includeDirectoryStateInDiffs) {
-      $range .= '...';
-    }
 
     $raw_diff_cache_key = $options.' '.$range.' '.$path;
     if (idx($this->rawDiffCache, $raw_diff_cache_key)) {
@@ -670,11 +661,6 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
     $this->reloadWorkingCopy();
   }
 
-  public function setIncludeDirectoryStateInDiffs($include) {
-    $this->includeDirectoryStateInDiffs = $include;
-    return $this;
-  }
-
   public function getCommitSummary($commit) {
     if ($commit == 'null') {
       return '(The Empty Void)';
index afef0c37e74c434d0c6177f8f1c092862628b16a..13f5488195193d2eea37d50465564d8bf0371fca 100644 (file)
@@ -660,12 +660,6 @@ EOTEXT
         $this->requireCleanWorkingCopy();
       } catch (ArcanistUncommittedChangesException $ex) {
         if ($repository_api instanceof ArcanistMercurialAPI) {
-
-          // Some Mercurial users prefer to use it like SVN, where they don't
-          // commit changes before sending them for review. This would be a
-          // pretty bad workflow in Git, but Mercurial users are significantly
-          // more expert at change management.
-
           $use_dirty_changes = false;
           if ($this->getArgument('uncommitted')) {
             // OK.
@@ -680,7 +674,6 @@ EOTEXT
             }
           }
 
-          $repository_api->setIncludeDirectoryStateInDiffs(true);
           $this->haveUncommittedChanges = true;
         } else {
           throw $ex;