Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15360821
D11874.id32274.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D11874.id32274.diff
View Options
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
@@ -581,6 +581,7 @@
'DiffusionQueryPathsConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionQueryPathsConduitAPIMethod.php',
'DiffusionRawDiffQuery' => 'applications/diffusion/query/rawdiff/DiffusionRawDiffQuery.php',
'DiffusionRawDiffQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionRawDiffQueryConduitAPIMethod.php',
+ 'DiffusionRawDiffStatQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionRawDiffStatQueryConduitAPIMethod.php',
'DiffusionReadmeView' => 'applications/diffusion/view/DiffusionReadmeView.php',
'DiffusionRefNotFoundException' => 'applications/diffusion/exception/DiffusionRefNotFoundException.php',
'DiffusionRefTableController' => 'applications/diffusion/controller/DiffusionRefTableController.php',
@@ -3949,6 +3950,7 @@
'DiffusionQueryPathsConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
'DiffusionRawDiffQuery' => 'DiffusionQuery',
'DiffusionRawDiffQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
+ 'DiffusionRawDiffStatQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
'DiffusionReadmeView' => 'DiffusionView',
'DiffusionRefNotFoundException' => 'Exception',
'DiffusionRefTableController' => 'DiffusionController',
diff --git a/src/applications/diffusion/conduit/DiffusionRawDiffStatQueryConduitAPIMethod.php b/src/applications/diffusion/conduit/DiffusionRawDiffStatQueryConduitAPIMethod.php
new file mode 100644
--- /dev/null
+++ b/src/applications/diffusion/conduit/DiffusionRawDiffStatQueryConduitAPIMethod.php
@@ -0,0 +1,72 @@
+<?php
+
+final class DiffusionRawDiffStatQueryConduitAPIMethod
+ extends DiffusionQueryConduitAPIMethod {
+
+ public function getAPIMethodName() {
+ return 'diffusion.rawdiffstatquery';
+ }
+
+ public function getMethodDescription() {
+ return pht(
+ 'Get raw diff stat information from '.
+ 'a repository for a specific commit.');
+ }
+
+ protected function defineReturnType() {
+ return 'string';
+ }
+
+ protected function defineCustomParamTypes() {
+ return array(
+ 'commit' => 'required string',
+ );
+ }
+
+ protected function getResult(ConduitAPIRequest $request) {
+ $drequest = $this->getDiffusionRequest();
+
+ $vcs = $drequest->getRepository()->getVersionControlSystem();
+ $is_git = ($vcs == PhabricatorRepositoryType::REPOSITORY_TYPE_GIT);
+ if (!$is_git) {
+ throw new Exception(pht(
+ 'This 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) = $drequest->getRepository()->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) = $drequest->getRepository()->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) = $drequest->getRepository()->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.rawdiffstatquery',
+ array(
+ 'commit' => $commit->getCommitIdentifier(),
+ ));
$changes = array();
$move_away = array();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 12, 10:26 AM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7583185
Default Alt Text
D11874.id32274.diff (6 KB)
Attached To
Mode
D11874: Use Conduit in PhabricatorRepositoryGitCommitChangeParserWorker
Attached
Detach File
Event Timeline
Log In to Comment