Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15426547
D14737.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D14737.diff
View Options
diff --git a/src/applications/differential/controller/DifferentialRevisionOperationController.php b/src/applications/differential/controller/DifferentialRevisionOperationController.php
--- a/src/applications/differential/controller/DifferentialRevisionOperationController.php
+++ b/src/applications/differential/controller/DifferentialRevisionOperationController.php
@@ -30,7 +30,7 @@
$diff = $revision->getActiveDiff();
$repository = $revision->getRepository();
- $default_ref = $this->loadDefaultRef($repository);
+ $default_ref = $this->loadDefaultRef($repository, $diff);
if ($default_ref) {
$v_ref = array($default_ref->getPHID());
@@ -133,8 +133,10 @@
);
}
- private function loadDefaultRef(PhabricatorRepository $repository) {
- $default_name = $this->getDefaultRefName($repository);
+ private function loadDefaultRef(
+ PhabricatorRepository $repository,
+ DifferentialDiff $diff) {
+ $default_name = $this->getDefaultRefName($repository, $diff);
if (!strlen($default_name)) {
return null;
@@ -145,7 +147,15 @@
->executeOne();
}
- private function getDefaultRefName(PhabricatorRepository $repository) {
+ private function getDefaultRefName(
+ PhabricatorRepository $repository,
+ DifferentialDiff $diff) {
+
+ $onto = $diff->loadTargetBranch();
+ if ($onto !== null) {
+ return $onto;
+ }
+
return $repository->getDefaultBranch();
}
diff --git a/src/applications/differential/customfield/DifferentialBranchField.php b/src/applications/differential/customfield/DifferentialBranchField.php
--- a/src/applications/differential/customfield/DifferentialBranchField.php
+++ b/src/applications/differential/customfield/DifferentialBranchField.php
@@ -44,7 +44,15 @@
} else if (strlen($bookmark)) {
return pht('%s (bookmark)', $bookmark);
} else if (strlen($branch)) {
- return $branch;
+ $onto = $diff->loadTargetBranch();
+ if (strlen($onto)) {
+ return pht(
+ '%s (branched from %s)',
+ $branch,
+ $onto);
+ } else {
+ return $branch;
+ }
} else {
return null;
}
diff --git a/src/applications/differential/storage/DifferentialDiff.php b/src/applications/differential/storage/DifferentialDiff.php
--- a/src/applications/differential/storage/DifferentialDiff.php
+++ b/src/applications/differential/storage/DifferentialDiff.php
@@ -489,6 +489,49 @@
return 'refs/tags/phabricator/diff/'.$this->getID();
}
+ public function loadTargetBranch() {
+ // TODO: This is sketchy, but just eat the query cost until this can get
+ // cleaned up.
+
+ // For now, we're only returning a target if there's exactly one and it's
+ // a branch, since we don't support landing to more esoteric targets like
+ // tags yet.
+
+ $property = id(new DifferentialDiffProperty())->loadOneWhere(
+ 'diffID = %d AND name = %s',
+ $this->getID(),
+ 'arc:onto');
+ if (!$property) {
+ return null;
+ }
+
+ $data = $property->getData();
+
+ if (!$data) {
+ return null;
+ }
+
+ if (!is_array($data)) {
+ return null;
+ }
+
+ if (count($data) != 1) {
+ return null;
+ }
+
+ $onto = head($data);
+ if (!is_array($onto)) {
+ return null;
+ }
+
+ $type = idx($onto, 'type');
+ if ($type != 'branch') {
+ return null;
+ }
+
+ return idx($onto, 'name');
+ }
+
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 24, 9:33 AM (4 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7708271
Default Alt Text
D14737.diff (3 KB)
Attached To
Mode
D14737: When `arc` has sent target branch data up after D14736, use it in the UI and "Land Revision"
Attached
Detach File
Event Timeline
Log In to Comment