1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-12-24 06:20:55 +01:00

Allow anyone to mark Differential revisions as commited.

Test Plan:
Run `arc mark-committed` on a revision that you don't own, you should see a
prompt asking you if you really want to do that and if you answer `Y` it should
mark the revision as committed.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley, mareksapota

Differential Revision: 1052
This commit is contained in:
Marek Sapota 2011-10-25 16:34:15 -07:00
parent 0b79132827
commit 6db055222a
2 changed files with 30 additions and 26 deletions

View file

@ -79,32 +79,41 @@ EOTEXT
throw new ArcanistUsageException( throw new ArcanistUsageException(
"mark-committed requires exactly one revision."); "mark-committed requires exactly one revision.");
} }
$revision_id = reset($revision_list);
$revision_data = $conduit->callMethodSynchronous( $revision_id = $this->normalizeRevisionID($revision_id);
'differential.find',
array(
'query' => 'committable',
'guids' => array(
$this->getUserPHID(),
),
));
$revision = null; $revision = null;
try { try {
$revision_id = reset($revision_list); $revision = $conduit->callMethodSynchronous(
$revision_id = $this->normalizeRevisionID($revision_id); 'differential.getrevision',
$revision = $this->chooseRevision( array(
$revision_data, 'revision_id' => $revision_id,
$revision_id); )
} catch (ArcanistChooseInvalidRevisionException $ex) { );
} catch (Exception $ex) {
if (!$is_finalize) { if (!$is_finalize) {
throw new ArcanistUsageException( throw new ArcanistUsageException(
"Revision D{$revision_id} is not committable. You can only mark ". "Revision D{$revision_id} does not exist."
"revisions which have been 'accepted' as committed."); );
} }
} }
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 ($revision) {
if ($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; $actually_mark = true;
if ($is_finalize) { if ($is_finalize) {
$project_info = $conduit->callMethodSynchronous( $project_info = $conduit->callMethodSynchronous(
@ -117,8 +126,7 @@ EOTEXT
} }
} }
if ($actually_mark) { if ($actually_mark) {
$revision_id = $revision->getID(); $revision_name = $revision['title'];
$revision_name = $revision->getName();
echo "Marking revision D{$revision_id} '{$revision_name}' ". echo "Marking revision D{$revision_id} '{$revision_name}' ".
"committed...\n"; "committed...\n";
@ -131,17 +139,12 @@ EOTEXT
} }
} }
$revision_info = $conduit->callMethodSynchronous( $status = $revision['statusName'];
'differential.getrevision',
array(
'revision_id' => $revision_id,
));
$status = $revision_info['statusName'];
if ($status == 'Accepted' || $status == 'Committed') { if ($status == 'Accepted' || $status == 'Committed') {
// If this has already been attached to commits, don't show the // 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 // "you can push this commit" message since we know it's been committed
// already. // already.
$is_finalized = empty($revision_info['commits']); $is_finalized = empty($revision['commits']);
} else { } else {
$is_finalized = false; $is_finalized = false;
} }

View file

@ -7,6 +7,7 @@
phutil_require_module('arcanist', 'exception/usage'); phutil_require_module('arcanist', 'exception/usage');
phutil_require_module('arcanist', 'exception/usage/userabort');
phutil_require_module('arcanist', 'workflow/base'); phutil_require_module('arcanist', 'workflow/base');
phutil_require_module('phutil', 'console'); phutil_require_module('phutil', 'console');