mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-30 01:10:58 +01:00
Show all branches a commit appears on
Summary: We show the contextual branch (always the repository default branch) when viewing a commit. Instead, show all branches the commit appears on. Also pull some of the duplicated DiffusionXQuery stuff into a DiffusionQuery base class, I'll do a followup to reduce more duplication. Test Plan: Looked at a commit in Git. My HG and SVN setups are a little borked so I kind of faked tests in them -- I'm fixing them now. Reviewers: btrahan, jungejason, fratrik Reviewed By: btrahan CC: aran Maniphest Tasks: T768 Differential Revision: https://secure.phabricator.com/D1458
This commit is contained in:
parent
008461a395
commit
8b4b614d15
14 changed files with 268 additions and 7 deletions
|
@ -262,6 +262,7 @@ phutil_register_library_map(array(
|
|||
'DiffusionCommitChangeTableView' => 'applications/diffusion/view/commitchangetable',
|
||||
'DiffusionCommitController' => 'applications/diffusion/controller/commit',
|
||||
'DiffusionCommitListController' => 'applications/diffusion/controller/commitlist',
|
||||
'DiffusionContainsQuery' => 'applications/diffusion/query/contains/base',
|
||||
'DiffusionController' => 'applications/diffusion/controller/base',
|
||||
'DiffusionDiffController' => 'applications/diffusion/controller/diff',
|
||||
'DiffusionDiffQuery' => 'applications/diffusion/query/diff/base',
|
||||
|
@ -270,6 +271,7 @@ phutil_register_library_map(array(
|
|||
'DiffusionGitBranchQuery' => 'applications/diffusion/query/branch/git',
|
||||
'DiffusionGitBranchQueryTestCase' => 'applications/diffusion/query/branch/git/__tests__',
|
||||
'DiffusionGitBrowseQuery' => 'applications/diffusion/query/browse/git',
|
||||
'DiffusionGitContainsQuery' => 'applications/diffusion/query/contains/git',
|
||||
'DiffusionGitDiffQuery' => 'applications/diffusion/query/diff/git',
|
||||
'DiffusionGitFileContentQuery' => 'applications/diffusion/query/filecontent/git',
|
||||
'DiffusionGitHistoryQuery' => 'applications/diffusion/query/history/git',
|
||||
|
@ -283,6 +285,7 @@ phutil_register_library_map(array(
|
|||
'DiffusionLastModifiedQuery' => 'applications/diffusion/query/lastmodified/base',
|
||||
'DiffusionMercurialBranchQuery' => 'applications/diffusion/query/branch/mercurial',
|
||||
'DiffusionMercurialBrowseQuery' => 'applications/diffusion/query/browse/mercurial',
|
||||
'DiffusionMercurialContainsQuery' => 'applications/diffusion/query/contains/mercurial',
|
||||
'DiffusionMercurialDiffQuery' => 'applications/diffusion/query/diff/mercurial',
|
||||
'DiffusionMercurialFileContentQuery' => 'applications/diffusion/query/filecontent/mercurial',
|
||||
'DiffusionMercurialHistoryQuery' => 'applications/diffusion/query/history/mercurial',
|
||||
|
@ -294,9 +297,11 @@ phutil_register_library_map(array(
|
|||
'DiffusionPathIDQuery' => 'applications/diffusion/query/pathid/base',
|
||||
'DiffusionPathQueryTestCase' => 'applications/diffusion/query/pathid/base/__tests__',
|
||||
'DiffusionPathValidateController' => 'applications/diffusion/controller/pathvalidate',
|
||||
'DiffusionQuery' => 'applications/diffusion/query/base',
|
||||
'DiffusionRepositoryController' => 'applications/diffusion/controller/repository',
|
||||
'DiffusionRepositoryPath' => 'applications/diffusion/data/repositorypath',
|
||||
'DiffusionRequest' => 'applications/diffusion/request/base',
|
||||
'DiffusionSVNContainsQuery' => 'applications/diffusion/query/contains/svn',
|
||||
'DiffusionSvnBrowseQuery' => 'applications/diffusion/query/browse/svn',
|
||||
'DiffusionSvnDiffQuery' => 'applications/diffusion/query/diff/svn',
|
||||
'DiffusionSvnFileContentQuery' => 'applications/diffusion/query/filecontent/svn',
|
||||
|
@ -997,11 +1002,13 @@ phutil_register_library_map(array(
|
|||
'DiffusionCommitChangeTableView' => 'DiffusionView',
|
||||
'DiffusionCommitController' => 'DiffusionController',
|
||||
'DiffusionCommitListController' => 'DiffusionController',
|
||||
'DiffusionContainsQuery' => 'DiffusionQuery',
|
||||
'DiffusionController' => 'PhabricatorController',
|
||||
'DiffusionDiffController' => 'DiffusionController',
|
||||
'DiffusionGitBranchQuery' => 'DiffusionBranchQuery',
|
||||
'DiffusionGitBranchQueryTestCase' => 'PhabricatorTestCase',
|
||||
'DiffusionGitBrowseQuery' => 'DiffusionBrowseQuery',
|
||||
'DiffusionGitContainsQuery' => 'DiffusionContainsQuery',
|
||||
'DiffusionGitDiffQuery' => 'DiffusionDiffQuery',
|
||||
'DiffusionGitFileContentQuery' => 'DiffusionFileContentQuery',
|
||||
'DiffusionGitHistoryQuery' => 'DiffusionHistoryQuery',
|
||||
|
@ -1013,6 +1020,7 @@ phutil_register_library_map(array(
|
|||
'DiffusionLastModifiedController' => 'DiffusionController',
|
||||
'DiffusionMercurialBranchQuery' => 'DiffusionBranchQuery',
|
||||
'DiffusionMercurialBrowseQuery' => 'DiffusionBrowseQuery',
|
||||
'DiffusionMercurialContainsQuery' => 'DiffusionContainsQuery',
|
||||
'DiffusionMercurialDiffQuery' => 'DiffusionDiffQuery',
|
||||
'DiffusionMercurialFileContentQuery' => 'DiffusionFileContentQuery',
|
||||
'DiffusionMercurialHistoryQuery' => 'DiffusionHistoryQuery',
|
||||
|
@ -1022,6 +1030,7 @@ phutil_register_library_map(array(
|
|||
'DiffusionPathQueryTestCase' => 'PhabricatorTestCase',
|
||||
'DiffusionPathValidateController' => 'DiffusionController',
|
||||
'DiffusionRepositoryController' => 'DiffusionController',
|
||||
'DiffusionSVNContainsQuery' => 'DiffusionContainsQuery',
|
||||
'DiffusionSvnBrowseQuery' => 'DiffusionBrowseQuery',
|
||||
'DiffusionSvnDiffQuery' => 'DiffusionDiffQuery',
|
||||
'DiffusionSvnFileContentQuery' => 'DiffusionFileContentQuery',
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -167,12 +167,12 @@ abstract class DiffusionController extends PhabricatorController {
|
|||
$callsign = $repository->getCallsign();
|
||||
$repository_name = phutil_escape_html($repository->getName()).' Repository';
|
||||
|
||||
if (empty($spec['commit'])) {
|
||||
$branch_name = $drequest->getBranch();
|
||||
if ($branch_name) {
|
||||
$repository_name .= ' ('.phutil_escape_html($branch_name).')';
|
||||
}
|
||||
|
||||
$branch_uri = $drequest->getBranchURIComponent($drequest->getBranch());
|
||||
}
|
||||
|
||||
if (empty($spec['view']) && empty($spec['commit'])) {
|
||||
$crumb_list[] = $repository_name;
|
||||
|
@ -220,6 +220,7 @@ abstract class DiffusionController extends PhabricatorController {
|
|||
return $crumb_list;
|
||||
}
|
||||
|
||||
$branch_uri = $drequest->getBranchURIComponent($drequest->getBranch());
|
||||
$view_root_uri = "/diffusion/{$callsign}/{$view}/{$branch_uri}";
|
||||
$jump_href = $view_root_uri;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -263,6 +263,18 @@ class DiffusionCommitController extends DiffusionController {
|
|||
$props['Differential Revision'] = $handles[$revision_phid]->renderLink();
|
||||
}
|
||||
|
||||
$request = $this->getDiffusionRequest();
|
||||
|
||||
$contains = DiffusionContainsQuery::newFromDiffusionRequest($request);
|
||||
$branches = $contains->loadContainingBranches();
|
||||
|
||||
if ($branches) {
|
||||
// TODO: Separate these into 'tracked' and other; link tracked branches.
|
||||
$branches = implode(', ', array_keys($branches));
|
||||
$branches = phutil_escape_html($branches);
|
||||
$props['Branches'] = $branches;
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
foreach ($props as $key => $value) {
|
||||
$rows[] =
|
||||
|
|
|
@ -10,6 +10,7 @@ phutil_require_module('phabricator', 'applications/differential/constants/change
|
|||
phutil_require_module('phabricator', 'applications/differential/view/changesetlistview');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/data/pathchange');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/query/contains/base');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/query/pathchange/base');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/view/commitchangetable');
|
||||
phutil_require_module('phabricator', 'applications/markup/engine');
|
||||
|
|
56
src/applications/diffusion/query/base/DiffusionQuery.php
Normal file
56
src/applications/diffusion/query/base/DiffusionQuery.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
abstract class DiffusionQuery {
|
||||
|
||||
private $request;
|
||||
|
||||
final protected function __construct() {
|
||||
// <protected>
|
||||
}
|
||||
|
||||
protected static function newQueryObject(
|
||||
$base_class,
|
||||
DiffusionRequest $request) {
|
||||
|
||||
$repository = $request->getRepository();
|
||||
|
||||
$map = array(
|
||||
PhabricatorRepositoryType::REPOSITORY_TYPE_GIT => 'Git',
|
||||
PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL => 'Mercurial',
|
||||
PhabricatorRepositoryType::REPOSITORY_TYPE_SVN => 'SVN',
|
||||
);
|
||||
|
||||
$name = idx($map, $repository->getVersionControlSystem());
|
||||
if (!$name) {
|
||||
throw new Exception("Unsupported VCS!");
|
||||
}
|
||||
|
||||
$class = str_replace('Diffusion', 'Diffusion'.$name, $base_class);
|
||||
$obj = new $class();
|
||||
$obj->request = $request;
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
final protected function getRequest() {
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
abstract protected function executeQuery();
|
||||
}
|
14
src/applications/diffusion/query/base/__init__.php
Normal file
14
src/applications/diffusion/query/base/__init__.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/repository/constants/repositorytype');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('DiffusionQuery.php');
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
abstract class DiffusionContainsQuery extends DiffusionQuery {
|
||||
|
||||
final public static function newFromDiffusionRequest(
|
||||
DiffusionRequest $request) {
|
||||
return self::newQueryObject(__CLASS__, $request);
|
||||
}
|
||||
|
||||
final public function loadContainingBranches() {
|
||||
return $this->executeQuery();
|
||||
}
|
||||
|
||||
}
|
12
src/applications/diffusion/query/contains/base/__init__.php
Normal file
12
src/applications/diffusion/query/contains/base/__init__.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/diffusion/query/base');
|
||||
|
||||
|
||||
phutil_require_source('DiffusionContainsQuery.php');
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
final class DiffusionGitContainsQuery extends DiffusionContainsQuery {
|
||||
|
||||
final public function executeQuery() {
|
||||
$request = $this->getRequest();
|
||||
$repository = $request->getRepository();
|
||||
|
||||
list($contains) = $repository->execxLocalCommand(
|
||||
'branch -r --verbose --no-abbrev --contains %s',
|
||||
$request->getCommit());
|
||||
|
||||
return DiffusionGitBranchQuery::parseGitRemoteBranchOutput(
|
||||
$contains,
|
||||
DiffusionBranchInformation::DEFAULT_GIT_REMOTE);
|
||||
}
|
||||
|
||||
}
|
14
src/applications/diffusion/query/contains/git/__init__.php
Normal file
14
src/applications/diffusion/query/contains/git/__init__.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/diffusion/data/branch');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/query/branch/git');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/query/contains/base');
|
||||
|
||||
|
||||
phutil_require_source('DiffusionGitContainsQuery.php');
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
final class DiffusionMercurialContainsQuery extends DiffusionContainsQuery {
|
||||
|
||||
protected function executeQuery() {
|
||||
|
||||
// TODO: Implement this.
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/diffusion/query/contains/base');
|
||||
|
||||
|
||||
phutil_require_source('DiffusionMercurialContainsQuery.php');
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
final class DiffusionSVNContainsQuery extends DiffusionContainsQuery {
|
||||
|
||||
protected function executeQuery() {
|
||||
// NOTE: Subversion doesn't have branches, so we always return empty.
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
12
src/applications/diffusion/query/contains/svn/__init__.php
Normal file
12
src/applications/diffusion/query/contains/svn/__init__.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/diffusion/query/contains/base');
|
||||
|
||||
|
||||
phutil_require_source('DiffusionSVNContainsQuery.php');
|
Loading…
Reference in a new issue