mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-10 08:52:39 +01:00
Merge pull request #7 from mareksapota-fb/master
Pull request for differential revision D1055
This commit is contained in:
commit
3d29a9122c
2 changed files with 71 additions and 29 deletions
|
@ -68,33 +68,63 @@ EOTEXT
|
|||
$repository_api = $this->getRepositoryAPI();
|
||||
$conduit = $this->getConduit();
|
||||
|
||||
$revision_data = $conduit->callMethodSynchronous(
|
||||
'differential.find',
|
||||
array(
|
||||
'query' => 'committable',
|
||||
'guids' => array(
|
||||
$this->getUserPHID(),
|
||||
),
|
||||
));
|
||||
$revision_id = $this->getArgument('revision');
|
||||
|
||||
try {
|
||||
$revision_id = $this->getArgument('revision');
|
||||
$revision = $this->chooseRevision(
|
||||
$revision_data,
|
||||
$revision_id,
|
||||
'Which revision do you want to commit?');
|
||||
} catch (ArcanistChooseInvalidRevisionException $ex) {
|
||||
throw new ArcanistUsageException(
|
||||
"Revision D{$revision_id} is not committable. You can only commit ".
|
||||
"revisions you own which have been 'accepted'.");
|
||||
} catch (ArcanistChooseNoRevisionsException $ex) {
|
||||
throw new ArcanistUsageException(
|
||||
"You have no committable Differential revisions. You can only commit ".
|
||||
"revisions you own which have been 'accepted'.");
|
||||
if (!$revision_id) {
|
||||
$revision_data = $conduit->callMethodSynchronous(
|
||||
'differential.find',
|
||||
array(
|
||||
'query' => 'committable',
|
||||
'guids' => array(
|
||||
$this->getUserPHID(),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
try {
|
||||
$revision = $this->chooseRevision(
|
||||
$revision_data,
|
||||
null,
|
||||
'Which revision do you want to commit?'
|
||||
);
|
||||
$revision_id = $revision->getID();
|
||||
} catch (ArcanistChooseNoRevisionsException $ex) {
|
||||
throw new ArcanistUsageException(
|
||||
"You have no committable Differential revisions. You can only ".
|
||||
"commit revisions which have been 'accepted'.");
|
||||
}
|
||||
}
|
||||
|
||||
$revision_id = $revision->getID();
|
||||
$revision_name = $revision->getName();
|
||||
$revision = null;
|
||||
try {
|
||||
$revision = $conduit->callMethodSynchronous(
|
||||
'differential.getrevision',
|
||||
array(
|
||||
'revision_id' => $revision_id,
|
||||
)
|
||||
);
|
||||
} catch (Exception $ex) {
|
||||
throw new ArcanistUsageException(
|
||||
"Revision D{$revision_id} does not exist."
|
||||
);
|
||||
}
|
||||
|
||||
if ($revision['statusName'] != 'Accepted') {
|
||||
throw new ArcanistUsageException(
|
||||
"Revision D{$revision_id} is not committable. You can only commit ".
|
||||
"revisions which have been 'accepted'."
|
||||
);
|
||||
}
|
||||
|
||||
if ($revision['authorPHID'] != $this->getUserPHID()) {
|
||||
$prompt = "You are not the author of revision D{$revision_id}, ".
|
||||
'are you sure you want to commit it?';
|
||||
if (!phutil_console_confirm($prompt)) {
|
||||
throw new ArcanistUserAbortException();
|
||||
}
|
||||
}
|
||||
|
||||
$revision_name = $revision['title'];
|
||||
|
||||
$message = $conduit->callMethodSynchronous(
|
||||
'differential.getcommitmessage',
|
||||
|
@ -140,8 +170,7 @@ EOTEXT
|
|||
return $err;
|
||||
}
|
||||
|
||||
protected function getCommitFileList(
|
||||
ArcanistDifferentialRevisionRef $revision) {
|
||||
protected function getCommitFileList(array $revision) {
|
||||
$repository_api = $this->getRepositoryAPI();
|
||||
|
||||
if (!($repository_api instanceof ArcanistSubversionAPI)) {
|
||||
|
@ -151,9 +180,22 @@ EOTEXT
|
|||
|
||||
$conduit = $this->getConduit();
|
||||
|
||||
$revision_id = $revision->getID();
|
||||
$revision_id = $revision['id'];
|
||||
|
||||
$revision = reset($conduit->callMethodSynchronous(
|
||||
'differential.find',
|
||||
array(
|
||||
'query' => 'revision-ids',
|
||||
'guids' => array($revision_id,)
|
||||
)
|
||||
));
|
||||
if (!$revision) {
|
||||
throw new ArcanistUsageException(
|
||||
"Revision D{$revision_id} does not exist."
|
||||
);
|
||||
}
|
||||
$revision_source = $revision['sourcePath'];
|
||||
|
||||
$revision_source = $revision->getSourcePath();
|
||||
$working_copy = $repository_api->getPath();
|
||||
if ($revision_source != $working_copy) {
|
||||
$prompt =
|
||||
|
|
|
@ -106,7 +106,7 @@ EOTEXT
|
|||
}
|
||||
|
||||
if ($revision) {
|
||||
if ($revision['authorPHID'] != $this->getUserPHID()) {
|
||||
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)) {
|
||||
|
|
Loading…
Reference in a new issue