From 0212d7563267e3c3827ccb2d1bad963515a1c38d Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Fri, 17 May 2013 16:54:10 -0700 Subject: [PATCH] Diffusion - move commit branches query to conduit Summary: Ref T2784. Test Plan: loaded up a mercurial and a git commit. verified branches showed up correctly in object detail panel Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2784 Differential Revision: https://secure.phabricator.com/D5958 --- src/__phutil_library_map__.php | 10 +--- ...I_diffusion_commitbranchesquery_Method.php | 52 +++++++++++++++++++ .../DiffusionCommitBranchesController.php | 5 +- .../query/contains/DiffusionContainsQuery.php | 14 ----- .../contains/DiffusionGitContainsQuery.php | 18 ------- .../DiffusionMercurialContainsQuery.php | 18 ------- .../contains/DiffusionSvnContainsQuery.php | 10 ---- 7 files changed, 57 insertions(+), 70 deletions(-) create mode 100644 src/applications/diffusion/conduit/ConduitAPI_diffusion_commitbranchesquery_Method.php delete mode 100644 src/applications/diffusion/query/contains/DiffusionContainsQuery.php delete mode 100644 src/applications/diffusion/query/contains/DiffusionGitContainsQuery.php delete mode 100644 src/applications/diffusion/query/contains/DiffusionMercurialContainsQuery.php delete mode 100644 src/applications/diffusion/query/contains/DiffusionSvnContainsQuery.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 5b3f65e4ea..8b6fab92eb 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -147,6 +147,7 @@ phutil_register_library_map(array( 'ConduitAPI_diffusion_abstractquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_abstractquery_Method.php', 'ConduitAPI_diffusion_branchquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_branchquery_Method.php', 'ConduitAPI_diffusion_browsequery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_browsequery_Method.php', + 'ConduitAPI_diffusion_commitbranchesquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_commitbranchesquery_Method.php', 'ConduitAPI_diffusion_diffquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_diffquery_Method.php', 'ConduitAPI_diffusion_existsquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_existsquery_Method.php', 'ConduitAPI_diffusion_expandshortcommitquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_expandshortcommitquery_Method.php', @@ -429,7 +430,6 @@ phutil_register_library_map(array( 'DiffusionCommitParentsQuery' => 'applications/diffusion/query/parents/DiffusionCommitParentsQuery.php', 'DiffusionCommitQuery' => 'applications/diffusion/query/DiffusionCommitQuery.php', 'DiffusionCommitTagsController' => 'applications/diffusion/controller/DiffusionCommitTagsController.php', - 'DiffusionContainsQuery' => 'applications/diffusion/query/contains/DiffusionContainsQuery.php', 'DiffusionController' => 'applications/diffusion/controller/DiffusionController.php', 'DiffusionDiffController' => 'applications/diffusion/controller/DiffusionDiffController.php', 'DiffusionEmptyResultView' => 'applications/diffusion/view/DiffusionEmptyResultView.php', @@ -441,7 +441,6 @@ phutil_register_library_map(array( 'DiffusionGitBranch' => 'applications/diffusion/data/DiffusionGitBranch.php', 'DiffusionGitBranchTestCase' => 'applications/diffusion/data/__tests__/DiffusionGitBranchTestCase.php', 'DiffusionGitCommitParentsQuery' => 'applications/diffusion/query/parents/DiffusionGitCommitParentsQuery.php', - 'DiffusionGitContainsQuery' => 'applications/diffusion/query/contains/DiffusionGitContainsQuery.php', 'DiffusionGitExpandShortNameQuery' => 'applications/diffusion/query/expandshortname/DiffusionGitExpandShortNameQuery.php', 'DiffusionGitFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionGitFileContentQuery.php', 'DiffusionGitHistoryQuery' => 'applications/diffusion/query/history/DiffusionGitHistoryQuery.php', @@ -461,7 +460,6 @@ phutil_register_library_map(array( 'DiffusionLintDetailsController' => 'applications/diffusion/controller/DiffusionLintDetailsController.php', 'DiffusionLintSaveRunner' => 'applications/diffusion/DiffusionLintSaveRunner.php', 'DiffusionMercurialCommitParentsQuery' => 'applications/diffusion/query/parents/DiffusionMercurialCommitParentsQuery.php', - 'DiffusionMercurialContainsQuery' => 'applications/diffusion/query/contains/DiffusionMercurialContainsQuery.php', 'DiffusionMercurialExpandShortNameQuery' => 'applications/diffusion/query/expandshortname/DiffusionMercurialExpandShortNameQuery.php', 'DiffusionMercurialFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionMercurialFileContentQuery.php', 'DiffusionMercurialHistoryQuery' => 'applications/diffusion/query/history/DiffusionMercurialHistoryQuery.php', @@ -489,7 +487,6 @@ phutil_register_library_map(array( 'DiffusionSetupException' => 'applications/diffusion/exception/DiffusionSetupException.php', 'DiffusionStableCommitNameQuery' => 'applications/diffusion/query/stablecommitname/DiffusionStableCommitNameQuery.php', 'DiffusionSvnCommitParentsQuery' => 'applications/diffusion/query/parents/DiffusionSvnCommitParentsQuery.php', - 'DiffusionSvnContainsQuery' => 'applications/diffusion/query/contains/DiffusionSvnContainsQuery.php', 'DiffusionSvnFileContentQuery' => 'applications/diffusion/query/filecontent/DiffusionSvnFileContentQuery.php', 'DiffusionSvnHistoryQuery' => 'applications/diffusion/query/history/DiffusionSvnHistoryQuery.php', 'DiffusionSvnMergedCommitsQuery' => 'applications/diffusion/query/mergedcommits/DiffusionSvnMergedCommitsQuery.php', @@ -1952,6 +1949,7 @@ phutil_register_library_map(array( 'ConduitAPI_diffusion_abstractquery_Method' => 'ConduitAPI_diffusion_Method', 'ConduitAPI_diffusion_branchquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method', 'ConduitAPI_diffusion_browsequery_Method' => 'ConduitAPI_diffusion_abstractquery_Method', + 'ConduitAPI_diffusion_commitbranchesquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method', 'ConduitAPI_diffusion_diffquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method', 'ConduitAPI_diffusion_existsquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method', 'ConduitAPI_diffusion_expandshortcommitquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method', @@ -2224,7 +2222,6 @@ phutil_register_library_map(array( 'DiffusionCommitParentsQuery' => 'DiffusionQuery', 'DiffusionCommitQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'DiffusionCommitTagsController' => 'DiffusionController', - 'DiffusionContainsQuery' => 'DiffusionQuery', 'DiffusionController' => 'PhabricatorController', 'DiffusionDiffController' => 'DiffusionController', 'DiffusionEmptyResultView' => 'DiffusionView', @@ -2234,7 +2231,6 @@ phutil_register_library_map(array( 'DiffusionFileContentQuery' => 'DiffusionQuery', 'DiffusionGitBranchTestCase' => 'PhabricatorTestCase', 'DiffusionGitCommitParentsQuery' => 'DiffusionCommitParentsQuery', - 'DiffusionGitContainsQuery' => 'DiffusionContainsQuery', 'DiffusionGitExpandShortNameQuery' => 'DiffusionExpandShortNameQuery', 'DiffusionGitFileContentQuery' => 'DiffusionFileContentQuery', 'DiffusionGitHistoryQuery' => 'DiffusionHistoryQuery', @@ -2253,7 +2249,6 @@ phutil_register_library_map(array( 'DiffusionLintController' => 'DiffusionController', 'DiffusionLintDetailsController' => 'DiffusionController', 'DiffusionMercurialCommitParentsQuery' => 'DiffusionCommitParentsQuery', - 'DiffusionMercurialContainsQuery' => 'DiffusionContainsQuery', 'DiffusionMercurialExpandShortNameQuery' => 'DiffusionExpandShortNameQuery', 'DiffusionMercurialFileContentQuery' => 'DiffusionFileContentQuery', 'DiffusionMercurialHistoryQuery' => 'DiffusionHistoryQuery', @@ -2273,7 +2268,6 @@ phutil_register_library_map(array( 'DiffusionSetupException' => 'AphrontUsageException', 'DiffusionStableCommitNameQuery' => 'DiffusionQuery', 'DiffusionSvnCommitParentsQuery' => 'DiffusionCommitParentsQuery', - 'DiffusionSvnContainsQuery' => 'DiffusionContainsQuery', 'DiffusionSvnFileContentQuery' => 'DiffusionFileContentQuery', 'DiffusionSvnHistoryQuery' => 'DiffusionHistoryQuery', 'DiffusionSvnMergedCommitsQuery' => 'DiffusionMergedCommitsQuery', diff --git a/src/applications/diffusion/conduit/ConduitAPI_diffusion_commitbranchesquery_Method.php b/src/applications/diffusion/conduit/ConduitAPI_diffusion_commitbranchesquery_Method.php new file mode 100644 index 0000000000..583ea4df79 --- /dev/null +++ b/src/applications/diffusion/conduit/ConduitAPI_diffusion_commitbranchesquery_Method.php @@ -0,0 +1,52 @@ + 'required string', + ); + } + + protected function getGitResult(ConduitAPIRequest $request) { + $drequest = $this->getDiffusionRequest(); + $repository = $drequest->getRepository(); + $commit = $request->getValue('commit'); + + list($contains) = $repository->execxLocalCommand( + 'branch -r --verbose --no-abbrev --contains %s', + $commit); + + return DiffusionGitBranch::parseRemoteBranchOutput( + $contains, + DiffusionBranchInformation::DEFAULT_GIT_REMOTE); + } + + protected function getMercurialResult(ConduitAPIRequest $request) { + $drequest = $this->getDiffusionRequest(); + $repository = $drequest->getRepository(); + $commit = $request->getValue('commit'); + + list($contains) = $repository->execxLocalCommand( + 'log --template %s --limit 1 --rev %s --', + '{branch}', + $commit); + + return array( + trim($contains) => $commit, + ); + + } +} diff --git a/src/applications/diffusion/controller/DiffusionCommitBranchesController.php b/src/applications/diffusion/controller/DiffusionCommitBranchesController.php index 9453f9fe44..caacef56c7 100644 --- a/src/applications/diffusion/controller/DiffusionCommitBranchesController.php +++ b/src/applications/diffusion/controller/DiffusionCommitBranchesController.php @@ -10,8 +10,9 @@ final class DiffusionCommitBranchesController extends DiffusionController { public function processRequest() { $request = $this->getDiffusionRequest(); - $branch_query = DiffusionContainsQuery::newFromDiffusionRequest($request); - $branches = $branch_query->loadContainingBranches(); + $branches = $this->callConduitWithDiffusionRequest( + 'diffusion.commitbranchesquery', + array('commit' => $request->getCommit())); $branch_links = array(); foreach ($branches as $branch => $commit) { diff --git a/src/applications/diffusion/query/contains/DiffusionContainsQuery.php b/src/applications/diffusion/query/contains/DiffusionContainsQuery.php deleted file mode 100644 index 03aaf0aac7..0000000000 --- a/src/applications/diffusion/query/contains/DiffusionContainsQuery.php +++ /dev/null @@ -1,14 +0,0 @@ -executeQuery(); - } - -} diff --git a/src/applications/diffusion/query/contains/DiffusionGitContainsQuery.php b/src/applications/diffusion/query/contains/DiffusionGitContainsQuery.php deleted file mode 100644 index 83af8c0207..0000000000 --- a/src/applications/diffusion/query/contains/DiffusionGitContainsQuery.php +++ /dev/null @@ -1,18 +0,0 @@ -getRequest(); - $repository = $request->getRepository(); - - list($contains) = $repository->execxLocalCommand( - 'branch -r --verbose --no-abbrev --contains %s', - $request->getCommit()); - - return DiffusionGitBranch::parseRemoteBranchOutput( - $contains, - DiffusionBranchInformation::DEFAULT_GIT_REMOTE); - } - -} diff --git a/src/applications/diffusion/query/contains/DiffusionMercurialContainsQuery.php b/src/applications/diffusion/query/contains/DiffusionMercurialContainsQuery.php deleted file mode 100644 index dbf40062ba..0000000000 --- a/src/applications/diffusion/query/contains/DiffusionMercurialContainsQuery.php +++ /dev/null @@ -1,18 +0,0 @@ -getRequest(); - $repository = $request->getRepository(); - list($contains) = $repository->execxLocalCommand( - 'log --template %s --limit 1 --rev %s --', - '{branch}', - $request->getCommit()); - - return array( - trim($contains) => $request->getCommit(), - ); - } - -} diff --git a/src/applications/diffusion/query/contains/DiffusionSvnContainsQuery.php b/src/applications/diffusion/query/contains/DiffusionSvnContainsQuery.php deleted file mode 100644 index 3f86c46931..0000000000 --- a/src/applications/diffusion/query/contains/DiffusionSvnContainsQuery.php +++ /dev/null @@ -1,10 +0,0 @@ -