'param' => 'revision_id',
'help' => "Always update a specific revision.",
),
+ 'auto' => array(
+ 'help' => "(Unstable!) Heuristically select --create or --update. ".
+ "This may become the default behvaior of arc.",
+ 'conflicts' => array(
+ 'raw',
+ ),
+ ),
'nounit' => array(
'help' =>
"Do not run unit tests.",
}
public function run() {
-
- if ($this->requiresRepositoryAPI()) {
- $repository_api = $this->getRepositoryAPI();
- if ($this->getArgument('less-context')) {
- $repository_api->setDiffLinesOfContext(3);
- }
- }
-
- $output_json = $this->getArgument('json');
- if ($output_json) {
- // TODO: We should move this to a higher-level and put an indirection
- // layer between echoing stuff and stdout.
- ob_start();
- }
-
- $conduit = $this->getConduit();
-
- if ($this->requiresWorkingCopy()) {
- $this->requireCleanWorkingCopy();
- }
+ $this->runDiffSetupBasics();
$paths = $this->generateAffectedPaths();
'unitStatus' => $this->getUnitStatus($unit_result),
) + $this->buildDiffSpecification();
+ $conduit = $this->getConduit();
$diff_info = $conduit->callMethodSynchronous(
'differential.creatediff',
$diff_spec);
$this->updateUnitDiffProperty();
$this->updateLocalDiffProperty();
+ $output_json = $this->getArgument('json');
+
if ($this->shouldOnlyCreateDiff()) {
if (!$output_json) {
echo phutil_console_format(
return 0;
}
+ private function runDiffSetupBasics() {
+ if ($this->requiresRepositoryAPI()) {
+ $repository_api = $this->getRepositoryAPI();
+ if ($this->getArgument('less-context')) {
+ $repository_api->setDiffLinesOfContext(3);
+ }
+ }
+
+ $output_json = $this->getArgument('json');
+ if ($output_json) {
+ // TODO: We should move this to a higher-level and put an indirection
+ // layer between echoing stuff and stdout.
+ ob_start();
+ }
+
+ if ($this->requiresWorkingCopy()) {
+ $this->requireCleanWorkingCopy();
+ }
+ }
+
protected function shouldOnlyCreateDiff() {
if ($this->getArgument('create')) {
return false;
}
+ if ($this->getArgument('auto')) {
+ return false;
+ }
+
if ($this->getArgument('use-commit-message')) {
return false;
}
private function buildCommitMessage() {
$is_create = $this->getArgument('create');
$is_update = $this->getArgument('update');
+ $is_auto = $this->getArgument('auto');
$is_raw = $this->isRawDiffSource();
$is_message = $this->getArgument('use-commit-message');
return $this->getCommitMessageFromCommit($is_message);
}
+ if ($is_auto) {
+ $repository_api = $this->getRepositoryAPI();
+ $revisions = $repository_api->loadWorkingCopyDifferentialRevisions(
+ $this->getConduit(),
+ array(
+ 'authors' => array($this->getUserPHID()),
+ ));
+ if (!$revisions) {
+ $is_create = true;
+ } else if (count($revisions) == 1) {
+ $revision = head($revisions);
+ $is_update = $revision['id'];
+ } else {
+ throw new ArcanistUsageException(
+ "There are several revisions in the specified commit range:\n\n".
+ $this->renderRevisionList($revisions)."\n".
+ "Use '--update' to choose one, or '--create' to create a new ".
+ "revision.");
+ }
+ }
+
$message = null;
if ($is_create) {
$message_file = $this->getArgument('message-file');