mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-12-23 14:00:55 +01:00
In arc diff
, try to guess where a change should land
Summary: Ref T9952. Ref T3462. My primary goal is to improve prefilling of the "Onto Branch:" field in the "Land Revision" dialog. When uploading a diff with `arc diff`, add a property with some information about which branch to target. In particular: - If the local branch tracks an upstream branch (or tracks something which tracks something which tracks the upstream), target that. - If not, but "arc.land.onto.default" is set, target that. This doesn't try to guess in other cases, since they're more involved. I'll add some context about this in T3462. I don't //love// using "diff properties" for this, but it doesn't make cleaning them up any harder since we already use it for other stuff which isn't going away (lint/unit excuses). Test Plan: - Added some `var_dump()` and used `arc diff --only` to generate diffs. - Saw upstream tracking and config-based rules generate reasonable values and submit them. Reviewers: chad Reviewed By: chad Maniphest Tasks: T3462, T9952 Differential Revision: https://secure.phabricator.com/D14736
This commit is contained in:
parent
d0e73bb656
commit
dae2f0073f
1 changed files with 49 additions and 0 deletions
|
@ -531,6 +531,7 @@ EOTEXT
|
|||
$this->updateLintDiffProperty();
|
||||
$this->updateUnitDiffProperty();
|
||||
$this->updateLocalDiffProperty();
|
||||
$this->updateOntoDiffProperty();
|
||||
$this->resolveDiffPropertyUpdates();
|
||||
|
||||
$output_json = $this->getArgument('json');
|
||||
|
@ -2406,6 +2407,54 @@ EOTEXT
|
|||
$this->updateDiffProperty('local:commits', json_encode($local_info));
|
||||
}
|
||||
|
||||
private function updateOntoDiffProperty() {
|
||||
$onto = $this->getDiffOntoTargets();
|
||||
|
||||
if (!$onto) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->updateDiffProperty('arc:onto', json_encode($onto));
|
||||
}
|
||||
|
||||
private function getDiffOntoTargets() {
|
||||
$api = $this->getRepositoryAPI();
|
||||
|
||||
if (!($api instanceof ArcanistGitAPI)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// If we track an upstream branch either directly or indirectly, use that.
|
||||
$branch = $api->getBranchName();
|
||||
if (strlen($branch)) {
|
||||
$upstream_path = $api->getPathToUpstream($branch);
|
||||
$remote_branch = $upstream_path->getRemoteBranchName();
|
||||
if (strlen($remote_branch)) {
|
||||
return array(
|
||||
array(
|
||||
'type' => 'branch',
|
||||
'name' => $remote_branch,
|
||||
'kind' => 'upstream',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// If "arc.land.onto.default" is configured, use that.
|
||||
$config_key = 'arc.land.onto.default';
|
||||
$onto = $this->getConfigFromAnySource($config_key);
|
||||
if (strlen($onto)) {
|
||||
return array(
|
||||
array(
|
||||
'type' => 'branch',
|
||||
'name' => $onto,
|
||||
'kind' => 'arc.land.onto.default',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an arbitrary diff property.
|
||||
|
|
Loading…
Reference in a new issue