Page MenuHomePhabricator

D11874.id37742.diff
No OneTemporary

D11874.id37742.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -650,6 +650,7 @@
'DiffusionHovercardEngineExtension' => 'applications/diffusion/engineextension/DiffusionHovercardEngineExtension.php',
'DiffusionInlineCommentController' => 'applications/diffusion/controller/DiffusionInlineCommentController.php',
'DiffusionInlineCommentPreviewController' => 'applications/diffusion/controller/DiffusionInlineCommentPreviewController.php',
+ 'DiffusionInternalGitRawDiffQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionInternalGitRawDiffQueryConduitAPIMethod.php',
'DiffusionLastModifiedController' => 'applications/diffusion/controller/DiffusionLastModifiedController.php',
'DiffusionLastModifiedQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionLastModifiedQueryConduitAPIMethod.php',
'DiffusionLintController' => 'applications/diffusion/controller/DiffusionLintController.php',
@@ -4821,6 +4822,7 @@
'DiffusionHovercardEngineExtension' => 'PhabricatorHovercardEngineExtension',
'DiffusionInlineCommentController' => 'PhabricatorInlineCommentController',
'DiffusionInlineCommentPreviewController' => 'PhabricatorInlineCommentPreviewController',
+ 'DiffusionInternalGitRawDiffQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
'DiffusionLastModifiedController' => 'DiffusionController',
'DiffusionLastModifiedQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
'DiffusionLintController' => 'DiffusionController',
diff --git a/src/applications/conduit/method/ConduitAPIMethod.php b/src/applications/conduit/method/ConduitAPIMethod.php
--- a/src/applications/conduit/method/ConduitAPIMethod.php
+++ b/src/applications/conduit/method/ConduitAPIMethod.php
@@ -52,6 +52,9 @@
abstract protected function execute(ConduitAPIRequest $request);
+ public function isInternalAPI() {
+ return false;
+ }
public function getParamTypes() {
$types = $this->defineParamTypes();
diff --git a/src/applications/conduit/query/PhabricatorConduitMethodQuery.php b/src/applications/conduit/query/PhabricatorConduitMethodQuery.php
--- a/src/applications/conduit/query/PhabricatorConduitMethodQuery.php
+++ b/src/applications/conduit/query/PhabricatorConduitMethodQuery.php
@@ -9,6 +9,7 @@
private $applicationNames;
private $nameContains;
private $methods;
+ private $isInternal;
public function withMethods(array $methods) {
$this->methods = $methods;
@@ -40,6 +41,11 @@
return $this;
}
+ public function withIsInternal($is_internal) {
+ $this->isInternal = $is_internal;
+ return $this;
+ }
+
protected function loadPage() {
$methods = $this->getAllMethods();
$methods = $this->filterMethods($methods);
@@ -112,6 +118,14 @@
}
}
+ if ($this->isInternal !== null) {
+ foreach ($methods as $key => $method) {
+ if ($method->isInternalAPI() !== $this->isInternal) {
+ unset($methods[$key]);
+ }
+ }
+ }
+
return $methods;
}
diff --git a/src/applications/conduit/query/PhabricatorConduitSearchEngine.php b/src/applications/conduit/query/PhabricatorConduitSearchEngine.php
--- a/src/applications/conduit/query/PhabricatorConduitSearchEngine.php
+++ b/src/applications/conduit/query/PhabricatorConduitSearchEngine.php
@@ -37,6 +37,7 @@
$query->withIsStable($saved->getParameter('isStable'));
$query->withIsUnstable($saved->getParameter('isUnstable'));
$query->withIsDeprecated($saved->getParameter('isDeprecated'));
+ $query->withIsInternal(false);
$names = $saved->getParameter('applicationNames', array());
if ($names) {
diff --git a/src/applications/diffusion/conduit/DiffusionInternalGitRawDiffQueryConduitAPIMethod.php b/src/applications/diffusion/conduit/DiffusionInternalGitRawDiffQueryConduitAPIMethod.php
new file mode 100644
--- /dev/null
+++ b/src/applications/diffusion/conduit/DiffusionInternalGitRawDiffQueryConduitAPIMethod.php
@@ -0,0 +1,74 @@
+<?php
+
+final class DiffusionInternalGitRawDiffQueryConduitAPIMethod
+ extends DiffusionQueryConduitAPIMethod {
+
+ public function isInternalAPI() {
+ return true;
+ }
+
+ public function getAPIMethodName() {
+ return 'diffusion.internal.gitrawdiffquery';
+ }
+
+ public function getMethodDescription() {
+ return pht('Internal method for getting raw diff information.');
+ }
+
+ protected function defineReturnType() {
+ return 'string';
+ }
+
+ protected function defineCustomParamTypes() {
+ return array(
+ 'commit' => 'required string',
+ );
+ }
+
+ protected function getResult(ConduitAPIRequest $request) {
+ $drequest = $this->getDiffusionRequest();
+ $repository = $drequest->getRepository();
+
+ if (!$repository->isGit()) {
+ throw new Exception(
+ pht(
+ 'This API method can only be called on Git repositories.'));
+ }
+
+ // Check if the commit has parents. We're testing to see whether it is the
+ // first commit in history (in which case we must use "git log") or some
+ // other commit (in which case we can use "git diff"). We'd rather use
+ // "git diff" because it has the right behavior for merge commits, but
+ // it requires the commit to have a parent that we can diff against. The
+ // first commit doesn't, so "commit^" is not a valid ref.
+ list($parents) = $repository->execxLocalCommand(
+ 'log -n1 --format=%s %s',
+ '%P',
+ $request->getValue('commit'));
+
+ $use_log = !strlen(trim($parents));
+ if ($use_log) {
+ // This is the first commit so we need to use "log". We know it's not a
+ // merge commit because it couldn't be merging anything, so this is safe.
+
+ // NOTE: "--pretty=format: " is to disable diff output, we only want the
+ // part we get from "--raw".
+ list($raw) = $repository->execxLocalCommand(
+ 'log -n1 -M -C -B --find-copies-harder --raw -t '.
+ '--pretty=format: --abbrev=40 %s',
+ $request->getValue('commit'));
+ } else {
+ // Otherwise, we can use "diff", which will give us output for merges.
+ // We diff against the first parent, as this is generally the expectation
+ // and results in sensible behavior.
+ list($raw) = $repository->execxLocalCommand(
+ 'diff -n1 -M -C -B --find-copies-harder --raw -t '.
+ '--abbrev=40 %s^1 %s',
+ $request->getValue('commit'),
+ $request->getValue('commit'));
+ }
+
+ return $raw;
+ }
+
+}
diff --git a/src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryGitCommitChangeParserWorker.php b/src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryGitCommitChangeParserWorker.php
--- a/src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryGitCommitChangeParserWorker.php
+++ b/src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryGitCommitChangeParserWorker.php
@@ -7,38 +7,18 @@
PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit) {
- // Check if the commit has parents. We're testing to see whether it is the
- // first commit in history (in which case we must use "git log") or some
- // other commit (in which case we can use "git diff"). We'd rather use
- // "git diff" because it has the right behavior for merge commits, but
- // it requires the commit to have a parent that we can diff against. The
- // first commit doesn't, so "commit^" is not a valid ref.
- list($parents) = $repository->execxLocalCommand(
- 'log -n1 --format=%s %s',
- '%P',
- $commit->getCommitIdentifier());
-
- $use_log = !strlen(trim($parents));
- if ($use_log) {
- // This is the first commit so we need to use "log". We know it's not a
- // merge commit because it couldn't be merging anything, so this is safe.
-
- // NOTE: "--pretty=format: " is to disable diff output, we only want the
- // part we get from "--raw".
- list($raw) = $repository->execxLocalCommand(
- 'log -n1 -M -C -B --find-copies-harder --raw -t '.
- '--pretty=format: --abbrev=40 %s',
- $commit->getCommitIdentifier());
- } else {
- // Otherwise, we can use "diff", which will give us output for merges.
- // We diff against the first parent, as this is generally the expectation
- // and results in sensible behavior.
- list($raw) = $repository->execxLocalCommand(
- 'diff -n1 -M -C -B --find-copies-harder --raw -t '.
- '--abbrev=40 %s^1 %s',
- $commit->getCommitIdentifier(),
- $commit->getCommitIdentifier());
- }
+ $viewer = PhabricatorUser::getOmnipotentUser();
+ $raw = DiffusionQuery::callConduitWithDiffusionRequest(
+ $viewer,
+ DiffusionRequest::newFromDictionary(
+ array(
+ 'repository' => $repository,
+ 'user' => $viewer,
+ )),
+ 'diffusion.internal.gitrawdiffquery',
+ array(
+ 'commit' => $commit->getCommitIdentifier(),
+ ));
$changes = array();
$move_away = array();

File Metadata

Mime Type
text/plain
Expires
Fri, Jan 31, 12:12 PM (12 h, 35 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7078424
Default Alt Text
D11874.id37742.diff (8 KB)

Event Timeline