public function willProcessRequest(array $data) { if (isset($data['callsign'])) { $drequest = DiffusionRequest::newFromAphrontRequestDictionary($data); $this->diffusionRequest = $drequest; } }
public function processRequest() { $request = $this->getRequest(); $repository_phid = $request->getStr('repositoryPHID'); $repository = id(new PhabricatorRepository())->loadOneWhere('phid = %s', $repository_phid); if (!$repository) { return new Aphront400Response(); } $query_path = $request->getStr('q'); $query_path = ltrim($query_path, '/'); if (preg_match('@/$@', $query_path)) { $query_dir = $query_path; } else { $query_dir = dirname($query_path); if ($query_dir == '.') { $query_dir = ''; } } $drequest = DiffusionRequest::newFromAphrontRequestDictionary(array('callsign' => $repository->getCallsign(), 'path' => ':/' . $query_dir)); $browse_query = DiffusionBrowseQuery::newFromDiffusionRequest($drequest); $paths = $browse_query->loadPaths(); $output = array(); foreach ($paths as $path) { $full_path = $query_dir . $path->getPath(); if ($path->getFileType() == DifferentialChangeType::FILE_DIRECTORY) { $full_path .= '/'; } $output[] = array('/' . $full_path, null, substr(md5($full_path), 0, 7)); } return id(new AphrontAjaxResponse())->setContent($output); }
public function willProcessRequest(array $data) { $request = $this->getRequest(); if ($request->getStr('ref')) { $parts = explode(';', $request->getStr('ref')); $data['path'] = idx($parts, 0); $data['commit'] = idx($parts, 1); } $this->diffusionRequest = DiffusionRequest::newFromAphrontRequestDictionary($data); }
public function getURI() { $repo = $this->getRepository(); $file = $this->getPath(); $line = $this->getLineNumber(); $drequest = DiffusionRequest::newFromAphrontRequestDictionary(array('callsign' => $repo->getCallsign())); $branch = $drequest->getBranchURIComponent($drequest->getBranch()); $file = $branch . ltrim($file, '/'); return '/diffusion/' . $repo->getCallsign() . '/browse/' . $file . '$' . $line; }
protected function execute(ConduitAPIRequest $request) { $results = array(); $history = DiffusionHistoryQuery::newFromDiffusionRequest(DiffusionRequest::newFromAphrontRequestDictionary($request->getAllParameters()))->setLimit(self::RESULT_LIMIT)->needDirectChanges(true)->needChildChanges(true)->loadHistory(); $raw_commit_identifiers = mpull($history, 'getCommitIdentifier'); $result = array(); foreach ($raw_commit_identifiers as $id) { $result[] = 'r' . $request->getValue('callsign') . $id; } return $result; }
public final function handleRequest(AphrontRequest $request) { if ($request->getURIData('callsign') && $this->shouldLoadDiffusionRequest()) { try { $drequest = DiffusionRequest::newFromAphrontRequestDictionary($request->getURIMap(), $request); } catch (Exception $ex) { return id(new Aphront404Response())->setRequest($request); } $this->setDiffusionRequest($drequest); } return $this->processDiffusionRequest($request); }
public function processRequest() { $request = $this->getRequest(); $repository_phid = $request->getStr('repositoryPHID'); $repository = id(new PhabricatorRepository())->loadOneWhere('phid = %s', $repository_phid); if (!$repository) { return new Aphront400Response(); } $path = $request->getStr('path'); $path = ltrim($path, '/'); $drequest = DiffusionRequest::newFromAphrontRequestDictionary(array('callsign' => $repository->getCallsign(), 'path' => ':/' . $path)); $browse_query = DiffusionBrowseQuery::newFromDiffusionRequest($drequest); $browse_query->needValidityOnly(true); $valid = $browse_query->loadPaths(); if (!$valid) { switch ($browse_query->getReasonForEmptyResultSet()) { case DiffusionBrowseQuery::REASON_IS_FILE: $valid = true; break; case DiffusionBrowseQuery::REASON_IS_EMPTY: $valid = true; break; } } $output = array('valid' => (bool) $valid); if (!$valid) { $branch = $drequest->getBranch(); if ($branch) { $message = 'Not found in ' . $branch; } else { $message = 'Not found at HEAD'; } } else { $message = 'OK'; } $output['message'] = $message; return id(new AphrontAjaxResponse())->setContent($output); }
public function willProcessRequest(array $data) { $data = $data + array('dblob' => $this->getRequest()->getStr('ref')); $drequest = DiffusionRequest::newFromAphrontRequestDictionary($data); $this->diffusionRequest = $drequest; }
public function willProcessRequest(array $data) { $this->diffusionRequest = DiffusionRequest::newFromAphrontRequestDictionary($data); }
private static function buildDiffusionRequest(PhabricatorRepository $repository, PhabricatorRepositoryCommit $commit) { return DiffusionRequest::newFromAphrontRequestDictionary(array('callsign' => $repository->getCallsign(), 'commit' => $commit->getCommitIdentifier())); }
public function save() { // TODO: Transactions! $ret = parent::save(); if ($this->unsavedOwners) { $new_owners = array_fill_keys($this->unsavedOwners, true); $cur_owners = array(); foreach ($this->loadOwners() as $owner) { if (empty($new_owners[$owner->getUserPHID()])) { $owner->delete(); continue; } $cur_owners[$owner->getUserPHID()] = true; } $add_owners = array_diff_key($new_owners, $cur_owners); foreach ($add_owners as $phid => $ignored) { $owner = new PhabricatorOwnersOwner(); $owner->setPackageID($this->getID()); $owner->setUserPHID($phid); $owner->save(); } unset($this->unsavedOwners); } if ($this->unsavedPaths) { $new_paths = igroup($this->unsavedPaths, 'repositoryPHID', 'path'); $cur_paths = $this->loadPaths(); foreach ($cur_paths as $key => $path) { if (empty($new_paths[$path->getRepositoryPHID()][$path->getPath()])) { $path->delete(); unset($cur_paths[$key]); } } $cur_paths = mgroup($cur_paths, 'getRepositoryPHID', 'getPath'); foreach ($new_paths as $repository_phid => $paths) { // get repository object for path validation $repository = id(new PhabricatorRepository())->loadOneWhere('phid = %s', $repository_phid); if (!$repository) { continue; } foreach ($paths as $path => $ignored) { $path = ltrim($path, '/'); // build query to validate path $drequest = DiffusionRequest::newFromAphrontRequestDictionary(array('callsign' => $repository->getCallsign(), 'path' => ':/' . $path)); $query = DiffusionBrowseQuery::newFromDiffusionRequest($drequest); $query->needValidityOnly(true); $valid = $query->loadPaths(); $is_directory = true; if (!$valid) { switch ($query->getReasonForEmptyResultSet()) { case DiffusionBrowseQuery::REASON_IS_FILE: $valid = true; $is_directory = false; break; case DiffusionBrowseQuery::REASON_IS_EMPTY: $valid = true; break; } } if ($is_directory && substr($path, -1) != '/') { $path .= '/'; } if (substr($path, 0, 1) != '/') { $path = '/' . $path; } if (empty($cur_paths[$repository_phid][$path]) && $valid) { $obj = new PhabricatorOwnersPath(); $obj->setPackageID($this->getID()); $obj->setRepositoryPHID($repository_phid); $obj->setPath($path); $obj->save(); } } } unset($this->unsavedPaths); } return $ret; }
protected function processDiffusionRequest(AphrontRequest $request) { $data = $request->getURIMap(); $data = $data + array('dblob' => $this->getRequest()->getStr('ref')); try { $drequest = DiffusionRequest::newFromAphrontRequestDictionary($data, $request); } catch (Exception $ex) { return id(new Aphront404Response())->setRequest($request); } $this->setDiffusionRequest($drequest); $drequest = $this->getDiffusionRequest(); $viewer = $this->getViewer(); if (!$request->isAjax()) { // This request came out of the dropdown menu, either "View Standalone" // or "View Raw File". $view = $request->getStr('view'); if ($view == 'r') { $uri = $drequest->generateURI(array('action' => 'browse', 'params' => array('view' => 'raw'))); } else { $uri = $drequest->generateURI(array('action' => 'change')); } return id(new AphrontRedirectResponse())->setURI($uri); } $data = $this->callConduitWithDiffusionRequest('diffusion.diffquery', array('commit' => $drequest->getCommit(), 'path' => $drequest->getPath())); $drequest->updateSymbolicCommit($data['effectiveCommit']); $raw_changes = ArcanistDiffChange::newFromConduit($data['changes']); $diff = DifferentialDiff::newEphemeralFromRawChanges($raw_changes); $changesets = $diff->getChangesets(); $changeset = reset($changesets); if (!$changeset) { return new Aphront404Response(); } $parser = new DifferentialChangesetParser(); $parser->setUser($viewer); $parser->setChangeset($changeset); $parser->setRenderingReference($drequest->generateURI(array('action' => 'rendering-ref'))); $parser->readParametersFromRequest($request); $coverage = $drequest->loadCoverage(); if ($coverage) { $parser->setCoverage($coverage); } $commit = $drequest->loadCommit(); $pquery = new DiffusionPathIDQuery(array($changeset->getFilename())); $ids = $pquery->loadPathIDs(); $path_id = $ids[$changeset->getFilename()]; $parser->setLeftSideCommentMapping($path_id, false); $parser->setRightSideCommentMapping($path_id, true); $parser->setCanMarkDone($commit->getAuthorPHID() && $viewer->getPHID() == $commit->getAuthorPHID()); $parser->setObjectOwnerPHID($commit->getAuthorPHID()); $parser->setWhitespaceMode(DifferentialChangesetParser::WHITESPACE_SHOW_ALL); $inlines = PhabricatorAuditInlineComment::loadDraftAndPublishedComments($viewer, $commit->getPHID(), $path_id); if ($inlines) { foreach ($inlines as $inline) { $parser->parseInlineComment($inline); } $phids = mpull($inlines, 'getAuthorPHID'); $handles = $this->loadViewerHandles($phids); $parser->setHandles($handles); } $engine = new PhabricatorMarkupEngine(); $engine->setViewer($viewer); foreach ($inlines as $inline) { $engine->addObject($inline, PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY); } $engine->process(); $parser->setMarkupEngine($engine); $spec = $request->getStr('range'); list($range_s, $range_e, $mask) = DifferentialChangesetParser::parseRangeSpecification($spec); $parser->setRange($range_s, $range_e); $parser->setMask($mask); return id(new PhabricatorChangesetResponse())->setRenderedChangeset($parser->renderChangeset())->setUndoTemplates($parser->getRenderer()->renderUndoTemplates()); }
private function buildDiffusionRequest() { return DiffusionRequest::newFromAphrontRequestDictionary(array('callsign' => $this->repository->getCallsign(), 'commit' => $this->commit->getCommitIdentifier())); }