### Question:
VcsLogMultiRepoJoiner { @Nonnull public List<Commit> join(@Nonnull Collection<List<Commit>> logsFromRepos) { if (logsFromRepos.size() == 1) { return logsFromRepos.iterator().next(); } int size = 0; for (List<Commit> repo : logsFromRepos) { size += repo.size(); } List<Commit> result = new ArrayList<>(size); Map<Commit, Iterator<Commit>> nextCommits = ContainerUtil.newHashMap(); for (List<Commit> log : logsFromRepos) { Iterator<Commit> iterator = log.iterator(); if (iterator.hasNext()) { nextCommits.put(iterator.next(), iterator); } } while (!nextCommits.isEmpty()) { Commit lastCommit = findLatestCommit(nextCommits.keySet()); Iterator<Commit> iterator = nextCommits.get(lastCommit); result.add(lastCommit); nextCommits.remove(lastCommit); if (iterator.hasNext()) { nextCommits.put(iterator.next(), iterator); } } return result; }  @Nonnull List<Commit> join(@Nonnull Collection<List<Commit>> logsFromRepos);  }### Answer:
@Test public void joinTest() { List<? extends TimedVcsCommit> first = log("6|-a2|-a0", "3|-a1|-a0", "1|-a0|-"); List<? extends TimedVcsCommit> second = log("4|-b1|-b0", "2|-b0|-"); List<? extends TimedVcsCommit> third = log("7|-c1|-c0", "5|-c0|-"); List<TimedVcsCommit> expected = log("7|-c1|-c0", "6|-a2|-a0", "5|-c0|-", "4|-b1|-b0", "3|-a1|-a0", "2|-b0|-", "1|-a0|-"); List<? extends TimedVcsCommit> joined = new VcsLogMultiRepoJoiner().join(Arrays.asList(first, second, third)); assertEquals(expected, joined); }