mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Add basic support for mirroring Mercurial repositories
Summary: Ref T4338. Mercurial exits with exit code 1 and "no changes found" in stdout when there's no changes. I've split up the `pushRepositoryToMirror` to make the code a tad more readable. It isn't perfect, but it works for me. Test Plan: pushed some changes to my hosted repo. Saw them appearing in the mirrored repo Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley CC: Korvin, epriestley, aran Maniphest Tasks: T4338 Differential Revision: https://secure.phabricator.com/D8107
This commit is contained in:
parent
ba81aa1dfe
commit
28fcb5711b
2 changed files with 30 additions and 2 deletions
|
@ -55,9 +55,17 @@ final class PhabricatorRepositoryMirrorEngine
|
|||
|
||||
$this->log(pht('Pushing to remote "%s"...', $mirror->getRemoteURI()));
|
||||
|
||||
if (!$proxy->isGit()) {
|
||||
if ($proxy->isGit()) {
|
||||
$this->pushToGitRepository($proxy);
|
||||
} else if ($proxy->isHg()) {
|
||||
$this->pushToHgRepository($proxy);
|
||||
} else {
|
||||
throw new Exception(pht('Unsupported VCS!'));
|
||||
}
|
||||
}
|
||||
|
||||
private function pushToGitRepository(
|
||||
PhabricatorRepository $proxy) {
|
||||
|
||||
$future = $proxy->getRemoteCommandFuture(
|
||||
'push --verbose --mirror -- %P',
|
||||
|
@ -68,4 +76,24 @@ final class PhabricatorRepositoryMirrorEngine
|
|||
->resolvex();
|
||||
}
|
||||
|
||||
private function pushToHgRepository(
|
||||
PhabricatorRepository $proxy) {
|
||||
|
||||
$future = $proxy->getRemoteCommandFuture(
|
||||
'push --verbose --rev tip -- %P',
|
||||
$proxy->getRemoteURIEnvelope());
|
||||
|
||||
try {
|
||||
$future
|
||||
->setCWD($proxy->getLocalPath())
|
||||
->resolvex();
|
||||
} catch (CommandException $ex) {
|
||||
if (preg_match('/no changes found/', $ex->getStdOut())) {
|
||||
// mercurial says nothing changed, but that's good
|
||||
} else {
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1038,7 +1038,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
|||
}
|
||||
|
||||
public function canMirror() {
|
||||
if ($this->isGit()) {
|
||||
if ($this->isGit() || $this->isHg()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue