mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-10 08:52:39 +01:00
Fix some arc/mercurial issues
Summary: - In "arc which", we recommend "--rev x --rev ." to show changes. This is not accurate if there are uncommitted changes in the working copy. Just "--rev x" shows the correct changes (implicitly, the other end of the range is the working copy state). - When you diff only working copy changes, we currently incorrectly identify all your open revisions as belonging to the working copy. Instead, correctly identify none of them as belonging to the working copy (in theory, we could go farther than this and do path-based identification like SVN, but with --amend in hg 2.2+ this workflow should be going away in the long run). - If you have uncommitted working copy changes, never try to amend. Test Plan: Ran "arc which .", "arc diff ." in a working copy with dirty changes, got better results than before. Reviewers: dschleimer, btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1507 Differential Revision: https://secure.phabricator.com/D2980
This commit is contained in:
parent
cb56743521
commit
802c0ed89f
3 changed files with 42 additions and 17 deletions
|
@ -553,6 +553,11 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
||||||
$hashes[] = array('hgcm', $commit['commit']);
|
$hashes[] = array('hgcm', $commit['commit']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($hashes) {
|
||||||
|
|
||||||
|
// NOTE: In the case of "arc diff . --uncommitted" in a Mercurial working
|
||||||
|
// copy with dirty changes, there may be no local commits.
|
||||||
|
|
||||||
$results = $conduit->callMethodSynchronous(
|
$results = $conduit->callMethodSynchronous(
|
||||||
'differential.query',
|
'differential.query',
|
||||||
$query + array(
|
$query + array(
|
||||||
|
@ -568,6 +573,9 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
public function updateWorkingCopy() {
|
public function updateWorkingCopy() {
|
||||||
$this->execxLocal('up');
|
$this->execxLocal('up');
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ final class ArcanistDiffWorkflow extends ArcanistBaseWorkflow {
|
||||||
private $unitWorkflow;
|
private $unitWorkflow;
|
||||||
private $lintWorkflow;
|
private $lintWorkflow;
|
||||||
private $postponedLinters;
|
private $postponedLinters;
|
||||||
|
private $haveUncommittedChanges = false;
|
||||||
|
|
||||||
public function getCommandSynopses() {
|
public function getCommandSynopses() {
|
||||||
return phutil_console_format(<<<EOTEXT
|
return phutil_console_format(<<<EOTEXT
|
||||||
|
@ -297,7 +298,7 @@ EOTEXT
|
||||||
'help' => 'Never amend commits in the working copy.',
|
'help' => 'Never amend commits in the working copy.',
|
||||||
),
|
),
|
||||||
'uncommitted' => array(
|
'uncommitted' => array(
|
||||||
'help' => 'Include uncommitted changes without prompting.',
|
'help' => 'Suppress warning about uncommitted changes.',
|
||||||
'supports' => array(
|
'supports' => array(
|
||||||
'hg',
|
'hg',
|
||||||
),
|
),
|
||||||
|
@ -486,9 +487,8 @@ EOTEXT
|
||||||
'revision_id' => $result['revisionid'],
|
'revision_id' => $result['revisionid'],
|
||||||
));
|
));
|
||||||
|
|
||||||
if (!$this->isRawDiffSource() && $this->shouldAmend()) {
|
if ($this->shouldAmend()) {
|
||||||
$repository_api = $this->getRepositoryAPI();
|
$repository_api = $this->getRepositoryAPI();
|
||||||
|
|
||||||
if ($repository_api->supportsAmend()) {
|
if ($repository_api->supportsAmend()) {
|
||||||
echo "Updating commit message...\n";
|
echo "Updating commit message...\n";
|
||||||
$repository_api->amendCommit($revised_message);
|
$repository_api->amendCommit($revised_message);
|
||||||
|
@ -577,6 +577,7 @@ EOTEXT
|
||||||
}
|
}
|
||||||
|
|
||||||
$repository_api->setIncludeDirectoryStateInDiffs(true);
|
$repository_api->setIncludeDirectoryStateInDiffs(true);
|
||||||
|
$this->haveUncommittedChanges = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1070,7 +1071,23 @@ EOTEXT
|
||||||
}
|
}
|
||||||
|
|
||||||
private function shouldAmend() {
|
private function shouldAmend() {
|
||||||
return !$this->isHistoryImmutable() && !$this->getArgument('no-amend');
|
if ($this->haveUncommittedChanges) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->isHistoryImmutable()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->getArgument('no-amend')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->isRawDiffSource()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ EOTEXT
|
||||||
if ($repository_api instanceof ArcanistGitAPI) {
|
if ($repository_api instanceof ArcanistGitAPI) {
|
||||||
$command = "git diff {$relative}..HEAD";
|
$command = "git diff {$relative}..HEAD";
|
||||||
} else if ($repository_api instanceof ArcanistMercurialAPI) {
|
} else if ($repository_api instanceof ArcanistMercurialAPI) {
|
||||||
$command = "hg diff --rev {$relative} --rev .";
|
$command = "hg diff --rev {$relative}";
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Unknown VCS!");
|
throw new Exception("Unknown VCS!");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue