mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 01: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:
parent
0da3f34728
commit
f5336cd6e7
2 changed files with 25 additions and 0 deletions
|
@ -36,6 +36,7 @@ final class DifferentialParseCommitMessageConduitAPIMethod
|
||||||
$field_map = $parser->parseFields($corpus);
|
$field_map = $parser->parseFields($corpus);
|
||||||
|
|
||||||
$errors = $parser->getErrors();
|
$errors = $parser->getErrors();
|
||||||
|
$xactions = $parser->getTransactions();
|
||||||
|
|
||||||
$revision_id_value = idx(
|
$revision_id_value = idx(
|
||||||
$field_map,
|
$field_map,
|
||||||
|
@ -49,6 +50,7 @@ final class DifferentialParseCommitMessageConduitAPIMethod
|
||||||
'value' => $revision_id_value,
|
'value' => $revision_id_value,
|
||||||
'validDomain' => $revision_id_valid_domain,
|
'validDomain' => $revision_id_valid_domain,
|
||||||
),
|
),
|
||||||
|
'transactions' => $xactions,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ final class DifferentialCommitMessageParser extends Phobject {
|
||||||
private $errors;
|
private $errors;
|
||||||
private $commitMessageFields;
|
private $commitMessageFields;
|
||||||
private $raiseMissingFieldErrors = true;
|
private $raiseMissingFieldErrors = true;
|
||||||
|
private $xactions;
|
||||||
|
|
||||||
public static function newStandardParser(PhabricatorUser $viewer) {
|
public static function newStandardParser(PhabricatorUser $viewer) {
|
||||||
$key_title = DifferentialTitleCommitMessageField::FIELDKEY;
|
$key_title = DifferentialTitleCommitMessageField::FIELDKEY;
|
||||||
|
@ -134,6 +135,7 @@ final class DifferentialCommitMessageParser extends Phobject {
|
||||||
*/
|
*/
|
||||||
public function parseCorpus($corpus) {
|
public function parseCorpus($corpus) {
|
||||||
$this->errors = array();
|
$this->errors = array();
|
||||||
|
$this->xactions = array();
|
||||||
|
|
||||||
$label_map = $this->getLabelMap();
|
$label_map = $this->getLabelMap();
|
||||||
$key_title = $this->titleKey;
|
$key_title = $this->titleKey;
|
||||||
|
@ -284,12 +286,25 @@ final class DifferentialCommitMessageParser extends Phobject {
|
||||||
try {
|
try {
|
||||||
$result = $field->parseFieldValue($text_value);
|
$result = $field->parseFieldValue($text_value);
|
||||||
$result_map[$field_key] = $result;
|
$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) {
|
} catch (DifferentialFieldParseException $ex) {
|
||||||
$this->errors[] = pht(
|
$this->errors[] = pht(
|
||||||
'Error parsing field "%s": %s',
|
'Error parsing field "%s": %s',
|
||||||
$field->getFieldName(),
|
$field->getFieldName(),
|
||||||
$ex->getMessage());
|
$ex->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->getRaiseMissingFieldErrors()) {
|
if ($this->getRaiseMissingFieldErrors()) {
|
||||||
|
@ -317,6 +332,14 @@ final class DifferentialCommitMessageParser extends Phobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @task parse
|
||||||
|
*/
|
||||||
|
public function getTransactions() {
|
||||||
|
return $this->xactions;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -( Support Methods )---------------------------------------------------- */
|
/* -( Support Methods )---------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue