Page MenuHomePhabricator

D14940.id36116.diff
No OneTemporary

D14940.id36116.diff

diff --git a/src/applications/diffusion/application/PhabricatorDiffusionApplication.php b/src/applications/diffusion/application/PhabricatorDiffusionApplication.php
--- a/src/applications/diffusion/application/PhabricatorDiffusionApplication.php
+++ b/src/applications/diffusion/application/PhabricatorDiffusionApplication.php
@@ -47,8 +47,13 @@
public function getRoutes() {
return array(
- '/r(?P<callsign>[A-Z]+)(?P<commit>[a-z0-9]+)'
+ '/(?:'.
+ 'r(?P<repositoryCallsign>[A-Z]+)'.
+ '|'.
+ 'R(?P<repositoryID>[1-9]\d*):'.
+ ')(?P<commit>[a-f0-9]+)'
=> 'DiffusionCommitController',
+
'/diffusion/' => array(
'(?:query/(?P<queryKey>[^/]+)/)?'
=> 'DiffusionRepositoryListController',
diff --git a/src/applications/diffusion/controller/DiffusionCommitController.php b/src/applications/diffusion/controller/DiffusionCommitController.php
--- a/src/applications/diffusion/controller/DiffusionCommitController.php
+++ b/src/applications/diffusion/controller/DiffusionCommitController.php
@@ -17,19 +17,15 @@
return true;
}
- protected function shouldLoadDiffusionRequest() {
- return false;
- }
+ public function handleRequest(AphrontRequest $request) {
+ $response = $this->loadDiffusionContext();
+ if ($response) {
+ return $response;
+ }
- protected function processDiffusionRequest(AphrontRequest $request) {
- $user = $request->getUser();
+ $drequest = $this->getDiffusionRequest();
- // This controller doesn't use blob/path stuff, just pass the dictionary
- // in directly instead of using the AphrontRequest parsing mechanism.
- $data = $request->getURIMap();
- $data['user'] = $user;
- $drequest = DiffusionRequest::newFromDictionary($data);
- $this->diffusionRequest = $drequest;
+ $user = $request->getUser();
if ($request->getStr('diff')) {
return $this->buildRawDiffResponse($drequest);
diff --git a/src/applications/diffusion/controller/DiffusionController.php b/src/applications/diffusion/controller/DiffusionController.php
--- a/src/applications/diffusion/controller/DiffusionController.php
+++ b/src/applications/diffusion/controller/DiffusionController.php
@@ -35,7 +35,7 @@
return true;
}
- final public function handleRequest(AphrontRequest $request) {
+ public function handleRequest(AphrontRequest $request) {
if ($request->getURIData('callsign') &&
$this->shouldLoadDiffusionRequest()) {
try {
@@ -48,10 +48,51 @@
}
$this->setDiffusionRequest($drequest);
}
+
return $this->processDiffusionRequest($request);
}
- abstract protected function processDiffusionRequest(AphrontRequest $request);
+ protected function loadDiffusionContext() {
+ $request = $this->getRequest();
+ $viewer = $this->getViewer();
+
+ $identifier = $request->getURIData('repositoryCallsign');
+ if (!strlen($identifier)) {
+ $identifier = (int)$request->getURIData('repositoryID');
+ }
+
+ $blob = $request->getURIData('dblob');
+ if (strlen($blob)) {
+ $parsed = DiffusionRequest::parseRequestBlob($blob);
+ } else {
+ $parsed = array(
+ 'commit' => $request->getURIData('commit'),
+ 'path' => $request->getURIData('path'),
+ 'line' => $request->getURIData('line'),
+ 'branch' => $request->getURIData('branch'),
+ 'lint' => $request->getStr('lint'),
+ );
+ }
+
+ $params = array(
+ 'repository' => $identifier,
+ 'user' => $viewer,
+ ) + $parsed;
+
+ $drequest = DiffusionRequest::newFromDictionary($params);
+
+ if (!$drequest) {
+ return new Aphront404Response();
+ }
+
+ $this->diffusionRequest = $drequest;
+
+ return null;
+ }
+
+ protected function processDiffusionRequest(AphrontRequest $request) {
+ throw new PhutilMethodNotImplementedException();
+ }
public function buildCrumbs(array $spec = array()) {
$crumbs = $this->buildApplicationCrumbs();
diff --git a/src/applications/diffusion/request/DiffusionRequest.php b/src/applications/diffusion/request/DiffusionRequest.php
--- a/src/applications/diffusion/request/DiffusionRequest.php
+++ b/src/applications/diffusion/request/DiffusionRequest.php
@@ -105,6 +105,10 @@
$object = self::newFromRepository($repository);
}
+ if (!$object) {
+ return null;
+ }
+
$object->initializeFromDictionary($data);
return $object;
@@ -175,7 +179,7 @@
->executeOne();
if (!$repository) {
- throw new Exception(pht("No such repository '%s'.", $identifier));
+ return null;
}
return self::newFromRepository($repository);
diff --git a/src/applications/repository/query/PhabricatorRepositoryQuery.php b/src/applications/repository/query/PhabricatorRepositoryQuery.php
--- a/src/applications/repository/query/PhabricatorRepositoryQuery.php
+++ b/src/applications/repository/query/PhabricatorRepositoryQuery.php
@@ -55,7 +55,7 @@
$monograms = array();
foreach ($identifiers as $identifier) {
- if (ctype_digit($identifier)) {
+ if (ctype_digit((string)$identifier)) {
$ids[$identifier] = $identifier;
} else if (preg_match('/^(r[A-Z]+)|(R[1-9]\d*)\z/', $identifier)) {
$monograms[$identifier] = $identifier;
diff --git a/src/applications/repository/storage/PhabricatorRepositoryCommit.php b/src/applications/repository/storage/PhabricatorRepositoryCommit.php
--- a/src/applications/repository/storage/PhabricatorRepositoryCommit.php
+++ b/src/applications/repository/storage/PhabricatorRepositoryCommit.php
@@ -252,8 +252,12 @@
$repository = $this->getRepository();
$callsign = $repository->getCallsign();
$identifier = $this->getCommitIdentifier();
-
- return "r{$callsign}{$identifier}";
+ if ($callsign !== null) {
+ return "r{$callsign}{$identifier}";
+ } else {
+ $id = $repository->getID();
+ return "R{$id}:{$identifier}";
+ }
}
public function getDisplayName() {

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 7, 9:17 PM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6744706
Default Alt Text
D14940.id36116.diff (5 KB)

Event Timeline