array( 'help' => "Mark committed only if the repository is untracked and the ". "revision is accepted. Continue even if the mark can't happen. This ". "is a soft version of 'mark-committed' used by other workflows.", ), '*' => 'revision', ); } public function requiresConduit() { return true; } public function requiresAuthentication() { return true; } public function requiresRepositoryAPI() { // NOTE: Technically we only use this to generate the right message at // the end, and you can even get the wrong message (e.g., if you run // "arc mark-committed D123" from a git repository, but D123 is an SVN // revision). We could be smarter about this, but it's just display fluff. return true; } public function run() { $is_finalize = $this->getArgument('finalize'); $conduit = $this->getConduit(); $revision_list = $this->getArgument('revision', array()); if (!$revision_list) { throw new ArcanistUsageException( "mark-committed requires a revision number."); } if (count($revision_list) != 1) { throw new ArcanistUsageException( "mark-committed requires exactly one revision."); } $revision_id = reset($revision_list); $revision_id = $this->normalizeRevisionID($revision_id); $revision = null; try { $revision = $conduit->callMethodSynchronous( 'differential.getrevision', array( 'revision_id' => $revision_id, ) ); } catch (Exception $ex) { if (!$is_finalize) { throw new ArcanistUsageException( "Revision D{$revision_id} does not exist." ); } } if (!$is_finalize && $revision['statusName'] != 'Accepted') { throw new ArcanistUsageException( "Revision D{$revision_id} is not committable. You can only mark ". "revisions which have been 'accepted' as committed." ); } if ($revision) { if (!$is_finalize && $revision['authorPHID'] != $this->getUserPHID()) { $prompt = "You are not the author of revision D{$revision_id}, ". 'are you sure you want to mark it committed?'; if (!phutil_console_confirm($prompt)) { throw new ArcanistUserAbortException(); } } $actually_mark = true; if ($is_finalize) { $project_info = $conduit->callMethodSynchronous( 'arcanist.projectinfo', array( 'name' => $this->getWorkingCopy()->getProjectID(), )); if ($project_info['tracked'] || $revision['statusName'] != 'Accepted') { $actually_mark = false; } } if ($actually_mark) { $revision_name = $revision['title']; echo "Marking revision D{$revision_id} '{$revision_name}' ". "committed...\n"; $conduit->callMethodSynchronous( 'differential.markcommitted', array( 'revision_id' => $revision_id, )); } } $status = $revision['statusName']; if ($status == 'Accepted' || $status == 'Committed') { // If this has already been attached to commits, don't show the // "you can push this commit" message since we know it's been committed // already. $is_finalized = empty($revision['commits']); } else { $is_finalized = false; } if ($is_finalized) { $message = $this->getRepositoryAPI()->getFinalizedRevisionMessage(); echo phutil_console_wrap($message)."\n"; } else { echo "Done.\n"; } return 0; } }