diff --git a/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php b/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php --- a/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php +++ b/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php @@ -212,9 +212,7 @@ ->setObject($object) ->execute(); - $track_value = $object->getDetail('branch-filter', array()); - $track_value = array_keys($track_value); - + $track_value = $object->getTrackOnlyRules(); $autoclose_value = $object->getAutocloseOnlyRules(); $automation_instructions = pht( diff --git a/src/applications/diffusion/management/DiffusionRepositoryBranchesManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositoryBranchesManagementPanel.php --- a/src/applications/diffusion/management/DiffusionRepositoryBranchesManagementPanel.php +++ b/src/applications/diffusion/management/DiffusionRepositoryBranchesManagementPanel.php @@ -23,7 +23,7 @@ $has_any = $repository->getDetail('default-branch') || - $repository->getDetail('branch-filter') || + $repository->getTrackOnlyRules() || $repository->getAutocloseOnlyRules(); if ($has_any) { @@ -74,12 +74,14 @@ ->setViewer($viewer); $default_branch = nonempty( - $repository->getHumanReadableDetail('default-branch'), + $repository->getDetail('default-branch'), phutil_tag('em', array(), $repository->getDefaultBranch())); $view->addProperty(pht('Default Branch'), $default_branch); + $track_only_rules = $repository->getTrackOnlyRules(); + $track_only_rules = implode(', ', $track_only_rules); $track_only = nonempty( - $repository->getHumanReadableDetail('branch-filter', array()), + $track_only_rules, phutil_tag('em', array(), pht('Track All Branches'))); $view->addProperty(pht('Track Only'), $track_only); diff --git a/src/applications/diffusion/management/DiffusionRepositorySubversionManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositorySubversionManagementPanel.php --- a/src/applications/diffusion/management/DiffusionRepositorySubversionManagementPanel.php +++ b/src/applications/diffusion/management/DiffusionRepositorySubversionManagementPanel.php @@ -68,7 +68,7 @@ ->setViewer($viewer); $default_branch = nonempty( - $repository->getHumanReadableDetail('svn-subpath'), + $repository->getDetail('svn-subpath'), phutil_tag('em', array(), pht('Import Entire Repository'))); $view->addProperty(pht('Import Only'), $default_branch); diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php --- a/src/applications/repository/storage/PhabricatorRepository.php +++ b/src/applications/repository/storage/PhabricatorRepository.php @@ -239,19 +239,6 @@ return idx($this->details, $key, $default); } - public function getHumanReadableDetail($key, $default = null) { - $value = $this->getDetail($key, $default); - - switch ($key) { - case 'branch-filter': - $value = array_keys($value); - $value = implode(', ', $value); - break; - } - - return $value; - } - public function setDetail($key, $value) { $this->details[$key] = $value; return $this; @@ -1211,6 +1198,16 @@ return $this; } + public function getTrackOnlyRules() { + return array_keys($this->getDetail('branch-filter', array())); + } + + public function setTrackOnlyRules(array $rules) { + $rules = array_fill_keys($rules, true); + $this->setDetail('branch-filter', $rules); + return $this; + } + /* -( Repository URI Management )------------------------------------------ */ diff --git a/src/applications/repository/storage/__tests__/PhabricatorRepositoryTestCase.php b/src/applications/repository/storage/__tests__/PhabricatorRepositoryTestCase.php --- a/src/applications/repository/storage/__tests__/PhabricatorRepositoryTestCase.php +++ b/src/applications/repository/storage/__tests__/PhabricatorRepositoryTestCase.php @@ -37,11 +37,7 @@ $repo->shouldTrackBranch('imaginary'), pht('Track all branches by default.')); - $repo->setDetail( - 'branch-filter', - array( - 'master' => true, - )); + $repo->setTrackOnlyRules(array('master')); $this->assertTrue( $repo->shouldTrackBranch('master'), diff --git a/src/applications/repository/xaction/PhabricatorRepositoryTrackOnlyTransaction.php b/src/applications/repository/xaction/PhabricatorRepositoryTrackOnlyTransaction.php --- a/src/applications/repository/xaction/PhabricatorRepositoryTrackOnlyTransaction.php +++ b/src/applications/repository/xaction/PhabricatorRepositoryTrackOnlyTransaction.php @@ -6,11 +6,11 @@ const TRANSACTIONTYPE = 'repo:track-only'; public function generateOldValue($object) { - return array_keys($object->getDetail('branch-filter', array())); + return $object->getTrackOnlyRules(); } public function applyInternalEffects($object, $value) { - $object->setDetail('branch-filter', array_fill_keys($value, true)); + $object->setTrackOnlyRules($value); } public function getTitle() {