@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

When `arc` has sent target branch data up after D14736, use it in the UI and "Land Revision"

Summary:
Ref T9952. Ref T3462. After D14736, if we have information about the target/"onto" branch, use it in the UI:

- Show "feature (branched from master)" instead of "feature".
- Default "Land Revision" to hit the correct branch.

Test Plan:
- Branched from `test` with branch tracking.
- Diffed.
- Saw "feature (branched from test)" in UI.
- Saw "test" fill as default in "Land Revision", despite the repository having a different default branch.

{F1020587}

{F1020588}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T3462, T9952

Differential Revision: https://secure.phabricator.com/D14737

+66 -5
+14 -4
src/applications/differential/controller/DifferentialRevisionOperationController.php
··· 30 30 $diff = $revision->getActiveDiff(); 31 31 $repository = $revision->getRepository(); 32 32 33 - $default_ref = $this->loadDefaultRef($repository); 33 + $default_ref = $this->loadDefaultRef($repository, $diff); 34 34 35 35 if ($default_ref) { 36 36 $v_ref = array($default_ref->getPHID()); ··· 133 133 ); 134 134 } 135 135 136 - private function loadDefaultRef(PhabricatorRepository $repository) { 137 - $default_name = $this->getDefaultRefName($repository); 136 + private function loadDefaultRef( 137 + PhabricatorRepository $repository, 138 + DifferentialDiff $diff) { 139 + $default_name = $this->getDefaultRefName($repository, $diff); 138 140 139 141 if (!strlen($default_name)) { 140 142 return null; ··· 145 147 ->executeOne(); 146 148 } 147 149 148 - private function getDefaultRefName(PhabricatorRepository $repository) { 150 + private function getDefaultRefName( 151 + PhabricatorRepository $repository, 152 + DifferentialDiff $diff) { 153 + 154 + $onto = $diff->loadTargetBranch(); 155 + if ($onto !== null) { 156 + return $onto; 157 + } 158 + 149 159 return $repository->getDefaultBranch(); 150 160 } 151 161
+9 -1
src/applications/differential/customfield/DifferentialBranchField.php
··· 44 44 } else if (strlen($bookmark)) { 45 45 return pht('%s (bookmark)', $bookmark); 46 46 } else if (strlen($branch)) { 47 - return $branch; 47 + $onto = $diff->loadTargetBranch(); 48 + if (strlen($onto)) { 49 + return pht( 50 + '%s (branched from %s)', 51 + $branch, 52 + $onto); 53 + } else { 54 + return $branch; 55 + } 48 56 } else { 49 57 return null; 50 58 }
+43
src/applications/differential/storage/DifferentialDiff.php
··· 489 489 return 'refs/tags/phabricator/diff/'.$this->getID(); 490 490 } 491 491 492 + public function loadTargetBranch() { 493 + // TODO: This is sketchy, but just eat the query cost until this can get 494 + // cleaned up. 495 + 496 + // For now, we're only returning a target if there's exactly one and it's 497 + // a branch, since we don't support landing to more esoteric targets like 498 + // tags yet. 499 + 500 + $property = id(new DifferentialDiffProperty())->loadOneWhere( 501 + 'diffID = %d AND name = %s', 502 + $this->getID(), 503 + 'arc:onto'); 504 + if (!$property) { 505 + return null; 506 + } 507 + 508 + $data = $property->getData(); 509 + 510 + if (!$data) { 511 + return null; 512 + } 513 + 514 + if (!is_array($data)) { 515 + return null; 516 + } 517 + 518 + if (count($data) != 1) { 519 + return null; 520 + } 521 + 522 + $onto = head($data); 523 + if (!is_array($onto)) { 524 + return null; 525 + } 526 + 527 + $type = idx($onto, 'type'); 528 + if ($type != 'branch') { 529 + return null; 530 + } 531 + 532 + return idx($onto, 'name'); 533 + } 534 + 492 535 493 536 /* -( PhabricatorApplicationTransactionInterface )------------------------- */ 494 537