1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-26 08:42:40 +01:00

ArcanistRepositoryAPI: add getCanonicalRevisionName

Summary:
Resolves crazy stuff like 'HEAD' or '{2001-01-01T01:01:01}' into an
actual revision, with a provided implementation for git.

Test Plan: Tested in a hacky script.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1849
This commit is contained in:
Edward Speyer 2012-03-09 14:40:47 -08:00
parent 6a7b1a7bdd
commit 454a7de87e
6 changed files with 21 additions and 18 deletions

View file

@ -157,6 +157,7 @@ abstract class ArcanistRepositoryAPI {
abstract public function getCurrentFileData($path); abstract public function getCurrentFileData($path);
abstract public function getLocalCommitInformation(); abstract public function getLocalCommitInformation();
abstract public function getSourceControlBaseRevision(); abstract public function getSourceControlBaseRevision();
abstract public function getCanonicalRevisionName($string);
abstract public function supportsRelativeLocalCommits(); abstract public function supportsRelativeLocalCommits();
abstract public function getWorkingCopyRevision(); abstract public function getWorkingCopyRevision();
abstract public function loadWorkingCopyDifferentialRevisions( abstract public function loadWorkingCopyDifferentialRevisions(

View file

@ -223,20 +223,10 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
return rtrim($stdout, "\n"); return rtrim($stdout, "\n");
} }
/** public function getCanonicalRevisionName($string) {
* Returns the sha1 of the HEAD revision list($stdout) = $this->execxLocal('show -s --format=%C %s',
* @param boolean $short whether return the abbreviated or full hash. '%H', $string);
*/ return rtrim($stdout);
public function getGitHeadRevision($short=false) {
if ($short) {
$flags = '--short';
} else {
$flags = '';
}
list($stdout) = $this->execxLocal(
'rev-parse %s HEAD',
$flags);
return rtrim($stdout, "\n");
} }
public function getWorkingCopyStatus() { public function getWorkingCopyStatus() {
@ -552,10 +542,12 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
} }
public function hasLocalCommit($commit) { public function hasLocalCommit($commit) {
list($err) = $this->execManualLocal( try {
'merge-base %s HEAD', $this->getCanonicalRevisionName($commit);
$commit); } catch (CommandException $exception) {
return !$err; return false;
}
return true;
} }
public function parseRelativeLocalCommit(array $argv) { public function parseRelativeLocalCommit(array $argv) {

View file

@ -60,6 +60,10 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
return rtrim($stdout, "\n"); return rtrim($stdout, "\n");
} }
public function getCanonicalRevisionName($string) {
throw new ArcanistCapabilityNotSupportedException($this);
}
public function getSourceControlPath() { public function getSourceControlPath() {
return '/'; return '/';
} }

View file

@ -11,6 +11,7 @@ phutil_require_module('arcanist', 'parser/diff');
phutil_require_module('arcanist', 'parser/diff/changetype'); phutil_require_module('arcanist', 'parser/diff/changetype');
phutil_require_module('arcanist', 'repository/api/base'); phutil_require_module('arcanist', 'repository/api/base');
phutil_require_module('arcanist', 'repository/parser/mercurial'); phutil_require_module('arcanist', 'repository/parser/mercurial');
phutil_require_module('arcanist', 'workflow/exception/notsupported');
phutil_require_module('phutil', 'future/exec'); phutil_require_module('phutil', 'future/exec');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');

View file

@ -191,6 +191,10 @@ final class ArcanistSubversionAPI extends ArcanistRepositoryAPI {
return $info['URL'].'@'.$this->getSVNBaseRevisionNumber(); return $info['URL'].'@'.$this->getSVNBaseRevisionNumber();
} }
public function getCanonicalRevisionName($string) {
throw new ArcanistCapabilityNotSupportedException($this);
}
public function getSVNBaseRevisionNumber() { public function getSVNBaseRevisionNumber() {
if ($this->svnBaseRevisionNumber) { if ($this->svnBaseRevisionNumber) {
return $this->svnBaseRevisionNumber; return $this->svnBaseRevisionNumber;

View file

@ -7,6 +7,7 @@
phutil_require_module('arcanist', 'repository/api/base'); phutil_require_module('arcanist', 'repository/api/base');
phutil_require_module('arcanist', 'workflow/exception/notsupported');
phutil_require_module('phutil', 'filesystem'); phutil_require_module('phutil', 'filesystem');
phutil_require_module('phutil', 'filesystem/tempfile'); phutil_require_module('phutil', 'filesystem/tempfile');