3 final class DiffusionPathChangeQuery
extends Phobject
{
8 public function setLimit($limit) {
13 public function getLimit() {
17 private function __construct() {
21 public static function newFromDiffusionRequest(
22 DiffusionRequest
$request) {
23 $query = new DiffusionPathChangeQuery();
24 $query->request
= $request;
29 protected function getRequest() {
30 return $this->request
;
33 public function loadChanges() {
34 return $this->executeQuery();
37 protected function executeQuery() {
39 $drequest = $this->getRequest();
40 $repository = $drequest->getRepository();
42 $commit = $drequest->loadCommit();
44 $conn_r = $repository->establishConnection('r');
52 $limit = qsprintf($conn_r, '');
55 $raw_changes = queryfx_all(
57 'SELECT c.*, p.path pathName, t.path targetPathName,
58 i.commitIdentifier targetCommitIdentifier
60 LEFT JOIN %T p ON c.pathID = p.id
61 LEFT JOIN %T t ON c.targetPathID = t.id
62 LEFT JOIN %T i ON c.targetCommitID = i.id
63 WHERE c.commitID = %d AND isDirect = 1 %Q',
64 PhabricatorRepository
::TABLE_PATHCHANGE
,
65 PhabricatorRepository
::TABLE_PATH
,
66 PhabricatorRepository
::TABLE_PATH
,
67 $commit->getTableName(),
71 $limited = $this->limit
&& (count($raw_changes) > $this->limit
);
73 $raw_changes = array_slice($raw_changes, 0, $this->limit
);
78 $raw_changes = isort($raw_changes, 'pathName');
79 foreach ($raw_changes as $raw_change) {
80 $type = $raw_change['changeType'];
81 if ($type == DifferentialChangeType
::TYPE_CHILD
) {
85 $change = new DiffusionPathChange();
86 $change->setPath(ltrim($raw_change['pathName'], '/'));
87 $change->setChangeType($raw_change['changeType']);
88 $change->setFileType($raw_change['fileType']);
89 $change->setCommitIdentifier($commit->getCommitIdentifier());
91 $change->setTargetPath(ltrim($raw_change['targetPathName'], '/'));
92 $change->setTargetCommitIdentifier($raw_change['targetCommitIdentifier']);
94 $id = $raw_change['pathID'];
95 $changes[$id] = $change;
98 // Deduce the away paths by examining all the changes, if we loaded them
103 foreach ($changes as $change) {
104 if ($change->getTargetPath()) {
105 $away[$change->getTargetPath()][] = $change->getPath();
108 foreach ($changes as $change) {
109 if (isset($away[$change->getPath()])) {
110 $change->setAwayPaths($away[$change->getPath()]);