Support Mercurial pretxnchangegroup hooks
Summary: Ref T4189. Fixes T2066. Mercurial has a //lot// of hooks so I'm not 100% sure this is all we need to install (we may need separate hooks for tags/bookmarks) but it should cover most of what we're after at least. Test Plan: - `bin/repository pull`'d a Mercurial repo and got a hook install. - Pushed to a Mercurial repository over SSH and HTTP, with good/bad hooks. Saw hooks fire. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2066, T4189 Differential Revision: https://secure.phabricator.com/D7685
This commit is contained in:
@@ -406,7 +406,9 @@ final class DiffusionServeController extends DiffusionController {
|
||||
return $user;
|
||||
}
|
||||
|
||||
private function serveMercurialRequest(PhabricatorRepository $repository) {
|
||||
private function serveMercurialRequest(
|
||||
PhabricatorRepository $repository,
|
||||
PhabricatorUser $viewer) {
|
||||
$request = $this->getRequest();
|
||||
|
||||
$bin = Filesystem::resolveBinary('hg');
|
||||
@@ -414,7 +416,9 @@ final class DiffusionServeController extends DiffusionController {
|
||||
throw new Exception("Unable to find `hg` in PATH!");
|
||||
}
|
||||
|
||||
$env = array();
|
||||
$env = array(
|
||||
'PHABRICATOR_USER' => $viewer->getUsername(),
|
||||
);
|
||||
$input = PhabricatorStartup::getRawInput();
|
||||
|
||||
$cmd = $request->getStr('cmd');
|
||||
|
||||
@@ -51,6 +51,9 @@ final class DiffusionCommitHookEngine extends Phobject {
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
||||
$err = $this->executeSubversionHook();
|
||||
break;
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
|
||||
$err = $this->executeMercurialHook();
|
||||
break;
|
||||
default:
|
||||
throw new Exception(pht('Unsupported repository type "%s"!', $type));
|
||||
}
|
||||
@@ -73,6 +76,13 @@ final class DiffusionCommitHookEngine extends Phobject {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function executeMercurialHook() {
|
||||
|
||||
// TODO: Here, too, useful things should be done.
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function parseGitUpdates($stdin) {
|
||||
$updates = array();
|
||||
|
||||
|
||||
@@ -42,7 +42,8 @@ final class DiffusionSSHMercurialServeWorkflow
|
||||
$command = csprintf('hg -R %s serve --stdio', $repository->getLocalPath());
|
||||
$command = PhabricatorDaemon::sudoCommandAsDaemonUser($command);
|
||||
|
||||
$future = new ExecFuture('%C', $command);
|
||||
$future = id(new ExecFuture('%C', $command))
|
||||
->setEnv($this->getEnvironment());
|
||||
|
||||
$io_channel = $this->getIOChannel();
|
||||
$protocol_channel = new DiffusionSSHMercurialWireClientProtocolChannel(
|
||||
|
||||
Reference in New Issue
Block a user