mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-12 14:58:33 +01:00
Summary: Ref T2784. This is a lower-level one from drequest so it gets the conditional initialization treatment. Consolidated SVN as well even though SVN is issuing database queries; I felt better about the code de-duplication despite the small performance hit when we could just query the DB directly in the SVN case. Test Plan: browsed around my Phabricator repositories in Mercurial, Git, and SVN flavors. Looked good. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2784 Differential Revision: https://secure.phabricator.com/D5956
45 lines
837 B
PHP
45 lines
837 B
PHP
<?php
|
|
|
|
/**
|
|
* @group diffusion
|
|
*/
|
|
final class DiffusionMercurialRequest extends DiffusionRequest {
|
|
|
|
protected function getSupportsBranches() {
|
|
return true;
|
|
}
|
|
|
|
protected function didInitialize() {
|
|
// Expand abbreviated hashes to full hashes so "/rXnnnn" (i.e., fewer than
|
|
// 40 characters) works correctly.
|
|
if (!$this->commit) {
|
|
return;
|
|
}
|
|
|
|
if (strlen($this->commit) == 40) {
|
|
return;
|
|
}
|
|
|
|
$this->expandCommitName();
|
|
}
|
|
|
|
public function getBranch() {
|
|
if ($this->branch) {
|
|
return $this->branch;
|
|
}
|
|
|
|
if ($this->repository) {
|
|
return $this->repository->getDefaultBranch();
|
|
}
|
|
|
|
throw new Exception("Unable to determine branch!");
|
|
}
|
|
|
|
public function getCommit() {
|
|
if ($this->commit) {
|
|
return $this->commit;
|
|
}
|
|
return $this->getBranch();
|
|
}
|
|
|
|
}
|