Differential D14943 Diff 36119 src/applications/diffusion/conduit/DiffusionQueryPathsConduitAPIMethod.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/conduit/DiffusionQueryPathsConduitAPIMethod.php
| Show All 21 Lines | return array( | ||||
| 'pattern' => 'optional string', | 'pattern' => 'optional string', | ||||
| 'limit' => 'optional int', | 'limit' => 'optional int', | ||||
| 'offset' => 'optional int', | 'offset' => 'optional int', | ||||
| ); | ); | ||||
| } | } | ||||
| protected function getResult(ConduitAPIRequest $request) { | protected function getResult(ConduitAPIRequest $request) { | ||||
| $results = parent::getResult($request); | $results = parent::getResult($request); | ||||
| $offset = $request->getValue('offset'); | $offset = $request->getValue('offset'); | ||||
| return array_slice($results, $offset); | return array_slice($results, $offset); | ||||
epriestley: The second issue is that pages 2+ of git results weren't returned correctly because the skipped… | |||||
| } | } | ||||
| protected function getGitResult(ConduitAPIRequest $request) { | protected function getGitResult(ConduitAPIRequest $request) { | ||||
| $drequest = $this->getDiffusionRequest(); | $drequest = $this->getDiffusionRequest(); | ||||
| $path = $drequest->getPath(); | $path = $drequest->getPath(); | ||||
| $commit = $request->getValue('commit'); | $commit = $request->getValue('commit'); | ||||
| $repository = $drequest->getRepository(); | $repository = $drequest->getRepository(); | ||||
| // http://comments.gmane.org/gmane.comp.version-control.git/197735 | // http://comments.gmane.org/gmane.comp.version-control.git/197735 | ||||
| $future = $repository->getLocalCommandFuture( | $future = $repository->getLocalCommandFuture( | ||||
| 'ls-tree --name-only -r -z %s -- %s', | 'ls-tree --name-only -r -z %s -- %s', | ||||
| $commit, | $commit, | ||||
| $path); | $path); | ||||
| $lines = id(new LinesOfALargeExecFuture($future))->setDelimiter("\0"); | $lines = id(new LinesOfALargeExecFuture($future))->setDelimiter("\0"); | ||||
| return $this->filterResults($lines, $request); | return $this->filterResults($lines, $request); | ||||
| } | } | ||||
| protected function getMercurialResult(ConduitAPIRequest $request) { | protected function getMercurialResult(ConduitAPIRequest $request) { | ||||
| $drequest = $this->getDiffusionRequest(); | $drequest = $this->getDiffusionRequest(); | ||||
| $repository = $drequest->getRepository(); | $repository = $drequest->getRepository(); | ||||
| $path = $request->getValue('path'); | $path = $request->getValue('path'); | ||||
| Show All 25 Lines | protected function filterResults($lines, ConduitAPIRequest $request) { | ||||
| if (strlen($pattern)) { | if (strlen($pattern)) { | ||||
| $pattern = '/'.preg_quote($pattern, '/').'/'; | $pattern = '/'.preg_quote($pattern, '/').'/'; | ||||
| } | } | ||||
| $results = array(); | $results = array(); | ||||
| $count = 0; | $count = 0; | ||||
| foreach ($lines as $line) { | foreach ($lines as $line) { | ||||
| if (!$pattern || preg_match($pattern, $line)) { | if (strlen($pattern) && !preg_match($pattern, $line)) { | ||||
| if ($count >= $offset) { | continue; | ||||
| $results[] = $line; | |||||
| } | } | ||||
Not Done Inline ActionsThis is the second place where earlier pages of results were being discarded. epriestley: This is the second place where earlier pages of results were being discarded. | |||||
| $results[] = $line; | |||||
| $count++; | $count++; | ||||
| if ($limit && ($count >= ($offset + $limit))) { | if ($limit && ($count >= ($offset + $limit))) { | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| return $results; | return $results; | ||||
| } | } | ||||
| } | } | ||||
The second issue is that pages 2+ of git results weren't returned correctly because the skipped results were discarded twice. This is one of two places where earlier pages of results were being discarded.