|
27 | 27 | import org.junit.jupiter.api.BeforeEach;
|
28 | 28 | import org.junit.jupiter.api.Test;
|
29 | 29 | import org.opengrok.indexer.condition.EnabledForRepository;
|
| 30 | +import org.opengrok.indexer.configuration.RuntimeEnvironment; |
30 | 31 | import org.opengrok.indexer.util.Executor;
|
31 | 32 | import org.opengrok.indexer.util.TestRepository;
|
32 | 33 |
|
|
44 | 45 | import static org.junit.jupiter.api.Assertions.assertNotNull;
|
45 | 46 | import static org.junit.jupiter.api.Assertions.assertNotSame;
|
46 | 47 | import static org.junit.jupiter.api.Assertions.assertThrows;
|
| 48 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
47 | 49 | import static org.opengrok.indexer.condition.RepositoryInstalled.Type.MERCURIAL;
|
48 | 50 |
|
49 | 51 | /**
|
@@ -314,7 +316,6 @@ public void testGetHistoryWithNoSuchRevision() throws Exception {
|
314 | 316 | assertThrows(HistoryException.class, () -> mr.getHistory(root, constructedRevision));
|
315 | 317 | }
|
316 | 318 |
|
317 |
| - // TODO: also for (renamed) file |
318 | 319 | @Test
|
319 | 320 | void testGetHistorySinceTillNullNull() throws Exception {
|
320 | 321 | File root = new File(repository.getSourceRoot(), "mercurial");
|
@@ -366,4 +367,20 @@ void testGetHistorySinceTillRevRev() throws Exception {
|
366 | 367 | collect(Collectors.toList());
|
367 | 368 | assertEquals(List.of(Arrays.copyOfRange(REVISIONS, 2, 7)), revisions);
|
368 | 369 | }
|
| 370 | + |
| 371 | + @Test |
| 372 | + void testGetHistoryRenamedFileTillRev() throws Exception { |
| 373 | + RuntimeEnvironment.getInstance().setHandleHistoryOfRenamedFiles(true); |
| 374 | + File root = new File(repository.getSourceRoot(), "mercurial"); |
| 375 | + File file = new File(root, "novel.txt"); |
| 376 | + assertTrue(file.exists() && file.isFile()); |
| 377 | + MercurialRepository hgRepo = (MercurialRepository) RepositoryFactory.getRepository(root); |
| 378 | + History history = hgRepo.getHistory(file, null, "7:db1394c05268"); |
| 379 | + assertNotNull(history); |
| 380 | + assertNotNull(history.getHistoryEntries()); |
| 381 | + assertEquals(5, history.getHistoryEntries().size()); |
| 382 | + List<String> revisions = history.getHistoryEntries().stream().map(HistoryEntry::getRevision). |
| 383 | + collect(Collectors.toList()); |
| 384 | + assertEquals(List.of(Arrays.copyOfRange(REVISIONS, 2, 7)), revisions); |
| 385 | + } |
369 | 386 | }
|
0 commit comments