@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.

When creating foreign stubs during SVN import, mark them imported

Summary: See <https://github.com/facebook/phabricator/issues/501>. I think the issue here is that we created a foreign stub for commit `X-1`, probably because commit `X` was created by running `svn cp y x`.

Test Plan: I'll write a separate test for this before I land it. Huge pain to test.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D8133

+61 -5
src/applications/repository/engine/__tests__/data/CHE.svn.tgz

This is a binary file and will not be displayed.

+57 -5
src/applications/repository/worker/__tests__/PhabricatorChangeParserTestCase.php
··· 1103 1103 pht('Artificial SVN root should fail.')); 1104 1104 } 1105 1105 1106 + public function testSubversionForeignStubsParser() { 1107 + $repository = $this->buildBareRepository('CHE'); 1108 + $repository->setDetail('svn-subpath', 'branch/'); 1106 1109 1107 - private function expectChanges( 1110 + id(new PhabricatorRepositoryPullEngine()) 1111 + ->setRepository($repository) 1112 + ->pullRepository(); 1113 + 1114 + id(new PhabricatorRepositoryDiscoveryEngine()) 1115 + ->setRepository($repository) 1116 + ->discoverCommits(); 1117 + 1118 + $viewer = PhabricatorUser::getOmnipotentUser(); 1119 + 1120 + $commits = id(new DiffusionCommitQuery()) 1121 + ->setViewer($viewer) 1122 + ->withRepositoryIDs(array($repository->getID())) 1123 + ->execute(); 1124 + 1125 + foreach ($commits as $commit) { 1126 + $this->parseCommit($repository, $commit); 1127 + } 1128 + 1129 + // As a side effect, we expect parsing these commits to have created 1130 + // foreign stubs of other commits. 1131 + 1132 + $commits = id(new DiffusionCommitQuery()) 1133 + ->setViewer($viewer) 1134 + ->withRepositoryIDs(array($repository->getID())) 1135 + ->execute(); 1136 + 1137 + $commits = mpull($commits, null, 'getCommitIdentifier'); 1138 + 1139 + $this->assertEqual( 1140 + true, 1141 + isset($commits['2']), 1142 + 'Expect rCHE2 to exist as a foreign stub.'); 1143 + 1144 + // The foreign stub should be marked imported. 1145 + 1146 + $commit = $commits['2']; 1147 + $this->assertEqual( 1148 + PhabricatorRepositoryCommit::IMPORTED_ALL, 1149 + (int)$commit->getImportStatus()); 1150 + } 1151 + 1152 + private function parseCommit( 1108 1153 PhabricatorRepository $repository, 1109 - array $commits, 1110 - array $expect) { 1154 + PhabricatorRepositoryCommit $commit) { 1111 1155 1112 1156 switch ($repository->getVersionControlSystem()) { 1113 1157 case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: ··· 1123 1167 throw new Exception(pht('No support yet.')); 1124 1168 } 1125 1169 1170 + $parser_object = newv($parser, array(array())); 1171 + return $parser_object->parseChangesForUnitTest($repository, $commit); 1172 + } 1173 + 1174 + private function expectChanges( 1175 + PhabricatorRepository $repository, 1176 + array $commits, 1177 + array $expect) { 1178 + 1126 1179 foreach ($commits as $commit) { 1127 1180 $commit_identifier = $commit->getCommitIdentifier(); 1128 1181 $expect_changes = idx($expect, $commit_identifier); ··· 1137 1190 $repository->getCallsign())); 1138 1191 } 1139 1192 1140 - $parser_object = newv($parser, array(array())); 1141 - $changes = $parser_object->parseChangesForUnitTest($repository, $commit); 1193 + $changes = $this->parseCommit($repository, $commit); 1142 1194 1143 1195 $path_map = id(new DiffusionPathQuery()) 1144 1196 ->withPathIDs(mpull($changes, 'getPathID'))
+4
src/applications/repository/worker/commitchangeparser/PhabricatorRepositorySvnCommitChangeParserWorker.php
··· 509 509 "Missing commits ({$need}) in a SVN repository which is not ". 510 510 "configured for subdirectory-only parsing!"); 511 511 } 512 + 512 513 foreach ($need as $foreign_commit) { 513 514 $commit = new PhabricatorRepositoryCommit(); 514 515 $commit->setRepositoryID($repository->getID()); 515 516 $commit->setCommitIdentifier($foreign_commit); 516 517 $commit->setEpoch(0); 518 + // Mark this commit as imported so it doesn't prevent the repository 519 + // from transitioning into the "Imported" state. 520 + $commit->setImportStatus(PhabricatorRepositoryCommit::IMPORTED_ALL); 517 521 $commit->save(); 518 522 519 523 $data = new PhabricatorRepositoryCommitData();