Differential D15330 Diff 40879 src/applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php
Show All 16 Lines | final class DiffusionHistoryQueryConduitAPIMethod | ||||
protected function defineReturnType() { | protected function defineReturnType() { | ||||
return 'array'; | return 'array'; | ||||
} | } | ||||
protected function defineCustomParamTypes() { | protected function defineCustomParamTypes() { | ||||
return array( | return array( | ||||
'commit' => 'required string', | 'commit' => 'required string', | ||||
'against' => 'optional string', | |||||
'path' => 'required string', | 'path' => 'required string', | ||||
'offset' => 'required int', | 'offset' => 'required int', | ||||
'limit' => 'required int', | 'limit' => 'required int', | ||||
'needDirectChanges' => 'optional bool', | 'needDirectChanges' => 'optional bool', | ||||
'needChildChanges' => 'optional bool', | 'needChildChanges' => 'optional bool', | ||||
); | ); | ||||
} | } | ||||
protected function getResult(ConduitAPIRequest $request) { | protected function getResult(ConduitAPIRequest $request) { | ||||
$path_changes = parent::getResult($request); | $path_changes = parent::getResult($request); | ||||
return array( | return array( | ||||
'pathChanges' => mpull($path_changes, 'toDictionary'), | 'pathChanges' => mpull($path_changes, 'toDictionary'), | ||||
'parents' => $this->parents, | 'parents' => $this->parents, | ||||
); | ); | ||||
} | } | ||||
protected function getGitResult(ConduitAPIRequest $request) { | protected function getGitResult(ConduitAPIRequest $request) { | ||||
$drequest = $this->getDiffusionRequest(); | $drequest = $this->getDiffusionRequest(); | ||||
$repository = $drequest->getRepository(); | $repository = $drequest->getRepository(); | ||||
$commit_hash = $request->getValue('commit'); | $commit_hash = $request->getValue('commit'); | ||||
$against_hash = $request->getValue('against'); | |||||
$path = $request->getValue('path'); | $path = $request->getValue('path'); | ||||
$offset = $request->getValue('offset'); | $offset = $request->getValue('offset'); | ||||
$limit = $request->getValue('limit'); | $limit = $request->getValue('limit'); | ||||
if (strlen($against_hash)) { | |||||
$commit_range = "${against_hash}..${commit_hash}"; | |||||
} else { | |||||
$commit_range = $commit_hash; | |||||
} | |||||
list($stdout) = $repository->execxLocalCommand( | list($stdout) = $repository->execxLocalCommand( | ||||
'log '. | 'log '. | ||||
'--skip=%d '. | '--skip=%d '. | ||||
'-n %d '. | '-n %d '. | ||||
'--pretty=format:%s '. | '--pretty=format:%s '. | ||||
'%s -- %C', | '%s -- %C', | ||||
$offset, | $offset, | ||||
$limit, | $limit, | ||||
'%H:%P', | '%H:%P', | ||||
$commit_hash, | $commit_range, | ||||
// Git omits merge commits if the path is provided, even if it is empty. | // Git omits merge commits if the path is provided, even if it is empty. | ||||
(strlen($path) ? csprintf('%s', $path) : '')); | (strlen($path) ? csprintf('%s', $path) : '')); | ||||
$lines = explode("\n", trim($stdout)); | $lines = explode("\n", trim($stdout)); | ||||
$lines = array_filter($lines); | $lines = array_filter($lines); | ||||
if (!$lines) { | |||||
return array(); | |||||
} | |||||
$hash_list = array(); | $hash_list = array(); | ||||
$parent_map = array(); | $parent_map = array(); | ||||
foreach ($lines as $line) { | foreach ($lines as $line) { | ||||
list($hash, $parents) = explode(':', $line); | list($hash, $parents) = explode(':', $line); | ||||
$hash_list[] = $hash; | $hash_list[] = $hash; | ||||
$parent_map[$hash] = preg_split('/\s+/', $parents); | $parent_map[$hash] = preg_split('/\s+/', $parents); | ||||
} | } | ||||
$this->parents = $parent_map; | $this->parents = $parent_map; | ||||
if (!$hash_list) { | |||||
return array(); | |||||
} | |||||
return DiffusionQuery::loadHistoryForCommitIdentifiers( | return DiffusionQuery::loadHistoryForCommitIdentifiers( | ||||
$hash_list, | $hash_list, | ||||
$drequest); | $drequest); | ||||
} | } | ||||
protected function getMercurialResult(ConduitAPIRequest $request) { | protected function getMercurialResult(ConduitAPIRequest $request) { | ||||
$drequest = $this->getDiffusionRequest(); | $drequest = $this->getDiffusionRequest(); | ||||
$repository = $drequest->getRepository(); | $repository = $drequest->getRepository(); | ||||
▲ Show 20 Lines • Show All 185 Lines • Show Last 20 Lines |