2013-12-03 00:45:36 +01:00
|
|
|
<?php
|
|
|
|
|
2013-12-05 20:56:14 +01:00
|
|
|
/**
|
2013-12-17 17:32:33 +01:00
|
|
|
* @task config Configuring the Hook Engine
|
|
|
|
* @task hook Hook Execution
|
|
|
|
* @task git Git Hooks
|
|
|
|
* @task hg Mercurial Hooks
|
|
|
|
* @task svn Subversion Hooks
|
|
|
|
* @task internal Internals
|
2013-12-05 20:56:14 +01:00
|
|
|
*/
|
2013-12-03 00:45:36 +01:00
|
|
|
final class DiffusionCommitHookEngine extends Phobject {
|
|
|
|
|
2013-12-05 20:59:22 +01:00
|
|
|
const ENV_USER = 'PHABRICATOR_USER';
|
|
|
|
const ENV_REMOTE_ADDRESS = 'PHABRICATOR_REMOTE_ADDRESS';
|
|
|
|
const ENV_REMOTE_PROTOCOL = 'PHABRICATOR_REMOTE_PROTOCOL';
|
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
const EMPTY_HASH = '0000000000000000000000000000000000000000';
|
|
|
|
|
2013-12-03 00:45:36 +01:00
|
|
|
private $viewer;
|
|
|
|
private $repository;
|
|
|
|
private $stdin;
|
2013-12-03 00:45:55 +01:00
|
|
|
private $subversionTransaction;
|
|
|
|
private $subversionRepository;
|
2013-12-05 20:59:22 +01:00
|
|
|
private $remoteAddress;
|
|
|
|
private $remoteProtocol;
|
2013-12-05 20:59:41 +01:00
|
|
|
private $transactionKey;
|
2013-12-05 20:59:22 +01:00
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
|
|
|
|
/* -( Config )------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
2013-12-05 20:59:22 +01:00
|
|
|
public function setRemoteProtocol($remote_protocol) {
|
|
|
|
$this->remoteProtocol = $remote_protocol;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRemoteProtocol() {
|
|
|
|
return $this->remoteProtocol;
|
|
|
|
}
|
2013-12-03 00:45:55 +01:00
|
|
|
|
2013-12-05 20:59:22 +01:00
|
|
|
public function setRemoteAddress($remote_address) {
|
|
|
|
$this->remoteAddress = $remote_address;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRemoteAddress() {
|
|
|
|
return $this->remoteAddress;
|
|
|
|
}
|
2013-12-03 00:45:55 +01:00
|
|
|
|
2013-12-05 20:59:41 +01:00
|
|
|
private function getRemoteAddressForLog() {
|
|
|
|
// If whatever we have here isn't a valid IPv4 address, just store `null`.
|
|
|
|
// Older versions of PHP return `-1` on failure instead of `false`.
|
|
|
|
$remote_address = $this->getRemoteAddress();
|
|
|
|
$remote_address = max(0, ip2long($remote_address));
|
|
|
|
$remote_address = nonempty($remote_address, null);
|
|
|
|
return $remote_address;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getTransactionKey() {
|
|
|
|
if (!$this->transactionKey) {
|
|
|
|
$entropy = Filesystem::readRandomBytes(64);
|
|
|
|
$this->transactionKey = PhabricatorHash::digestForIndex($entropy);
|
|
|
|
}
|
|
|
|
return $this->transactionKey;
|
|
|
|
}
|
|
|
|
|
2013-12-03 00:45:55 +01:00
|
|
|
public function setSubversionTransactionInfo($transaction, $repository) {
|
|
|
|
$this->subversionTransaction = $transaction;
|
|
|
|
$this->subversionRepository = $repository;
|
|
|
|
return $this;
|
|
|
|
}
|
2013-12-03 00:45:36 +01:00
|
|
|
|
|
|
|
public function setStdin($stdin) {
|
|
|
|
$this->stdin = $stdin;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getStdin() {
|
|
|
|
return $this->stdin;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setRepository(PhabricatorRepository $repository) {
|
|
|
|
$this->repository = $repository;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRepository() {
|
|
|
|
return $this->repository;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setViewer(PhabricatorUser $viewer) {
|
|
|
|
$this->viewer = $viewer;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getViewer() {
|
|
|
|
return $this->viewer;
|
|
|
|
}
|
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
|
|
|
|
/* -( Hook Execution )----------------------------------------------------- */
|
|
|
|
|
|
|
|
|
2013-12-03 00:45:36 +01:00
|
|
|
public function execute() {
|
2013-12-17 17:32:33 +01:00
|
|
|
$ref_updates = $this->findRefUpdates();
|
|
|
|
$all_updates = $ref_updates;
|
|
|
|
|
|
|
|
$caught = null;
|
|
|
|
try {
|
|
|
|
|
|
|
|
try {
|
|
|
|
$this->rejectDangerousChanges($ref_updates);
|
|
|
|
} catch (DiffusionCommitHookRejectException $ex) {
|
|
|
|
// If we're rejecting dangerous changes, flag everything that we've
|
|
|
|
// seen as rejected so it's clear that none of it was accepted.
|
|
|
|
foreach ($all_updates as $update) {
|
|
|
|
$update->setRejectCode(
|
|
|
|
PhabricatorRepositoryPushLog::REJECT_DANGEROUS);
|
|
|
|
}
|
|
|
|
throw $ex;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Fire ref herald rules.
|
|
|
|
|
|
|
|
$content_updates = $this->findContentUpdates($ref_updates);
|
|
|
|
$all_updates = array_merge($all_updates, $content_updates);
|
|
|
|
|
|
|
|
// TODO: Fire content Herald rules.
|
|
|
|
// TODO: Fire external hooks.
|
|
|
|
|
|
|
|
// If we make it this far, we're accepting these changes. Mark all the
|
|
|
|
// logs as accepted.
|
|
|
|
foreach ($all_updates as $update) {
|
|
|
|
$update->setRejectCode(PhabricatorRepositoryPushLog::REJECT_ACCEPT);
|
|
|
|
}
|
|
|
|
} catch (Exception $ex) {
|
|
|
|
// We'll throw this again in a minute, but we want to save all the logs
|
|
|
|
// first.
|
|
|
|
$caught = $ex;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save all the logs no matter what the outcome was.
|
|
|
|
foreach ($all_updates as $update) {
|
|
|
|
$update->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($caught) {
|
|
|
|
throw $caught;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function findRefUpdates() {
|
2013-12-03 00:45:36 +01:00
|
|
|
$type = $this->getRepository()->getVersionControlSystem();
|
|
|
|
switch ($type) {
|
|
|
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
|
2013-12-17 17:32:33 +01:00
|
|
|
return $this->findGitRefUpdates();
|
2013-12-03 00:46:03 +01:00
|
|
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
|
2013-12-17 17:32:33 +01:00
|
|
|
return $this->findMercurialRefUpdates();
|
|
|
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
|
|
|
return $this->findSubversionRefUpdates();
|
2013-12-03 00:45:36 +01:00
|
|
|
default:
|
|
|
|
throw new Exception(pht('Unsupported repository type "%s"!', $type));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
private function rejectDangerousChanges(array $ref_updates) {
|
|
|
|
assert_instances_of($ref_updates, 'PhabricatorRepositoryPushLog');
|
2013-12-03 00:45:36 +01:00
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
$repository = $this->getRepository();
|
|
|
|
if ($repository->shouldAllowDangerousChanges()) {
|
|
|
|
return;
|
|
|
|
}
|
2013-12-03 19:28:39 +01:00
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
$flag_dangerous = PhabricatorRepositoryPushLog::CHANGEFLAG_DANGEROUS;
|
2013-12-03 00:45:36 +01:00
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
foreach ($ref_updates as $ref_update) {
|
|
|
|
if (!$ref_update->hasChangeFlags($flag_dangerous)) {
|
|
|
|
// This is not a dangerous change.
|
|
|
|
continue;
|
|
|
|
}
|
2013-12-03 00:45:55 +01:00
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
// We either have a branch deletion or a non fast-forward branch update.
|
|
|
|
// Format a message and reject the push.
|
2013-12-03 00:45:55 +01:00
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
$message = pht(
|
|
|
|
"DANGEROUS CHANGE: %s\n".
|
|
|
|
"Dangerous change protection is enabled for this repository.\n".
|
|
|
|
"Edit the repository configuration before making dangerous changes.",
|
|
|
|
$ref_update->getDangerousChangeDescription());
|
2013-12-05 20:59:22 +01:00
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
throw new DiffusionCommitHookRejectException($message);
|
|
|
|
}
|
|
|
|
}
|
2013-12-05 20:56:14 +01:00
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
private function findContentUpdates(array $ref_updates) {
|
|
|
|
assert_instances_of($ref_updates, 'PhabricatorRepositoryPushLog');
|
2013-12-05 20:56:14 +01:00
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
$type = $this->getRepository()->getVersionControlSystem();
|
|
|
|
switch ($type) {
|
|
|
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
|
|
|
|
return $this->findGitContentUpdates($ref_updates);
|
|
|
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
|
|
|
|
return $this->findMercurialContentUpdates($ref_updates);
|
|
|
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
|
|
|
return $this->findSubversionContentUpdates($ref_updates);
|
|
|
|
default:
|
|
|
|
throw new Exception(pht('Unsupported repository type "%s"!', $type));
|
2013-12-05 20:56:14 +01:00
|
|
|
}
|
2013-12-17 17:32:33 +01:00
|
|
|
}
|
2013-12-05 20:56:14 +01:00
|
|
|
|
2013-12-05 20:59:41 +01:00
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
/* -( Git )---------------------------------------------------------------- */
|
2013-12-05 20:56:14 +01:00
|
|
|
|
2013-12-03 00:45:55 +01:00
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
private function findGitRefUpdates() {
|
|
|
|
$ref_updates = array();
|
2013-12-03 00:46:03 +01:00
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
// First, parse stdin, which lists all the ref changes. The input looks
|
|
|
|
// like this:
|
|
|
|
//
|
|
|
|
// <old hash> <new hash> <ref>
|
2013-12-03 00:45:36 +01:00
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
$stdin = $this->getStdin();
|
2013-12-03 00:45:36 +01:00
|
|
|
$lines = phutil_split_lines($stdin, $retain_endings = false);
|
|
|
|
foreach ($lines as $line) {
|
|
|
|
$parts = explode(' ', $line, 3);
|
|
|
|
if (count($parts) != 3) {
|
|
|
|
throw new Exception(pht('Expected "old new ref", got "%s".', $line));
|
|
|
|
}
|
2013-12-17 17:32:33 +01:00
|
|
|
|
|
|
|
$ref_old = $parts[0];
|
|
|
|
$ref_new = $parts[1];
|
|
|
|
$ref_raw = $parts[2];
|
|
|
|
|
|
|
|
if (preg_match('(^refs/heads/)', $ref_raw)) {
|
|
|
|
$ref_type = PhabricatorRepositoryPushLog::REFTYPE_BRANCH;
|
|
|
|
} else if (preg_match('(^refs/tags/)', $ref_raw)) {
|
|
|
|
$ref_type = PhabricatorRepositoryPushLog::REFTYPE_TAG;
|
2013-12-03 19:27:45 +01:00
|
|
|
} else {
|
2013-12-17 17:32:33 +01:00
|
|
|
$ref_type = PhabricatorRepositoryPushLog::REFTYPE_UNKNOWN;
|
2013-12-03 19:27:45 +01:00
|
|
|
}
|
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
$ref_update = $this->newPushLog()
|
|
|
|
->setRefType($ref_type)
|
|
|
|
->setRefName($ref_raw)
|
|
|
|
->setRefOld($ref_old)
|
|
|
|
->setRefNew($ref_new);
|
|
|
|
|
|
|
|
$ref_updates[] = $ref_update;
|
2013-12-03 19:27:45 +01:00
|
|
|
}
|
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
$this->findGitMergeBases($ref_updates);
|
|
|
|
$this->findGitChangeFlags($ref_updates);
|
2013-12-03 19:27:45 +01:00
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
return $ref_updates;
|
2013-12-03 19:27:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
private function findGitMergeBases(array $ref_updates) {
|
|
|
|
assert_instances_of($ref_updates, 'PhabricatorRepositoryPushLog');
|
2013-12-03 19:27:45 +01:00
|
|
|
|
|
|
|
$futures = array();
|
2013-12-17 17:32:33 +01:00
|
|
|
foreach ($ref_updates as $key => $ref_update) {
|
2013-12-03 19:27:45 +01:00
|
|
|
// If the old hash is "00000...", the ref is being created (either a new
|
|
|
|
// branch, or a new tag). If the new hash is "00000...", the ref is being
|
|
|
|
// deleted. If both are nonempty, the ref is being updated. For updates,
|
|
|
|
// we'll figure out the `merge-base` of the old and new objects here. This
|
|
|
|
// lets us reject non-FF changes cheaply; later, we'll figure out exactly
|
|
|
|
// which commits are new.
|
2013-12-17 17:32:33 +01:00
|
|
|
$ref_old = $ref_update->getRefOld();
|
|
|
|
$ref_new = $ref_update->getRefNew();
|
2013-12-03 19:27:45 +01:00
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
if (($ref_old === self::EMPTY_HASH) ||
|
|
|
|
($ref_new === self::EMPTY_HASH)) {
|
|
|
|
continue;
|
2013-12-03 19:27:45 +01:00
|
|
|
}
|
2013-12-17 17:32:33 +01:00
|
|
|
|
|
|
|
$futures[$key] = $this->getRepository()->getLocalCommandFuture(
|
|
|
|
'merge-base %s %s',
|
|
|
|
$ref_old,
|
|
|
|
$ref_new);
|
2013-12-03 19:27:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach (Futures($futures)->limit(8) as $key => $future) {
|
2013-12-11 23:46:46 +01:00
|
|
|
|
|
|
|
// If 'old' and 'new' have no common ancestors (for example, a force push
|
|
|
|
// which completely rewrites a ref), `git merge-base` will exit with
|
|
|
|
// an error and no output. It would be nice to find a positive test
|
|
|
|
// for this instead, but I couldn't immediately come up with one. See
|
|
|
|
// T4224. Assume this means there are no ancestors.
|
|
|
|
|
|
|
|
list($err, $stdout) = $future->resolve();
|
2013-12-17 17:32:33 +01:00
|
|
|
|
2013-12-11 23:46:46 +01:00
|
|
|
if ($err) {
|
2013-12-17 17:32:33 +01:00
|
|
|
$merge_base = null;
|
2013-12-11 23:46:46 +01:00
|
|
|
} else {
|
2013-12-17 17:32:33 +01:00
|
|
|
$merge_base = rtrim($stdout, "\n");
|
2013-12-11 23:46:46 +01:00
|
|
|
}
|
2013-12-17 17:32:33 +01:00
|
|
|
|
|
|
|
$ref_update->setMergeBase($merge_base);
|
2013-12-03 19:27:45 +01:00
|
|
|
}
|
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
return $ref_updates;
|
2013-12-03 19:27:45 +01:00
|
|
|
}
|
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
|
|
|
|
private function findGitChangeFlags(array $ref_updates) {
|
|
|
|
assert_instances_of($ref_updates, 'PhabricatorRepositoryPushLog');
|
|
|
|
|
|
|
|
foreach ($ref_updates as $key => $ref_update) {
|
|
|
|
$ref_old = $ref_update->getRefOld();
|
|
|
|
$ref_new = $ref_update->getRefNew();
|
|
|
|
$ref_type = $ref_update->getRefType();
|
|
|
|
|
|
|
|
$ref_flags = 0;
|
|
|
|
$dangerous = null;
|
|
|
|
|
|
|
|
if ($ref_old === self::EMPTY_HASH) {
|
|
|
|
$ref_flags |= PhabricatorRepositoryPushLog::CHANGEFLAG_ADD;
|
|
|
|
} else if ($ref_new === self::EMPTY_HASH) {
|
|
|
|
$ref_flags |= PhabricatorRepositoryPushLog::CHANGEFLAG_DELETE;
|
|
|
|
if ($ref_type == PhabricatorRepositoryPushLog::REFTYPE_BRANCH) {
|
|
|
|
$ref_flags |= PhabricatorRepositoryPushLog::CHANGEFLAG_DANGEROUS;
|
|
|
|
$dangerous = pht(
|
|
|
|
"The change you're attempting to push deletes the branch '%s'.",
|
|
|
|
$ref_update->getRefName());
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$merge_base = $ref_update->getMergeBase();
|
|
|
|
if ($merge_base == $ref_old) {
|
|
|
|
// This is a fast-forward update to an existing branch.
|
|
|
|
// These are safe.
|
|
|
|
$ref_flags |= PhabricatorRepositoryPushLog::CHANGEFLAG_APPEND;
|
|
|
|
} else {
|
|
|
|
$ref_flags |= PhabricatorRepositoryPushLog::CHANGEFLAG_REWRITE;
|
|
|
|
|
|
|
|
// For now, we don't consider deleting or moving tags to be a
|
|
|
|
// "dangerous" update. It's way harder to get wrong and should be easy
|
|
|
|
// to recover from once we have better logging. Only add the dangerous
|
|
|
|
// flag if this ref is a branch.
|
|
|
|
|
|
|
|
if ($ref_type == PhabricatorRepositoryPushLog::REFTYPE_BRANCH) {
|
|
|
|
$ref_flags |= PhabricatorRepositoryPushLog::CHANGEFLAG_DANGEROUS;
|
|
|
|
|
|
|
|
$dangerous = pht(
|
|
|
|
"DANGEROUS CHANGE: The change you're attempting to push updates ".
|
|
|
|
"the branch '%s' from '%s' to '%s', but this is not a ".
|
|
|
|
"fast-forward. Pushes which rewrite published branch history ".
|
|
|
|
"are dangerous.",
|
|
|
|
$ref_update->getRefName(),
|
|
|
|
$ref_update->getRefOldShort(),
|
|
|
|
$ref_update->getRefNewShort());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$ref_update->setChangeFlags($ref_flags);
|
|
|
|
if ($dangerous !== null) {
|
|
|
|
$ref_update->attachDangerousChangeDescription($dangerous);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $ref_updates;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private function findGitContentUpdates(array $ref_updates) {
|
|
|
|
$flag_delete = PhabricatorRepositoryPushLog::CHANGEFLAG_DELETE;
|
|
|
|
|
2013-12-03 19:27:45 +01:00
|
|
|
$futures = array();
|
2013-12-17 17:32:33 +01:00
|
|
|
foreach ($ref_updates as $key => $ref_update) {
|
|
|
|
if ($ref_update->hasChangeFlags($flag_delete)) {
|
2013-12-03 19:27:45 +01:00
|
|
|
// Deleting a branch or tag can never create any new commits.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: This piece of magic finds all new commits, by walking backward
|
|
|
|
// from the new value to the value of *any* existing ref in the
|
|
|
|
// repository. Particularly, this will cover the cases of a new branch, a
|
|
|
|
// completely moved tag, etc.
|
|
|
|
$futures[$key] = $this->getRepository()->getLocalCommandFuture(
|
|
|
|
'log --format=%s %s --not --all',
|
|
|
|
'%H',
|
2013-12-17 17:32:33 +01:00
|
|
|
$ref_update->getRefNew());
|
2013-12-03 19:27:45 +01:00
|
|
|
}
|
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
$content_updates = array();
|
2013-12-03 19:27:45 +01:00
|
|
|
foreach (Futures($futures)->limit(8) as $key => $future) {
|
|
|
|
list($stdout) = $future->resolvex();
|
2013-12-17 17:32:33 +01:00
|
|
|
|
|
|
|
if (!strlen(trim($stdout))) {
|
|
|
|
// This change doesn't have any new commits. One common case of this
|
|
|
|
// is creating a new tag which points at an existing commit.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-12-03 19:27:45 +01:00
|
|
|
$commits = phutil_split_lines($stdout, $retain_newlines = false);
|
2013-12-17 17:32:33 +01:00
|
|
|
|
|
|
|
foreach ($commits as $commit) {
|
|
|
|
$content_updates[$commit] = $this->newPushLog()
|
|
|
|
->setRefType(PhabricatorRepositoryPushLog::REFTYPE_COMMIT)
|
|
|
|
->setRefNew($commit)
|
|
|
|
->setChangeFlags(PhabricatorRepositoryPushLog::CHANGEFLAG_ADD);
|
|
|
|
}
|
2013-12-03 00:45:36 +01:00
|
|
|
}
|
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
return $content_updates;
|
2013-12-03 00:45:36 +01:00
|
|
|
}
|
|
|
|
|
2013-12-03 19:28:39 +01:00
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
/* -( Mercurial )---------------------------------------------------------- */
|
2013-12-03 19:28:39 +01:00
|
|
|
|
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
private function findMercurialRefUpdates() {
|
|
|
|
// TODO: Implement.
|
|
|
|
return array();
|
|
|
|
}
|
2013-12-03 19:28:39 +01:00
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
private function findMercurialContentUpdates(array $ref_updates) {
|
|
|
|
// TODO: Implement.
|
|
|
|
return array();
|
|
|
|
}
|
2013-12-03 19:28:39 +01:00
|
|
|
|
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
/* -( Subversion )--------------------------------------------------------- */
|
2013-12-03 19:28:39 +01:00
|
|
|
|
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
private function findSubversionRefUpdates() {
|
|
|
|
// TODO: Implement.
|
|
|
|
return array();
|
2013-12-03 19:28:39 +01:00
|
|
|
}
|
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
private function findSubversionContentUpdates(array $ref_updates) {
|
|
|
|
// TODO: Implement.
|
|
|
|
return array();
|
|
|
|
}
|
2013-12-03 19:27:45 +01:00
|
|
|
|
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
/* -( Internals )---------------------------------------------------------- */
|
2013-12-03 19:27:45 +01:00
|
|
|
|
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
private function newPushLog() {
|
|
|
|
// NOTE: By default, we create these with REJECT_BROKEN as the reject
|
|
|
|
// code. This indicates a broken hook, and covers the case where we
|
|
|
|
// encounter some unexpected exception and consequently reject the changes.
|
2013-12-03 19:27:45 +01:00
|
|
|
|
2013-12-17 17:32:33 +01:00
|
|
|
return PhabricatorRepositoryPushLog::initializeNewLog($this->getViewer())
|
|
|
|
->attachRepository($this->getRepository())
|
|
|
|
->setRepositoryPHID($this->getRepository()->getPHID())
|
|
|
|
->setEpoch(time())
|
|
|
|
->setRemoteAddress($this->getRemoteAddressForLog())
|
|
|
|
->setRemoteProtocol($this->getRemoteProtocol())
|
|
|
|
->setTransactionKey($this->getTransactionKey())
|
|
|
|
->setRejectCode(PhabricatorRepositoryPushLog::REJECT_BROKEN)
|
|
|
|
->setRejectDetails(null);
|
2013-12-03 19:27:45 +01:00
|
|
|
}
|
2013-12-17 17:32:33 +01:00
|
|
|
|
2013-12-03 00:45:36 +01:00
|
|
|
}
|