| 
									
										
										
										
											2011-03-07 15:13:36 -08:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* | 
					
						
							| 
									
										
										
										
											2012-01-19 11:49:51 -08:00
										 |  |  |  * Copyright 2012 Facebook, Inc. | 
					
						
							| 
									
										
										
										
											2011-03-07 15:13:36 -08:00
										 |  |  |  * | 
					
						
							|  |  |  |  * 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 DiffusionController extends PhabricatorController { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-08 17:31:44 -08:00
										 |  |  |   protected $diffusionRequest; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   public function willProcessRequest(array $data) { | 
					
						
							| 
									
										
											  
											
												Fix many encoding and architecture problems in Diffusion request and URI handling
Summary:
Diffusion request/uri handling is currently a big, hastily ported mess. In particular, it has:
  - Tons and tons of duplicated code.
  - Bugs with handling unusual branch and file names.
  - An excessively large (and yet insufficiently expressive) API on DiffusionRequest, including a nonsensical concrete base class.
  - Other tools were doing hacky things like passing ":" branch names.
This diff attempts to fix these issues.
  - Make the base class abstract (it was concrete ONLY for "/diffusion/").
  - Move all URI generation to DiffusionRequest. Make the core static. Add unit tests.
  - Delete the 300 copies of URI generation code throughout Diffusion.
  - Move all URI parsing to DiffusionRequest. Make the core static. Add unit tests.
  - Add an appropriate static initializer for other callers.
  - Convert all code calling `newFromAphrontRequestDictionary` outside of Diffusion to the new `newFromDictionary` API.
  - Refactor static initializers to be sensibly-sized.
  - Refactor derived DiffusionRequest classes to remove duplicated code.
  - Properly encode branch names (fixes branches with "/", see <https://github.com/facebook/phabricator/issues/100>).
  - Properly encode path names (fixes issues in D1742).
  - Properly escape delimiter characters ";" and "$" in path names so files like "$100" are not interpreted as "line 100".
  - Fix a couple warnings.
  - Fix a couple lint issues.
  - Fix a bug where we would not parse filenames with spaces in them correctly in the Git browse query.
  - Fix a bug where Git change queries would fail unnecessarily.
  - Provide or improve some documentation.
This thing is pretty gigantic but also kind of hard to split up. If it's unreasonably difficult to review, let me know and I can take a stab at it though.
This supplants D1742.
Test Plan:
  - Used home, repository, branch, browse, change, history, diff (ajax), lastmodified (ajax) views of Diffusion.
  - Used Owners typeaheads and search.
  - Used diffusion.getrecentcommitsbypath method.
  - Pushed a change to an absurdly-named file on an absurdly-named branch, everything worked properly.
{F9185}
Reviewers: nh, vrana, btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1921
											
										 
											2012-03-19 19:52:14 -07:00
										 |  |  |     if (isset($data['callsign'])) { | 
					
						
							|  |  |  |       $drequest = DiffusionRequest::newFromAphrontRequestDictionary($data); | 
					
						
							|  |  |  |       $this->diffusionRequest = $drequest; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-03-08 17:31:44 -08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   public function setDiffusionRequest(DiffusionRequest $request) { | 
					
						
							|  |  |  |     $this->diffusionRequest = $request; | 
					
						
							|  |  |  |     return $this; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-12 16:17:34 -08:00
										 |  |  |   protected function getDiffusionRequest() { | 
					
						
							| 
									
										
											  
											
												Fix many encoding and architecture problems in Diffusion request and URI handling
Summary:
Diffusion request/uri handling is currently a big, hastily ported mess. In particular, it has:
  - Tons and tons of duplicated code.
  - Bugs with handling unusual branch and file names.
  - An excessively large (and yet insufficiently expressive) API on DiffusionRequest, including a nonsensical concrete base class.
  - Other tools were doing hacky things like passing ":" branch names.
This diff attempts to fix these issues.
  - Make the base class abstract (it was concrete ONLY for "/diffusion/").
  - Move all URI generation to DiffusionRequest. Make the core static. Add unit tests.
  - Delete the 300 copies of URI generation code throughout Diffusion.
  - Move all URI parsing to DiffusionRequest. Make the core static. Add unit tests.
  - Add an appropriate static initializer for other callers.
  - Convert all code calling `newFromAphrontRequestDictionary` outside of Diffusion to the new `newFromDictionary` API.
  - Refactor static initializers to be sensibly-sized.
  - Refactor derived DiffusionRequest classes to remove duplicated code.
  - Properly encode branch names (fixes branches with "/", see <https://github.com/facebook/phabricator/issues/100>).
  - Properly encode path names (fixes issues in D1742).
  - Properly escape delimiter characters ";" and "$" in path names so files like "$100" are not interpreted as "line 100".
  - Fix a couple warnings.
  - Fix a couple lint issues.
  - Fix a bug where we would not parse filenames with spaces in them correctly in the Git browse query.
  - Fix a bug where Git change queries would fail unnecessarily.
  - Provide or improve some documentation.
This thing is pretty gigantic but also kind of hard to split up. If it's unreasonably difficult to review, let me know and I can take a stab at it though.
This supplants D1742.
Test Plan:
  - Used home, repository, branch, browse, change, history, diff (ajax), lastmodified (ajax) views of Diffusion.
  - Used Owners typeaheads and search.
  - Used diffusion.getrecentcommitsbypath method.
  - Pushed a change to an absurdly-named file on an absurdly-named branch, everything worked properly.
{F9185}
Reviewers: nh, vrana, btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1921
											
										 
											2012-03-19 19:52:14 -07:00
										 |  |  |     if (!$this->diffusionRequest) { | 
					
						
							|  |  |  |       throw new Exception("No Diffusion request object!"); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-03-12 16:17:34 -08:00
										 |  |  |     return $this->diffusionRequest; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-07 15:13:36 -08:00
										 |  |  |   public function buildStandardPageResponse($view, array $data) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $page = $this->buildStandardPageView(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $page->setApplicationName('Diffusion'); | 
					
						
							|  |  |  |     $page->setBaseURI('/diffusion/'); | 
					
						
							|  |  |  |     $page->setTitle(idx($data, 'title')); | 
					
						
							|  |  |  |     $page->setGlyph("\xE2\x89\x88"); | 
					
						
							| 
									
										
										
										
											2011-05-19 13:40:12 -07:00
										 |  |  |     $page->setTabs( | 
					
						
							|  |  |  |       array( | 
					
						
							|  |  |  |         'help' => array( | 
					
						
							|  |  |  |           'href' => PhabricatorEnv::getDoclink( | 
					
						
							|  |  |  |             'article/Diffusion_User_Guide.html'), | 
					
						
							|  |  |  |           'name' => 'Help', | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |       null); | 
					
						
							| 
									
										
										
										
											2012-02-14 17:00:12 -08:00
										 |  |  |     $page->setSearchDefaultScope(PhabricatorSearchScope::SCOPE_COMMITS); | 
					
						
							| 
									
										
										
										
											2011-05-19 13:40:12 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-07 15:13:36 -08:00
										 |  |  |     $page->appendChild($view); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $response = new AphrontWebpageResponse(); | 
					
						
							|  |  |  |     return $response->setContent($page->render()); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-12 16:17:34 -08:00
										 |  |  |   final protected function buildSideNav($selected, $has_change_view) { | 
					
						
							|  |  |  |     $nav = new AphrontSideNavView(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $navs = array( | 
					
						
							|  |  |  |       'history' => 'History View', | 
					
						
							|  |  |  |       'browse'  => 'Browse View', | 
					
						
							|  |  |  |       'change'  => 'Change View', | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (!$has_change_view) { | 
					
						
							|  |  |  |       unset($navs['change']); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $drequest = $this->getDiffusionRequest(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Fix many encoding and architecture problems in Diffusion request and URI handling
Summary:
Diffusion request/uri handling is currently a big, hastily ported mess. In particular, it has:
  - Tons and tons of duplicated code.
  - Bugs with handling unusual branch and file names.
  - An excessively large (and yet insufficiently expressive) API on DiffusionRequest, including a nonsensical concrete base class.
  - Other tools were doing hacky things like passing ":" branch names.
This diff attempts to fix these issues.
  - Make the base class abstract (it was concrete ONLY for "/diffusion/").
  - Move all URI generation to DiffusionRequest. Make the core static. Add unit tests.
  - Delete the 300 copies of URI generation code throughout Diffusion.
  - Move all URI parsing to DiffusionRequest. Make the core static. Add unit tests.
  - Add an appropriate static initializer for other callers.
  - Convert all code calling `newFromAphrontRequestDictionary` outside of Diffusion to the new `newFromDictionary` API.
  - Refactor static initializers to be sensibly-sized.
  - Refactor derived DiffusionRequest classes to remove duplicated code.
  - Properly encode branch names (fixes branches with "/", see <https://github.com/facebook/phabricator/issues/100>).
  - Properly encode path names (fixes issues in D1742).
  - Properly escape delimiter characters ";" and "$" in path names so files like "$100" are not interpreted as "line 100".
  - Fix a couple warnings.
  - Fix a couple lint issues.
  - Fix a bug where we would not parse filenames with spaces in them correctly in the Git browse query.
  - Fix a bug where Git change queries would fail unnecessarily.
  - Provide or improve some documentation.
This thing is pretty gigantic but also kind of hard to split up. If it's unreasonably difficult to review, let me know and I can take a stab at it though.
This supplants D1742.
Test Plan:
  - Used home, repository, branch, browse, change, history, diff (ajax), lastmodified (ajax) views of Diffusion.
  - Used Owners typeaheads and search.
  - Used diffusion.getrecentcommitsbypath method.
  - Pushed a change to an absurdly-named file on an absurdly-named branch, everything worked properly.
{F9185}
Reviewers: nh, vrana, btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1921
											
										 
											2012-03-19 19:52:14 -07:00
										 |  |  |     foreach ($navs as $action => $name) { | 
					
						
							|  |  |  |       $href = $drequest->generateURI( | 
					
						
							|  |  |  |         array( | 
					
						
							|  |  |  |           'action' => $action, | 
					
						
							|  |  |  |         )); | 
					
						
							| 
									
										
										
										
											2011-03-12 16:17:34 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |       $nav->addNavItem( | 
					
						
							|  |  |  |         phutil_render_tag( | 
					
						
							|  |  |  |           'a', | 
					
						
							|  |  |  |           array( | 
					
						
							| 
									
										
											  
											
												Fix many encoding and architecture problems in Diffusion request and URI handling
Summary:
Diffusion request/uri handling is currently a big, hastily ported mess. In particular, it has:
  - Tons and tons of duplicated code.
  - Bugs with handling unusual branch and file names.
  - An excessively large (and yet insufficiently expressive) API on DiffusionRequest, including a nonsensical concrete base class.
  - Other tools were doing hacky things like passing ":" branch names.
This diff attempts to fix these issues.
  - Make the base class abstract (it was concrete ONLY for "/diffusion/").
  - Move all URI generation to DiffusionRequest. Make the core static. Add unit tests.
  - Delete the 300 copies of URI generation code throughout Diffusion.
  - Move all URI parsing to DiffusionRequest. Make the core static. Add unit tests.
  - Add an appropriate static initializer for other callers.
  - Convert all code calling `newFromAphrontRequestDictionary` outside of Diffusion to the new `newFromDictionary` API.
  - Refactor static initializers to be sensibly-sized.
  - Refactor derived DiffusionRequest classes to remove duplicated code.
  - Properly encode branch names (fixes branches with "/", see <https://github.com/facebook/phabricator/issues/100>).
  - Properly encode path names (fixes issues in D1742).
  - Properly escape delimiter characters ";" and "$" in path names so files like "$100" are not interpreted as "line 100".
  - Fix a couple warnings.
  - Fix a couple lint issues.
  - Fix a bug where we would not parse filenames with spaces in them correctly in the Git browse query.
  - Fix a bug where Git change queries would fail unnecessarily.
  - Provide or improve some documentation.
This thing is pretty gigantic but also kind of hard to split up. If it's unreasonably difficult to review, let me know and I can take a stab at it though.
This supplants D1742.
Test Plan:
  - Used home, repository, branch, browse, change, history, diff (ajax), lastmodified (ajax) views of Diffusion.
  - Used Owners typeaheads and search.
  - Used diffusion.getrecentcommitsbypath method.
  - Pushed a change to an absurdly-named file on an absurdly-named branch, everything worked properly.
{F9185}
Reviewers: nh, vrana, btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1921
											
										 
											2012-03-19 19:52:14 -07:00
										 |  |  |             'href'  => $href, | 
					
						
							| 
									
										
										
										
											2011-03-12 16:17:34 -08:00
										 |  |  |             'class' => | 
					
						
							| 
									
										
											  
											
												Fix many encoding and architecture problems in Diffusion request and URI handling
Summary:
Diffusion request/uri handling is currently a big, hastily ported mess. In particular, it has:
  - Tons and tons of duplicated code.
  - Bugs with handling unusual branch and file names.
  - An excessively large (and yet insufficiently expressive) API on DiffusionRequest, including a nonsensical concrete base class.
  - Other tools were doing hacky things like passing ":" branch names.
This diff attempts to fix these issues.
  - Make the base class abstract (it was concrete ONLY for "/diffusion/").
  - Move all URI generation to DiffusionRequest. Make the core static. Add unit tests.
  - Delete the 300 copies of URI generation code throughout Diffusion.
  - Move all URI parsing to DiffusionRequest. Make the core static. Add unit tests.
  - Add an appropriate static initializer for other callers.
  - Convert all code calling `newFromAphrontRequestDictionary` outside of Diffusion to the new `newFromDictionary` API.
  - Refactor static initializers to be sensibly-sized.
  - Refactor derived DiffusionRequest classes to remove duplicated code.
  - Properly encode branch names (fixes branches with "/", see <https://github.com/facebook/phabricator/issues/100>).
  - Properly encode path names (fixes issues in D1742).
  - Properly escape delimiter characters ";" and "$" in path names so files like "$100" are not interpreted as "line 100".
  - Fix a couple warnings.
  - Fix a couple lint issues.
  - Fix a bug where we would not parse filenames with spaces in them correctly in the Git browse query.
  - Fix a bug where Git change queries would fail unnecessarily.
  - Provide or improve some documentation.
This thing is pretty gigantic but also kind of hard to split up. If it's unreasonably difficult to review, let me know and I can take a stab at it though.
This supplants D1742.
Test Plan:
  - Used home, repository, branch, browse, change, history, diff (ajax), lastmodified (ajax) views of Diffusion.
  - Used Owners typeaheads and search.
  - Used diffusion.getrecentcommitsbypath method.
  - Pushed a change to an absurdly-named file on an absurdly-named branch, everything worked properly.
{F9185}
Reviewers: nh, vrana, btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1921
											
										 
											2012-03-19 19:52:14 -07:00
										 |  |  |               ($action == $selected | 
					
						
							| 
									
										
										
										
											2011-03-12 16:17:34 -08:00
										 |  |  |                 ? 'aphront-side-nav-selected' | 
					
						
							|  |  |  |                 : null), | 
					
						
							|  |  |  |           ), | 
					
						
							|  |  |  |           $name)); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
											  
											
												Fix many encoding and architecture problems in Diffusion request and URI handling
Summary:
Diffusion request/uri handling is currently a big, hastily ported mess. In particular, it has:
  - Tons and tons of duplicated code.
  - Bugs with handling unusual branch and file names.
  - An excessively large (and yet insufficiently expressive) API on DiffusionRequest, including a nonsensical concrete base class.
  - Other tools were doing hacky things like passing ":" branch names.
This diff attempts to fix these issues.
  - Make the base class abstract (it was concrete ONLY for "/diffusion/").
  - Move all URI generation to DiffusionRequest. Make the core static. Add unit tests.
  - Delete the 300 copies of URI generation code throughout Diffusion.
  - Move all URI parsing to DiffusionRequest. Make the core static. Add unit tests.
  - Add an appropriate static initializer for other callers.
  - Convert all code calling `newFromAphrontRequestDictionary` outside of Diffusion to the new `newFromDictionary` API.
  - Refactor static initializers to be sensibly-sized.
  - Refactor derived DiffusionRequest classes to remove duplicated code.
  - Properly encode branch names (fixes branches with "/", see <https://github.com/facebook/phabricator/issues/100>).
  - Properly encode path names (fixes issues in D1742).
  - Properly escape delimiter characters ";" and "$" in path names so files like "$100" are not interpreted as "line 100".
  - Fix a couple warnings.
  - Fix a couple lint issues.
  - Fix a bug where we would not parse filenames with spaces in them correctly in the Git browse query.
  - Fix a bug where Git change queries would fail unnecessarily.
  - Provide or improve some documentation.
This thing is pretty gigantic but also kind of hard to split up. If it's unreasonably difficult to review, let me know and I can take a stab at it though.
This supplants D1742.
Test Plan:
  - Used home, repository, branch, browse, change, history, diff (ajax), lastmodified (ajax) views of Diffusion.
  - Used Owners typeaheads and search.
  - Used diffusion.getrecentcommitsbypath method.
  - Pushed a change to an absurdly-named file on an absurdly-named branch, everything worked properly.
{F9185}
Reviewers: nh, vrana, btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1921
											
										 
											2012-03-19 19:52:14 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // TODO: URI encoding might need to be sorted out for this link.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-03 23:45:38 -08:00
										 |  |  |     $nav->addNavItem( | 
					
						
							|  |  |  |       phutil_render_tag( | 
					
						
							|  |  |  |         'a', | 
					
						
							|  |  |  |         array( | 
					
						
							|  |  |  |           'href'  => '/owners/view/search/'. | 
					
						
							| 
									
										
											  
											
												Fix many encoding and architecture problems in Diffusion request and URI handling
Summary:
Diffusion request/uri handling is currently a big, hastily ported mess. In particular, it has:
  - Tons and tons of duplicated code.
  - Bugs with handling unusual branch and file names.
  - An excessively large (and yet insufficiently expressive) API on DiffusionRequest, including a nonsensical concrete base class.
  - Other tools were doing hacky things like passing ":" branch names.
This diff attempts to fix these issues.
  - Make the base class abstract (it was concrete ONLY for "/diffusion/").
  - Move all URI generation to DiffusionRequest. Make the core static. Add unit tests.
  - Delete the 300 copies of URI generation code throughout Diffusion.
  - Move all URI parsing to DiffusionRequest. Make the core static. Add unit tests.
  - Add an appropriate static initializer for other callers.
  - Convert all code calling `newFromAphrontRequestDictionary` outside of Diffusion to the new `newFromDictionary` API.
  - Refactor static initializers to be sensibly-sized.
  - Refactor derived DiffusionRequest classes to remove duplicated code.
  - Properly encode branch names (fixes branches with "/", see <https://github.com/facebook/phabricator/issues/100>).
  - Properly encode path names (fixes issues in D1742).
  - Properly escape delimiter characters ";" and "$" in path names so files like "$100" are not interpreted as "line 100".
  - Fix a couple warnings.
  - Fix a couple lint issues.
  - Fix a bug where we would not parse filenames with spaces in them correctly in the Git browse query.
  - Fix a bug where Git change queries would fail unnecessarily.
  - Provide or improve some documentation.
This thing is pretty gigantic but also kind of hard to split up. If it's unreasonably difficult to review, let me know and I can take a stab at it though.
This supplants D1742.
Test Plan:
  - Used home, repository, branch, browse, change, history, diff (ajax), lastmodified (ajax) views of Diffusion.
  - Used Owners typeaheads and search.
  - Used diffusion.getrecentcommitsbypath method.
  - Pushed a change to an absurdly-named file on an absurdly-named branch, everything worked properly.
{F9185}
Reviewers: nh, vrana, btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1921
											
										 
											2012-03-19 19:52:14 -07:00
										 |  |  |             '?repository='.phutil_escape_uri($drequest->getCallsign()). | 
					
						
							| 
									
										
										
										
											2012-02-03 23:45:38 -08:00
										 |  |  |             '&path='.phutil_escape_uri('/'.$drequest->getPath()), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         'Search Owners')); | 
					
						
							| 
									
										
										
										
											2011-03-12 16:17:34 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return $nav; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   public function buildCrumbs(array $spec = array()) { | 
					
						
							|  |  |  |     $crumbs = new AphrontCrumbsView(); | 
					
						
							| 
									
										
										
										
											2011-03-30 22:08:41 -07:00
										 |  |  |     $crumb_list = $this->buildCrumbList($spec); | 
					
						
							|  |  |  |     $crumbs->setCrumbs($crumb_list); | 
					
						
							|  |  |  |     return $crumbs; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-02 12:52:54 -07:00
										 |  |  |   protected function buildOpenRevisions() { | 
					
						
							|  |  |  |     $drequest = $this->getDiffusionRequest(); | 
					
						
							|  |  |  |     $repository = $drequest->getRepository(); | 
					
						
							|  |  |  |     $path = $drequest->getPath(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $path_map = id(new DiffusionPathIDQuery(array($path)))->loadPathIDs(); | 
					
						
							|  |  |  |     $path_id = idx($path_map, $path); | 
					
						
							|  |  |  |     if (!$path_id) { | 
					
						
							|  |  |  |       return null; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $revisions = id(new DifferentialRevisionQuery()) | 
					
						
							|  |  |  |       ->withPath($repository->getID(), $path_id) | 
					
						
							|  |  |  |       ->withStatus(DifferentialRevisionQuery::STATUS_OPEN) | 
					
						
							|  |  |  |       ->setOrder(DifferentialRevisionQuery::ORDER_PATH_MODIFIED) | 
					
						
							|  |  |  |       ->setLimit(10) | 
					
						
							|  |  |  |       ->needRelationships(true) | 
					
						
							|  |  |  |       ->execute(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (!$revisions) { | 
					
						
							|  |  |  |       return null; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $view = id(new DifferentialRevisionListView()) | 
					
						
							|  |  |  |       ->setRevisions($revisions) | 
					
						
							| 
									
										
										
										
											2012-02-21 22:15:13 -08:00
										 |  |  |       ->setFields(DifferentialRevisionListView::getDefaultFields()) | 
					
						
							| 
									
										
										
										
											2011-10-02 12:52:54 -07:00
										 |  |  |       ->setUser($this->getRequest()->getUser()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $phids = $view->getRequiredHandlePHIDs(); | 
					
						
							|  |  |  |     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); | 
					
						
							|  |  |  |     $view->setHandles($handles); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $panel = new AphrontPanelView(); | 
					
						
							|  |  |  |     $panel->setHeader('Pending Differential Revisions'); | 
					
						
							|  |  |  |     $panel->appendChild($view); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return $panel; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-30 22:08:41 -07:00
										 |  |  |   private function buildCrumbList(array $spec = array()) { | 
					
						
							| 
									
										
										
										
											2011-03-12 16:17:34 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     $crumb_list = array(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Fix many encoding and architecture problems in Diffusion request and URI handling
Summary:
Diffusion request/uri handling is currently a big, hastily ported mess. In particular, it has:
  - Tons and tons of duplicated code.
  - Bugs with handling unusual branch and file names.
  - An excessively large (and yet insufficiently expressive) API on DiffusionRequest, including a nonsensical concrete base class.
  - Other tools were doing hacky things like passing ":" branch names.
This diff attempts to fix these issues.
  - Make the base class abstract (it was concrete ONLY for "/diffusion/").
  - Move all URI generation to DiffusionRequest. Make the core static. Add unit tests.
  - Delete the 300 copies of URI generation code throughout Diffusion.
  - Move all URI parsing to DiffusionRequest. Make the core static. Add unit tests.
  - Add an appropriate static initializer for other callers.
  - Convert all code calling `newFromAphrontRequestDictionary` outside of Diffusion to the new `newFromDictionary` API.
  - Refactor static initializers to be sensibly-sized.
  - Refactor derived DiffusionRequest classes to remove duplicated code.
  - Properly encode branch names (fixes branches with "/", see <https://github.com/facebook/phabricator/issues/100>).
  - Properly encode path names (fixes issues in D1742).
  - Properly escape delimiter characters ";" and "$" in path names so files like "$100" are not interpreted as "line 100".
  - Fix a couple warnings.
  - Fix a couple lint issues.
  - Fix a bug where we would not parse filenames with spaces in them correctly in the Git browse query.
  - Fix a bug where Git change queries would fail unnecessarily.
  - Provide or improve some documentation.
This thing is pretty gigantic but also kind of hard to split up. If it's unreasonably difficult to review, let me know and I can take a stab at it though.
This supplants D1742.
Test Plan:
  - Used home, repository, branch, browse, change, history, diff (ajax), lastmodified (ajax) views of Diffusion.
  - Used Owners typeaheads and search.
  - Used diffusion.getrecentcommitsbypath method.
  - Pushed a change to an absurdly-named file on an absurdly-named branch, everything worked properly.
{F9185}
Reviewers: nh, vrana, btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1921
											
										 
											2012-03-19 19:52:14 -07:00
										 |  |  |     // On the home page, we don't have a DiffusionRequest.
 | 
					
						
							|  |  |  |     if ($this->diffusionRequest) { | 
					
						
							|  |  |  |       $drequest = $this->getDiffusionRequest(); | 
					
						
							|  |  |  |       $repository = $drequest->getRepository(); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       $drequest = null; | 
					
						
							|  |  |  |       $repository = null; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-12 16:17:34 -08:00
										 |  |  |     if ($repository) { | 
					
						
							|  |  |  |       $crumb_list[] = phutil_render_tag( | 
					
						
							|  |  |  |         'a', | 
					
						
							|  |  |  |         array( | 
					
						
							|  |  |  |           'href' => '/diffusion/', | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         'Diffusion'); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       $crumb_list[] = 'Diffusion'; | 
					
						
							| 
									
										
										
										
											2011-03-30 22:08:41 -07:00
										 |  |  |       return $crumb_list; | 
					
						
							| 
									
										
										
										
											2011-03-12 16:17:34 -08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $callsign = $repository->getCallsign(); | 
					
						
							|  |  |  |     $repository_name = phutil_escape_html($repository->getName()).' Repository'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-19 11:49:51 -08:00
										 |  |  |     if (empty($spec['commit'])) { | 
					
						
							|  |  |  |       $branch_name = $drequest->getBranch(); | 
					
						
							|  |  |  |       if ($branch_name) { | 
					
						
							|  |  |  |         $repository_name .= ' ('.phutil_escape_html($branch_name).')'; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2011-03-12 16:17:34 -08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-13 16:19:39 -07:00
										 |  |  |     if (empty($spec['view']) && empty($spec['commit'])) { | 
					
						
							| 
									
										
										
										
											2011-03-12 16:17:34 -08:00
										 |  |  |       $crumb_list[] = $repository_name; | 
					
						
							| 
									
										
										
										
											2011-03-30 22:08:41 -07:00
										 |  |  |       return $crumb_list; | 
					
						
							| 
									
										
										
										
											2011-03-12 16:17:34 -08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $crumb_list[] = phutil_render_tag( | 
					
						
							|  |  |  |       'a', | 
					
						
							|  |  |  |       array( | 
					
						
							|  |  |  |         'href' => "/diffusion/{$callsign}/", | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |       $repository_name); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-13 16:19:39 -07:00
										 |  |  |     $raw_commit = $drequest->getRawCommit(); | 
					
						
							|  |  |  |     if (isset($spec['commit'])) { | 
					
						
							|  |  |  |       $crumb_list[] = "r{$callsign}{$raw_commit}"; | 
					
						
							| 
									
										
										
										
											2011-03-30 22:08:41 -07:00
										 |  |  |       return $crumb_list; | 
					
						
							| 
									
										
										
										
											2011-03-12 16:17:34 -08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $view = $spec['view']; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-30 17:36:16 -07:00
										 |  |  |     $path = null; | 
					
						
							|  |  |  |     if (isset($spec['path'])) { | 
					
						
							|  |  |  |       $path = $drequest->getPath(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ($raw_commit) { | 
					
						
							|  |  |  |       $commit_link = DiffusionView::linkCommit( | 
					
						
							|  |  |  |         $repository, | 
					
						
							|  |  |  |         $raw_commit); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       $commit_link = ''; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-12 16:17:34 -08:00
										 |  |  |     switch ($view) { | 
					
						
							|  |  |  |       case 'history': | 
					
						
							|  |  |  |         $view_name = 'History'; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |       case 'browse': | 
					
						
							|  |  |  |         $view_name = 'Browse'; | 
					
						
							|  |  |  |         break; | 
					
						
							| 
									
										
										
										
											2011-03-13 22:03:30 -07:00
										 |  |  |       case 'change': | 
					
						
							| 
									
										
										
										
											2011-03-30 17:36:16 -07:00
										 |  |  |         $view_name = 'Change'; | 
					
						
							|  |  |  |         $crumb_list[] = phutil_escape_html($path).' ('.$commit_link.')'; | 
					
						
							| 
									
										
										
										
											2011-03-30 22:08:41 -07:00
										 |  |  |         return $crumb_list; | 
					
						
							| 
									
										
										
										
											2011-03-12 16:17:34 -08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Fix many encoding and architecture problems in Diffusion request and URI handling
Summary:
Diffusion request/uri handling is currently a big, hastily ported mess. In particular, it has:
  - Tons and tons of duplicated code.
  - Bugs with handling unusual branch and file names.
  - An excessively large (and yet insufficiently expressive) API on DiffusionRequest, including a nonsensical concrete base class.
  - Other tools were doing hacky things like passing ":" branch names.
This diff attempts to fix these issues.
  - Make the base class abstract (it was concrete ONLY for "/diffusion/").
  - Move all URI generation to DiffusionRequest. Make the core static. Add unit tests.
  - Delete the 300 copies of URI generation code throughout Diffusion.
  - Move all URI parsing to DiffusionRequest. Make the core static. Add unit tests.
  - Add an appropriate static initializer for other callers.
  - Convert all code calling `newFromAphrontRequestDictionary` outside of Diffusion to the new `newFromDictionary` API.
  - Refactor static initializers to be sensibly-sized.
  - Refactor derived DiffusionRequest classes to remove duplicated code.
  - Properly encode branch names (fixes branches with "/", see <https://github.com/facebook/phabricator/issues/100>).
  - Properly encode path names (fixes issues in D1742).
  - Properly escape delimiter characters ";" and "$" in path names so files like "$100" are not interpreted as "line 100".
  - Fix a couple warnings.
  - Fix a couple lint issues.
  - Fix a bug where we would not parse filenames with spaces in them correctly in the Git browse query.
  - Fix a bug where Git change queries would fail unnecessarily.
  - Provide or improve some documentation.
This thing is pretty gigantic but also kind of hard to split up. If it's unreasonably difficult to review, let me know and I can take a stab at it though.
This supplants D1742.
Test Plan:
  - Used home, repository, branch, browse, change, history, diff (ajax), lastmodified (ajax) views of Diffusion.
  - Used Owners typeaheads and search.
  - Used diffusion.getrecentcommitsbypath method.
  - Pushed a change to an absurdly-named file on an absurdly-named branch, everything worked properly.
{F9185}
Reviewers: nh, vrana, btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1921
											
										 
											2012-03-19 19:52:14 -07:00
										 |  |  |     $uri_params = array( | 
					
						
							|  |  |  |       'action' => $view, | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2011-03-12 16:17:34 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (!strlen($path)) { | 
					
						
							|  |  |  |       $crumb_list[] = $view_name; | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       $crumb_list[] = phutil_render_tag( | 
					
						
							|  |  |  |         'a', | 
					
						
							|  |  |  |         array( | 
					
						
							| 
									
										
											  
											
												Fix many encoding and architecture problems in Diffusion request and URI handling
Summary:
Diffusion request/uri handling is currently a big, hastily ported mess. In particular, it has:
  - Tons and tons of duplicated code.
  - Bugs with handling unusual branch and file names.
  - An excessively large (and yet insufficiently expressive) API on DiffusionRequest, including a nonsensical concrete base class.
  - Other tools were doing hacky things like passing ":" branch names.
This diff attempts to fix these issues.
  - Make the base class abstract (it was concrete ONLY for "/diffusion/").
  - Move all URI generation to DiffusionRequest. Make the core static. Add unit tests.
  - Delete the 300 copies of URI generation code throughout Diffusion.
  - Move all URI parsing to DiffusionRequest. Make the core static. Add unit tests.
  - Add an appropriate static initializer for other callers.
  - Convert all code calling `newFromAphrontRequestDictionary` outside of Diffusion to the new `newFromDictionary` API.
  - Refactor static initializers to be sensibly-sized.
  - Refactor derived DiffusionRequest classes to remove duplicated code.
  - Properly encode branch names (fixes branches with "/", see <https://github.com/facebook/phabricator/issues/100>).
  - Properly encode path names (fixes issues in D1742).
  - Properly escape delimiter characters ";" and "$" in path names so files like "$100" are not interpreted as "line 100".
  - Fix a couple warnings.
  - Fix a couple lint issues.
  - Fix a bug where we would not parse filenames with spaces in them correctly in the Git browse query.
  - Fix a bug where Git change queries would fail unnecessarily.
  - Provide or improve some documentation.
This thing is pretty gigantic but also kind of hard to split up. If it's unreasonably difficult to review, let me know and I can take a stab at it though.
This supplants D1742.
Test Plan:
  - Used home, repository, branch, browse, change, history, diff (ajax), lastmodified (ajax) views of Diffusion.
  - Used Owners typeaheads and search.
  - Used diffusion.getrecentcommitsbypath method.
  - Pushed a change to an absurdly-named file on an absurdly-named branch, everything worked properly.
{F9185}
Reviewers: nh, vrana, btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1921
											
										 
											2012-03-19 19:52:14 -07:00
										 |  |  |           'href' => $drequest->generateURI( | 
					
						
							|  |  |  |             array( | 
					
						
							| 
									
										
										
										
											2012-03-26 12:21:39 -07:00
										 |  |  |               'path' => '', | 
					
						
							| 
									
										
											  
											
												Fix many encoding and architecture problems in Diffusion request and URI handling
Summary:
Diffusion request/uri handling is currently a big, hastily ported mess. In particular, it has:
  - Tons and tons of duplicated code.
  - Bugs with handling unusual branch and file names.
  - An excessively large (and yet insufficiently expressive) API on DiffusionRequest, including a nonsensical concrete base class.
  - Other tools were doing hacky things like passing ":" branch names.
This diff attempts to fix these issues.
  - Make the base class abstract (it was concrete ONLY for "/diffusion/").
  - Move all URI generation to DiffusionRequest. Make the core static. Add unit tests.
  - Delete the 300 copies of URI generation code throughout Diffusion.
  - Move all URI parsing to DiffusionRequest. Make the core static. Add unit tests.
  - Add an appropriate static initializer for other callers.
  - Convert all code calling `newFromAphrontRequestDictionary` outside of Diffusion to the new `newFromDictionary` API.
  - Refactor static initializers to be sensibly-sized.
  - Refactor derived DiffusionRequest classes to remove duplicated code.
  - Properly encode branch names (fixes branches with "/", see <https://github.com/facebook/phabricator/issues/100>).
  - Properly encode path names (fixes issues in D1742).
  - Properly escape delimiter characters ";" and "$" in path names so files like "$100" are not interpreted as "line 100".
  - Fix a couple warnings.
  - Fix a couple lint issues.
  - Fix a bug where we would not parse filenames with spaces in them correctly in the Git browse query.
  - Fix a bug where Git change queries would fail unnecessarily.
  - Provide or improve some documentation.
This thing is pretty gigantic but also kind of hard to split up. If it's unreasonably difficult to review, let me know and I can take a stab at it though.
This supplants D1742.
Test Plan:
  - Used home, repository, branch, browse, change, history, diff (ajax), lastmodified (ajax) views of Diffusion.
  - Used Owners typeaheads and search.
  - Used diffusion.getrecentcommitsbypath method.
  - Pushed a change to an absurdly-named file on an absurdly-named branch, everything worked properly.
{F9185}
Reviewers: nh, vrana, btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1921
											
										 
											2012-03-19 19:52:14 -07:00
										 |  |  |             ) + $uri_params), | 
					
						
							| 
									
										
										
										
											2011-03-12 16:17:34 -08:00
										 |  |  |         ), | 
					
						
							|  |  |  |         $view_name); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       $path_parts = explode('/', $path); | 
					
						
							|  |  |  |       do { | 
					
						
							|  |  |  |         $last = array_pop($path_parts); | 
					
						
							|  |  |  |       } while ($last == ''); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       $path_sections = array(); | 
					
						
							|  |  |  |       $thus_far = ''; | 
					
						
							|  |  |  |       foreach ($path_parts as $path_part) { | 
					
						
							|  |  |  |         $thus_far .= $path_part.'/'; | 
					
						
							|  |  |  |         $path_sections[] = phutil_render_tag( | 
					
						
							|  |  |  |           'a', | 
					
						
							|  |  |  |           array( | 
					
						
							| 
									
										
											  
											
												Fix many encoding and architecture problems in Diffusion request and URI handling
Summary:
Diffusion request/uri handling is currently a big, hastily ported mess. In particular, it has:
  - Tons and tons of duplicated code.
  - Bugs with handling unusual branch and file names.
  - An excessively large (and yet insufficiently expressive) API on DiffusionRequest, including a nonsensical concrete base class.
  - Other tools were doing hacky things like passing ":" branch names.
This diff attempts to fix these issues.
  - Make the base class abstract (it was concrete ONLY for "/diffusion/").
  - Move all URI generation to DiffusionRequest. Make the core static. Add unit tests.
  - Delete the 300 copies of URI generation code throughout Diffusion.
  - Move all URI parsing to DiffusionRequest. Make the core static. Add unit tests.
  - Add an appropriate static initializer for other callers.
  - Convert all code calling `newFromAphrontRequestDictionary` outside of Diffusion to the new `newFromDictionary` API.
  - Refactor static initializers to be sensibly-sized.
  - Refactor derived DiffusionRequest classes to remove duplicated code.
  - Properly encode branch names (fixes branches with "/", see <https://github.com/facebook/phabricator/issues/100>).
  - Properly encode path names (fixes issues in D1742).
  - Properly escape delimiter characters ";" and "$" in path names so files like "$100" are not interpreted as "line 100".
  - Fix a couple warnings.
  - Fix a couple lint issues.
  - Fix a bug where we would not parse filenames with spaces in them correctly in the Git browse query.
  - Fix a bug where Git change queries would fail unnecessarily.
  - Provide or improve some documentation.
This thing is pretty gigantic but also kind of hard to split up. If it's unreasonably difficult to review, let me know and I can take a stab at it though.
This supplants D1742.
Test Plan:
  - Used home, repository, branch, browse, change, history, diff (ajax), lastmodified (ajax) views of Diffusion.
  - Used Owners typeaheads and search.
  - Used diffusion.getrecentcommitsbypath method.
  - Pushed a change to an absurdly-named file on an absurdly-named branch, everything worked properly.
{F9185}
Reviewers: nh, vrana, btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1921
											
										 
											2012-03-19 19:52:14 -07:00
										 |  |  |             'href' => $drequest->generateURI( | 
					
						
							|  |  |  |               array( | 
					
						
							|  |  |  |                 'path' => $thus_far, | 
					
						
							|  |  |  |               ) + $uri_params), | 
					
						
							| 
									
										
										
										
											2011-03-12 16:17:34 -08:00
										 |  |  |           ), | 
					
						
							|  |  |  |           phutil_escape_html($path_part)); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       $path_sections[] = phutil_escape_html($last); | 
					
						
							|  |  |  |       $path_sections = '/'.implode('/', $path_sections); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       $crumb_list[] = $path_sections; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $last_crumb = array_pop($crumb_list); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ($raw_commit) { | 
					
						
							|  |  |  |       $jump_link = phutil_render_tag( | 
					
						
							|  |  |  |         'a', | 
					
						
							|  |  |  |         array( | 
					
						
							| 
									
										
											  
											
												Fix many encoding and architecture problems in Diffusion request and URI handling
Summary:
Diffusion request/uri handling is currently a big, hastily ported mess. In particular, it has:
  - Tons and tons of duplicated code.
  - Bugs with handling unusual branch and file names.
  - An excessively large (and yet insufficiently expressive) API on DiffusionRequest, including a nonsensical concrete base class.
  - Other tools were doing hacky things like passing ":" branch names.
This diff attempts to fix these issues.
  - Make the base class abstract (it was concrete ONLY for "/diffusion/").
  - Move all URI generation to DiffusionRequest. Make the core static. Add unit tests.
  - Delete the 300 copies of URI generation code throughout Diffusion.
  - Move all URI parsing to DiffusionRequest. Make the core static. Add unit tests.
  - Add an appropriate static initializer for other callers.
  - Convert all code calling `newFromAphrontRequestDictionary` outside of Diffusion to the new `newFromDictionary` API.
  - Refactor static initializers to be sensibly-sized.
  - Refactor derived DiffusionRequest classes to remove duplicated code.
  - Properly encode branch names (fixes branches with "/", see <https://github.com/facebook/phabricator/issues/100>).
  - Properly encode path names (fixes issues in D1742).
  - Properly escape delimiter characters ";" and "$" in path names so files like "$100" are not interpreted as "line 100".
  - Fix a couple warnings.
  - Fix a couple lint issues.
  - Fix a bug where we would not parse filenames with spaces in them correctly in the Git browse query.
  - Fix a bug where Git change queries would fail unnecessarily.
  - Provide or improve some documentation.
This thing is pretty gigantic but also kind of hard to split up. If it's unreasonably difficult to review, let me know and I can take a stab at it though.
This supplants D1742.
Test Plan:
  - Used home, repository, branch, browse, change, history, diff (ajax), lastmodified (ajax) views of Diffusion.
  - Used Owners typeaheads and search.
  - Used diffusion.getrecentcommitsbypath method.
  - Pushed a change to an absurdly-named file on an absurdly-named branch, everything worked properly.
{F9185}
Reviewers: nh, vrana, btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1921
											
										 
											2012-03-19 19:52:14 -07:00
										 |  |  |           'href' => $drequest->generateURI( | 
					
						
							|  |  |  |             array( | 
					
						
							| 
									
										
										
										
											2012-04-03 18:05:14 -07:00
										 |  |  |               'commit' => '', | 
					
						
							| 
									
										
											  
											
												Fix many encoding and architecture problems in Diffusion request and URI handling
Summary:
Diffusion request/uri handling is currently a big, hastily ported mess. In particular, it has:
  - Tons and tons of duplicated code.
  - Bugs with handling unusual branch and file names.
  - An excessively large (and yet insufficiently expressive) API on DiffusionRequest, including a nonsensical concrete base class.
  - Other tools were doing hacky things like passing ":" branch names.
This diff attempts to fix these issues.
  - Make the base class abstract (it was concrete ONLY for "/diffusion/").
  - Move all URI generation to DiffusionRequest. Make the core static. Add unit tests.
  - Delete the 300 copies of URI generation code throughout Diffusion.
  - Move all URI parsing to DiffusionRequest. Make the core static. Add unit tests.
  - Add an appropriate static initializer for other callers.
  - Convert all code calling `newFromAphrontRequestDictionary` outside of Diffusion to the new `newFromDictionary` API.
  - Refactor static initializers to be sensibly-sized.
  - Refactor derived DiffusionRequest classes to remove duplicated code.
  - Properly encode branch names (fixes branches with "/", see <https://github.com/facebook/phabricator/issues/100>).
  - Properly encode path names (fixes issues in D1742).
  - Properly escape delimiter characters ";" and "$" in path names so files like "$100" are not interpreted as "line 100".
  - Fix a couple warnings.
  - Fix a couple lint issues.
  - Fix a bug where we would not parse filenames with spaces in them correctly in the Git browse query.
  - Fix a bug where Git change queries would fail unnecessarily.
  - Provide or improve some documentation.
This thing is pretty gigantic but also kind of hard to split up. If it's unreasonably difficult to review, let me know and I can take a stab at it though.
This supplants D1742.
Test Plan:
  - Used home, repository, branch, browse, change, history, diff (ajax), lastmodified (ajax) views of Diffusion.
  - Used Owners typeaheads and search.
  - Used diffusion.getrecentcommitsbypath method.
  - Pushed a change to an absurdly-named file on an absurdly-named branch, everything worked properly.
{F9185}
Reviewers: nh, vrana, btrahan
Reviewed By: btrahan
CC: aran, epriestley
Differential Revision: https://secure.phabricator.com/D1921
											
										 
											2012-03-19 19:52:14 -07:00
										 |  |  |             ) + $uri_params), | 
					
						
							| 
									
										
										
										
											2011-03-12 16:17:34 -08:00
										 |  |  |         ), | 
					
						
							|  |  |  |         'Jump to HEAD'); | 
					
						
							|  |  |  |       $last_crumb .= " @ {$commit_link} ({$jump_link})"; | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       $last_crumb .= " @ HEAD"; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $crumb_list[] = $last_crumb; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-30 22:08:41 -07:00
										 |  |  |     return $crumb_list; | 
					
						
							| 
									
										
										
										
											2011-03-12 16:17:34 -08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-03-07 15:13:36 -08:00
										 |  |  | } |