Skip to content

Commit

Permalink
checkout: simplify conversion logic
Browse files Browse the repository at this point in the history
Reviewed-by: rwestberg
  • Loading branch information
edvbld committed Jan 21, 2021
1 parent fa6ac0e commit 9d572d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
Expand Up @@ -136,22 +136,15 @@ public Collection<WorkItem> run(Path scratch) {
new IllegalStateException("Repository vanished from " + to));
var existing = new ArrayList<>(marks.current());
log.info("Found " + existing.size() + " existing marks");

var convertedGitHashes = existing.stream().map(Mark::git).collect(Collectors.toSet());
var gitHead = fromRepo.head();
if (!convertedGitHashes.contains(gitHead)) {
log.info("Found Git commits that needs to be converted. Git HEAD: " + gitHead.hex());
Collections.sort(existing);
converter.convert(fromRepo, toRepo, existing);
hasConverted = true;
} else {
log.info("No new Git commits to convert");
}
converter.convert(fromRepo, toRepo, existing);
hasConverted = true;
}
} finally {
if (hasConverted) {
log.info("Storing " + converter.marks().size() + " marks");
marks.put(converter.marks());
} else {
log.info("No conversion has taken place, not updating marks");
}
}
} catch (IOException e) {
Expand Down
Expand Up @@ -194,8 +194,8 @@ private void convertTags(Repository hgRepo, ReadOnlyRepository gitRepo, Map<Hash
var gitHash = gitRepo.resolve(name).orElseThrow(() ->
new IOException("Cannot resolve known tag " + name)
);
if (!gitRepo.isAncestor(gitBranchHead, gitHash)) {
// The tag is referring to a commit on another branch
if (!gitRepo.isAncestor(gitHash, gitBranchHead)) {
log.info("Tag " + name + " refers to a commit not present on branch " + branch.name());
continue;
}
var hgHash = gitToHg.get(gitHash);
Expand Down

1 comment on commit 9d572d7

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.