mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 06:42:41 +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:
parent
6a7b1a7bdd
commit
454a7de87e
6 changed files with 21 additions and 18 deletions
|
@ -157,6 +157,7 @@ abstract class ArcanistRepositoryAPI {
|
|||
abstract public function getCurrentFileData($path);
|
||||
abstract public function getLocalCommitInformation();
|
||||
abstract public function getSourceControlBaseRevision();
|
||||
abstract public function getCanonicalRevisionName($string);
|
||||
abstract public function supportsRelativeLocalCommits();
|
||||
abstract public function getWorkingCopyRevision();
|
||||
abstract public function loadWorkingCopyDifferentialRevisions(
|
||||
|
|
|
@ -223,20 +223,10 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
|||
return rtrim($stdout, "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sha1 of the HEAD revision
|
||||
* @param boolean $short whether return the abbreviated or full hash.
|
||||
*/
|
||||
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 getCanonicalRevisionName($string) {
|
||||
list($stdout) = $this->execxLocal('show -s --format=%C %s',
|
||||
'%H', $string);
|
||||
return rtrim($stdout);
|
||||
}
|
||||
|
||||
public function getWorkingCopyStatus() {
|
||||
|
@ -552,10 +542,12 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
|
|||
}
|
||||
|
||||
public function hasLocalCommit($commit) {
|
||||
list($err) = $this->execManualLocal(
|
||||
'merge-base %s HEAD',
|
||||
$commit);
|
||||
return !$err;
|
||||
try {
|
||||
$this->getCanonicalRevisionName($commit);
|
||||
} catch (CommandException $exception) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function parseRelativeLocalCommit(array $argv) {
|
||||
|
|
|
@ -60,6 +60,10 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
|
|||
return rtrim($stdout, "\n");
|
||||
}
|
||||
|
||||
public function getCanonicalRevisionName($string) {
|
||||
throw new ArcanistCapabilityNotSupportedException($this);
|
||||
}
|
||||
|
||||
public function getSourceControlPath() {
|
||||
return '/';
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ phutil_require_module('arcanist', 'parser/diff');
|
|||
phutil_require_module('arcanist', 'parser/diff/changetype');
|
||||
phutil_require_module('arcanist', 'repository/api/base');
|
||||
phutil_require_module('arcanist', 'repository/parser/mercurial');
|
||||
phutil_require_module('arcanist', 'workflow/exception/notsupported');
|
||||
|
||||
phutil_require_module('phutil', 'future/exec');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
|
|
@ -191,6 +191,10 @@ final class ArcanistSubversionAPI extends ArcanistRepositoryAPI {
|
|||
return $info['URL'].'@'.$this->getSVNBaseRevisionNumber();
|
||||
}
|
||||
|
||||
public function getCanonicalRevisionName($string) {
|
||||
throw new ArcanistCapabilityNotSupportedException($this);
|
||||
}
|
||||
|
||||
public function getSVNBaseRevisionNumber() {
|
||||
if ($this->svnBaseRevisionNumber) {
|
||||
return $this->svnBaseRevisionNumber;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
|
||||
phutil_require_module('arcanist', 'repository/api/base');
|
||||
phutil_require_module('arcanist', 'workflow/exception/notsupported');
|
||||
|
||||
phutil_require_module('phutil', 'filesystem');
|
||||
phutil_require_module('phutil', 'filesystem/tempfile');
|
||||
|
|
Loading…
Reference in a new issue