Changeset View
Changeset View
Standalone View
Standalone View
src/repository/marker/ArcanistRepositoryMarkerQuery.php
| <?php | <?php | ||||
| abstract class ArcanistRepositoryMarkerQuery | abstract class ArcanistRepositoryMarkerQuery | ||||
| extends Phobject { | extends ArcanistRepositoryQuery { | ||||
| private $repositoryAPI; | |||||
| private $isActive; | private $isActive; | ||||
| private $markerTypes; | private $markerTypes; | ||||
| private $names; | private $names; | ||||
| private $commitHashes; | private $commitHashes; | ||||
| private $ancestorCommitHashes; | private $ancestorCommitHashes; | ||||
| final public function setRepositoryAPI(ArcanistRepositoryAPI $api) { | |||||
| $this->repositoryAPI = $api; | |||||
| return $this; | |||||
| } | |||||
| final public function getRepositoryAPI() { | |||||
| return $this->repositoryAPI; | |||||
| } | |||||
| final public function withMarkerTypes(array $types) { | final public function withMarkerTypes(array $types) { | ||||
| $this->markerTypes = array_fuse($types); | $this->markerTypes = array_fuse($types); | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| final public function withNames(array $names) { | final public function withNames(array $names) { | ||||
| $this->names = array_fuse($names); | $this->names = array_fuse($names); | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| final public function withIsActive($active) { | final public function withIsActive($active) { | ||||
| $this->isActive = $active; | $this->isActive = $active; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| final public function executeOne() { | |||||
| $markers = $this->execute(); | |||||
| if (!$markers) { | |||||
| return null; | |||||
| } | |||||
| if (count($markers) > 1) { | |||||
| throw new Exception( | |||||
| pht( | |||||
| 'Query matched multiple markers, expected zero or one.')); | |||||
| } | |||||
| return head($markers); | |||||
| } | |||||
| final public function execute() { | final public function execute() { | ||||
| $markers = $this->newRefMarkers(); | $markers = $this->newRefMarkers(); | ||||
| $api = $this->getRepositoryAPI(); | $api = $this->getRepositoryAPI(); | ||||
| foreach ($markers as $marker) { | foreach ($markers as $marker) { | ||||
| $state_ref = id(new ArcanistWorkingCopyStateRef()) | $state_ref = id(new ArcanistWorkingCopyStateRef()) | ||||
| ->setCommitRef($marker->getCommitRef()); | ->setCommitRef($marker->getCommitRef()); | ||||
| ▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines | |||||