From: durham Date: Wed, 27 Feb 2013 00:15:29 +0000 (-0800) Subject: Fix arc lint on working copy changes in mercurial repos X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=0cb1b7efad98d207f3121cc2928df82ed6ff0d88;p=arcanist.git Fix arc lint on working copy changes in mercurial repos 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 --- diff --git a/src/repository/api/ArcanistMercurialAPI.php b/src/repository/api/ArcanistMercurialAPI.php index bd9adbf2..10de875f 100644 --- a/src/repository/api/ArcanistMercurialAPI.php +++ b/src/repository/api/ArcanistMercurialAPI.php @@ -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)'; diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php index afef0c37..13f54881 100644 --- a/src/workflow/ArcanistDiffWorkflow.php +++ b/src/workflow/ArcanistDiffWorkflow.php @@ -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;