public function supportsAmend() {
list ($err, $stdout) = $this->execManualLocal('help commit');
if ($err) {
- return false;
+ return false;
} else {
- return (strstr($stdout, "amend") !== false);
+ return (strstr($stdout, "amend") !== false);
}
}
$hashes[] = array('hgcm', $commit['commit']);
}
- $results = $conduit->callMethodSynchronous(
- 'differential.query',
- $query + array(
- 'commitHashes' => $hashes,
- ));
+ if ($hashes) {
+
+ // NOTE: In the case of "arc diff . --uncommitted" in a Mercurial working
+ // copy with dirty changes, there may be no local commits.
- foreach ($results as $key => $hash) {
- $results[$key]['why'] =
- "A mercurial commit hash in the commit range is already attached ".
- "to the Differential revision.";
+ $results = $conduit->callMethodSynchronous(
+ 'differential.query',
+ $query + array(
+ 'commitHashes' => $hashes,
+ ));
+
+ foreach ($results as $key => $hash) {
+ $results[$key]['why'] =
+ "A mercurial commit hash in the commit range is already attached ".
+ "to the Differential revision.";
+ }
+
+ return $results;
}
- return $results;
+ return array();
}
public function updateWorkingCopy() {
private $unitWorkflow;
private $lintWorkflow;
private $postponedLinters;
+ private $haveUncommittedChanges = false;
public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
'help' => 'Never amend commits in the working copy.',
),
'uncommitted' => array(
- 'help' => 'Include uncommitted changes without prompting.',
+ 'help' => 'Suppress warning about uncommitted changes.',
'supports' => array(
'hg',
),
'revision_id' => $result['revisionid'],
));
- if (!$this->isRawDiffSource() && $this->shouldAmend()) {
+ if ($this->shouldAmend()) {
$repository_api = $this->getRepositoryAPI();
-
if ($repository_api->supportsAmend()) {
echo "Updating commit message...\n";
$repository_api->amendCommit($revised_message);
}
$repository_api->setIncludeDirectoryStateInDiffs(true);
+ $this->haveUncommittedChanges = true;
}
}
}
}
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;
}
if ($repository_api instanceof ArcanistGitAPI) {
$command = "git diff {$relative}..HEAD";
} else if ($repository_api instanceof ArcanistMercurialAPI) {
- $command = "hg diff --rev {$relative} --rev .";
+ $command = "hg diff --rev {$relative}";
} else {
throw new Exception("Unknown VCS!");
}