1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00

Return transactions from "differential.parsecommitmessage"

Summary:
Depends on D18740. Prepares `arc` to receive a `--draft` flag by letting us switch to "differential.revision.edit" instead of "differential.createrevision".

To "differential.revision.edit", we need a transaction list, but we can't automatically construct this list from a field map. Return the transaction list alongside the field map.

The next change uses this list (if available) to switch us to the modern API method.

Test Plan: Ran `arc diff` on the experiemntal branch with followup changes, got a new revision.

Reviewers: amckinley

Reviewed By: amckinley

Differential Revision: https://secure.phabricator.com/D18741
This commit is contained in:
epriestley 2017-10-27 10:00:34 -07:00
parent 0da3f34728
commit f5336cd6e7
2 changed files with 25 additions and 0 deletions

View file

@ -36,6 +36,7 @@ final class DifferentialParseCommitMessageConduitAPIMethod
$field_map = $parser->parseFields($corpus);
$errors = $parser->getErrors();
$xactions = $parser->getTransactions();
$revision_id_value = idx(
$field_map,
@ -49,6 +50,7 @@ final class DifferentialParseCommitMessageConduitAPIMethod
'value' => $revision_id_value,
'validDomain' => $revision_id_valid_domain,
),
'transactions' => $xactions,
);
}

View file

@ -28,6 +28,7 @@ final class DifferentialCommitMessageParser extends Phobject {
private $errors;
private $commitMessageFields;
private $raiseMissingFieldErrors = true;
private $xactions;
public static function newStandardParser(PhabricatorUser $viewer) {
$key_title = DifferentialTitleCommitMessageField::FIELDKEY;
@ -134,6 +135,7 @@ final class DifferentialCommitMessageParser extends Phobject {
*/
public function parseCorpus($corpus) {
$this->errors = array();
$this->xactions = array();
$label_map = $this->getLabelMap();
$key_title = $this->titleKey;
@ -284,12 +286,25 @@ final class DifferentialCommitMessageParser extends Phobject {
try {
$result = $field->parseFieldValue($text_value);
$result_map[$field_key] = $result;
try {
$xactions = $field->getFieldTransactions($result);
foreach ($xactions as $xaction) {
$this->xactions[] = $xaction;
}
} catch (Exception $ex) {
$this->errors[] = pht(
'Error extracting field transactions from "%s": %s',
$field->getFieldName(),
$ex->getMessage());
}
} catch (DifferentialFieldParseException $ex) {
$this->errors[] = pht(
'Error parsing field "%s": %s',
$field->getFieldName(),
$ex->getMessage());
}
}
if ($this->getRaiseMissingFieldErrors()) {
@ -317,6 +332,14 @@ final class DifferentialCommitMessageParser extends Phobject {
}
/**
* @task parse
*/
public function getTransactions() {
return $this->xactions;
}
/* -( Support Methods )---------------------------------------------------- */