mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-20 13:52:40 +01:00
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
This commit is contained in:
parent
cb605ad5ee
commit
e42a982445
3 changed files with 61 additions and 5 deletions
BIN
src/applications/repository/engine/__tests__/data/CHE.svn.tgz
Normal file
BIN
src/applications/repository/engine/__tests__/data/CHE.svn.tgz
Normal file
Binary file not shown.
|
@ -1103,11 +1103,55 @@ final class PhabricatorChangeParserTestCase
|
|||
pht('Artificial SVN root should fail.'));
|
||||
}
|
||||
|
||||
public function testSubversionForeignStubsParser() {
|
||||
$repository = $this->buildBareRepository('CHE');
|
||||
$repository->setDetail('svn-subpath', 'branch/');
|
||||
|
||||
private function expectChanges(
|
||||
id(new PhabricatorRepositoryPullEngine())
|
||||
->setRepository($repository)
|
||||
->pullRepository();
|
||||
|
||||
id(new PhabricatorRepositoryDiscoveryEngine())
|
||||
->setRepository($repository)
|
||||
->discoverCommits();
|
||||
|
||||
$viewer = PhabricatorUser::getOmnipotentUser();
|
||||
|
||||
$commits = id(new DiffusionCommitQuery())
|
||||
->setViewer($viewer)
|
||||
->withRepositoryIDs(array($repository->getID()))
|
||||
->execute();
|
||||
|
||||
foreach ($commits as $commit) {
|
||||
$this->parseCommit($repository, $commit);
|
||||
}
|
||||
|
||||
// As a side effect, we expect parsing these commits to have created
|
||||
// foreign stubs of other commits.
|
||||
|
||||
$commits = id(new DiffusionCommitQuery())
|
||||
->setViewer($viewer)
|
||||
->withRepositoryIDs(array($repository->getID()))
|
||||
->execute();
|
||||
|
||||
$commits = mpull($commits, null, 'getCommitIdentifier');
|
||||
|
||||
$this->assertEqual(
|
||||
true,
|
||||
isset($commits['2']),
|
||||
'Expect rCHE2 to exist as a foreign stub.');
|
||||
|
||||
// The foreign stub should be marked imported.
|
||||
|
||||
$commit = $commits['2'];
|
||||
$this->assertEqual(
|
||||
PhabricatorRepositoryCommit::IMPORTED_ALL,
|
||||
(int)$commit->getImportStatus());
|
||||
}
|
||||
|
||||
private function parseCommit(
|
||||
PhabricatorRepository $repository,
|
||||
array $commits,
|
||||
array $expect) {
|
||||
PhabricatorRepositoryCommit $commit) {
|
||||
|
||||
switch ($repository->getVersionControlSystem()) {
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
|
||||
|
@ -1123,6 +1167,15 @@ final class PhabricatorChangeParserTestCase
|
|||
throw new Exception(pht('No support yet.'));
|
||||
}
|
||||
|
||||
$parser_object = newv($parser, array(array()));
|
||||
return $parser_object->parseChangesForUnitTest($repository, $commit);
|
||||
}
|
||||
|
||||
private function expectChanges(
|
||||
PhabricatorRepository $repository,
|
||||
array $commits,
|
||||
array $expect) {
|
||||
|
||||
foreach ($commits as $commit) {
|
||||
$commit_identifier = $commit->getCommitIdentifier();
|
||||
$expect_changes = idx($expect, $commit_identifier);
|
||||
|
@ -1137,8 +1190,7 @@ final class PhabricatorChangeParserTestCase
|
|||
$repository->getCallsign()));
|
||||
}
|
||||
|
||||
$parser_object = newv($parser, array(array()));
|
||||
$changes = $parser_object->parseChangesForUnitTest($repository, $commit);
|
||||
$changes = $this->parseCommit($repository, $commit);
|
||||
|
||||
$path_map = id(new DiffusionPathQuery())
|
||||
->withPathIDs(mpull($changes, 'getPathID'))
|
||||
|
|
|
@ -509,11 +509,15 @@ final class PhabricatorRepositorySvnCommitChangeParserWorker
|
|||
"Missing commits ({$need}) in a SVN repository which is not ".
|
||||
"configured for subdirectory-only parsing!");
|
||||
}
|
||||
|
||||
foreach ($need as $foreign_commit) {
|
||||
$commit = new PhabricatorRepositoryCommit();
|
||||
$commit->setRepositoryID($repository->getID());
|
||||
$commit->setCommitIdentifier($foreign_commit);
|
||||
$commit->setEpoch(0);
|
||||
// Mark this commit as imported so it doesn't prevent the repository
|
||||
// from transitioning into the "Imported" state.
|
||||
$commit->setImportStatus(PhabricatorRepositoryCommit::IMPORTED_ALL);
|
||||
$commit->save();
|
||||
|
||||
$data = new PhabricatorRepositoryCommitData();
|
||||
|
|
Loading…
Reference in a new issue