Skip to content
Permalink
Browse files
Make fetchAll the opposite of pushAll
Reviewed-by: ehelin
  • Loading branch information
rwestberg committed Oct 22, 2020
1 parent bf1ab1e commit 975fe286706921feb5c9835df568c9316411d49b
@@ -269,7 +269,7 @@ private Repository cloneAndSyncFork(Path to) throws IOException {
}

// Must fetch once to update refs/heads
repo.fetchAll(false);
repo.fetchAllRemotes(false);

return repo;
}
@@ -89,7 +89,7 @@ public Collection<WorkItem> run(Path scratchPath) {

if (shouldMirrorEverything) {
log.info("Pulling " + from.name());
repo.fetchAll(false);
repo.fetchAll(from.url(), false);
log.info("Pushing to " + to.name());
repo.pushAll(to.url());
} else {
@@ -265,7 +265,7 @@ public Collection<WorkItem> run(Path scratchPath) {
.stream()
.filter(ref -> branches.matcher(ref.name()).matches())
.collect(Collectors.toList());
localRepo.fetchAll(true);
localRepo.fetchAll(repository.url(), true);

var history = UpdateHistory.create(tagStorageBuilder, historyPath.resolve("tags"), branchStorageBuilder, historyPath.resolve("branches"));
var errors = new ArrayList<Throwable>();
@@ -80,7 +80,7 @@ public Collection<WorkItem> run(Path scratchPath) {
.orElseThrow(() -> new RuntimeException("Repository in " + dir + " has vanished"));
}

repo.fetchAll(false);
repo.fetchAllRemotes(false);
var depsFile = repo.root().resolve(depsFileName);

var orderedBranches = orderedBranches(repo, depsFile);
@@ -95,7 +95,7 @@ private void refreshSeed(boolean allowStale) throws IOException {
IOException lastException = null;
for (int counter = 0; counter < 5; counter++) {
try {
seedRepo.fetch(hostedRepository.url(), "+*:*", true);
seedRepo.fetchAll(hostedRepository.url(), true);
} catch (IOException e) {
if (!allowStale) {
lastException = e;
@@ -45,10 +45,14 @@ default Hash fetch(URI uri, String refspec) throws IOException {
return fetch(uri, refspec, true);
}
Hash fetch(URI uri, String refspec, boolean includeTags) throws IOException;
default void fetchAll() throws IOException {
fetchAll(false);
default void fetchAll(URI uri) throws IOException {
fetchAll(uri, true);
}
void fetchAll(boolean includeTags) throws IOException;
void fetchAll(URI uri, boolean includeTags) throws IOException;
default void fetchAllRemotes() throws IOException {
fetchAllRemotes(false);
}
void fetchAllRemotes(boolean includeTags) throws IOException;
void fetchRemote(String remote) throws IOException;
void pushAll(URI uri) throws IOException;
void push(Hash hash, URI uri, String ref, boolean force) throws IOException;
@@ -469,7 +469,19 @@ public Hash fetch(URI uri, String refspec, boolean includeTags) throws IOExcepti
}

@Override
public void fetchAll(boolean includeTags) throws IOException {
public void fetchAll(URI uri, boolean includeTags) throws IOException {
var cmd = new ArrayList<>(List.of("git", "fetch", "--recurse-submodules=on-demand", "--prune", uri.toString()));
cmd.add("+refs/heads/*:refs/heads/*");
if (includeTags) {
cmd.add("+refs/tags/*:refs/tags/*");
}
try (var p = capture(cmd)) {
await(p);
}
}

@Override
public void fetchAllRemotes(boolean includeTags) throws IOException {
var cmd = new ArrayList<String>();
cmd.addAll(List.of("git", "fetch", "--recurse-submodules=on-demand"));
cmd.add("--prune");
@@ -448,6 +448,18 @@ public Hash fetch(URI uri, String refspec, boolean includeTags) throws IOExcepti
return fetch(uri != null ? uri.toString() : null, refspec);
}

@Override
public void fetchAll(URI uri, boolean includeTags) throws IOException {
// Ignore includeTags, Mercurial always fetches tags
var cmd = new ArrayList<String>();
cmd.add("hg");
cmd.add("pull");
cmd.add(uri.toString());
try (var p = capture(cmd)) {
await(p);
}
}

private Hash fetch(String from, String refspec) throws IOException {
var oldHeads = new HashSet<Hash>(heads());

@@ -478,7 +490,7 @@ private Hash fetch(String from, String refspec) throws IOException {
}

@Override
public void fetchAll(boolean includeTags) throws IOException {
public void fetchAllRemotes(boolean includeTags) throws IOException {
// Ignore includeTags, Mercurial always fetches tags
var pullPaths = new ArrayList<URI>();
try (var p = capture("hg", "paths")) {

2 comments on commit 975fe28

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 975fe28 Oct 22, 2020

Choose a reason for hiding this comment

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

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 975fe28 Oct 28, 2020

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.