@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

Richard van Velzen and committed by
epriestley
28fcb571 ba81aa1d

+30 -2
+29 -1
src/applications/repository/engine/PhabricatorRepositoryMirrorEngine.php
··· 55 55 56 56 $this->log(pht('Pushing to remote "%s"...', $mirror->getRemoteURI())); 57 57 58 - if (!$proxy->isGit()) { 58 + if ($proxy->isGit()) { 59 + $this->pushToGitRepository($proxy); 60 + } else if ($proxy->isHg()) { 61 + $this->pushToHgRepository($proxy); 62 + } else { 59 63 throw new Exception(pht('Unsupported VCS!')); 60 64 } 65 + } 66 + 67 + private function pushToGitRepository( 68 + PhabricatorRepository $proxy) { 61 69 62 70 $future = $proxy->getRemoteCommandFuture( 63 71 'push --verbose --mirror -- %P', ··· 66 74 $future 67 75 ->setCWD($proxy->getLocalPath()) 68 76 ->resolvex(); 77 + } 78 + 79 + private function pushToHgRepository( 80 + PhabricatorRepository $proxy) { 81 + 82 + $future = $proxy->getRemoteCommandFuture( 83 + 'push --verbose --rev tip -- %P', 84 + $proxy->getRemoteURIEnvelope()); 85 + 86 + try { 87 + $future 88 + ->setCWD($proxy->getLocalPath()) 89 + ->resolvex(); 90 + } catch (CommandException $ex) { 91 + if (preg_match('/no changes found/', $ex->getStdOut())) { 92 + // mercurial says nothing changed, but that's good 93 + } else { 94 + throw $ex; 95 + } 96 + } 69 97 } 70 98 71 99 }
+1 -1
src/applications/repository/storage/PhabricatorRepository.php
··· 1038 1038 } 1039 1039 1040 1040 public function canMirror() { 1041 - if ($this->isGit()) { 1041 + if ($this->isGit() || $this->isHg()) { 1042 1042 return true; 1043 1043 } 1044 1044