private void rebuildGraph(Repository repo) { repo.command(RebuildGraphOp.class).call(); } }
/** * Executes the {@code RebuildGraphOp} operation. * * @return a list of {@link ObjectId}s that were found to be missing or incomplete */ @Override protected ImmutableList<ObjectId> _call() { Repository repository = repository(); Preconditions.checkState(!repository.isSparse(), "Cannot rebuild the graph of a sparse repository."); List<ObjectId> updated = new LinkedList<ObjectId>(); ImmutableList<Ref> branches = command(BranchListOp.class).setLocal(true).setRemotes(true) .call(); GraphDatabase graphDb = repository.graphDatabase(); for (Ref ref : branches) { Iterator<RevCommit> commits = command(LogOp.class).setUntil(ref.getObjectId()).call(); while (commits.hasNext()) { RevCommit next = commits.next(); if (graphDb.put(next.getId(), next.getParentIds())) { updated.add(next.getId()); } } } return ImmutableList.copyOf(updated); } }
/** * Runs the command and builds the appropriate response. * * @param context - the context to use for this command */ @Override protected void runInternal(CommandContext context) { final Context geogig = this.getRepositoryContext(context); final ImmutableList<ObjectId> updatedObjects = geogig.command(RebuildGraphOp.class).call(); context.setResponseContent(new CommandResponse() { @Override public void write(ResponseWriter out) throws Exception { out.start(); out.writeRebuildGraphResponse(updatedObjects, quiet); out.finish(); } }); } }
/** * Executes the {@code RebuildGraphOp} operation. * * @return a list of {@link ObjectId}s that were found to be missing or incomplete */ @Override protected ImmutableList<ObjectId> _call() { Repository repository = repository(); Preconditions.checkState(!repository.isSparse(), "Cannot rebuild the graph of a sparse repository."); List<ObjectId> updated = new LinkedList<ObjectId>(); ImmutableList<Ref> branches = command(BranchListOp.class).setLocal(true).setRemotes(true) .call(); GraphDatabase graphDb = repository.graphDatabase(); for (Ref ref : branches) { Iterator<RevCommit> commits = command(LogOp.class).setUntil(ref.getObjectId()).call(); while (commits.hasNext()) { RevCommit next = commits.next(); if (graphDb.put(next.getId(), next.getParentIds())) { updated.add(next.getId()); } } } return ImmutableList.copyOf(updated); } }
@Override public void runInternal(GeogigCLI cli) throws IOException { ImmutableList<ObjectId> updatedObjects = cli.getGeogig().command(RebuildGraphOp.class) .call(); final Console console = cli.getConsole(); if (updatedObjects.size() > 0) { if (quiet) { console.println(updatedObjects.size() + " graph elements (commits) were fixed."); } else { console.println("The following graph elements (commits) were incomplete or missing and have been fixed:"); for (ObjectId object : updatedObjects) { console.println(object.toString()); } } } else { console.println("No missing or incomplete graph elements (commits) were found."); } } }
@Override public void runInternal(GeogigCLI cli) throws IOException { ImmutableList<ObjectId> updatedObjects = cli.getGeogig().command(RebuildGraphOp.class) .call(); final Console console = cli.getConsole(); if (updatedObjects.size() > 0) { if (quiet) { console.println(updatedObjects.size() + " graph elements (commits) were fixed."); } else { console.println("The following graph elements (commits) were incomplete or missing and have been fixed:"); for (ObjectId object : updatedObjects) { console.println(object.toString()); } } } else { console.println("No missing or incomplete graph elements (commits) were found."); } } }
@Override public void runInternal(GeogigCLI cli) throws IOException { ImmutableList<ObjectId> updatedObjects = cli.getGeogig().command(RebuildGraphOp.class) .call(); final Console console = cli.getConsole(); if (updatedObjects.size() > 0) { if (quiet) { console.println(updatedObjects.size() + " graph elements (commits) were fixed."); } else { console.println("The following graph elements (commits) were incomplete or missing and have been fixed:"); for (ObjectId object : updatedObjects) { console.println(object.toString()); } } } else { console.println("No missing or incomplete graph elements (commits) were found."); } } }
ImmutableList<ObjectId> updated = geogig.command(RebuildGraphOp.class).call(); assertEquals(0, updated.size());
ImmutableList<ObjectId> updated = geogig.command(RebuildGraphOp.class).call(); assertEquals(0, updated.size());
ImmutableList<ObjectId> updated = geogig.command(RebuildGraphOp.class).call(); assertEquals(2, updated.size()); assertTrue(updated.contains(c1.getId()));
ImmutableList<ObjectId> updated = geogig.command(RebuildGraphOp.class).call(); assertEquals(4, updated.size()); assertTrue(updated.contains(c1.getId()));
ImmutableList<ObjectId> updated = geogig.command(RebuildGraphOp.class).call(); assertEquals(4, updated.size()); assertTrue(updated.contains(c1.getId()));
ImmutableList<ObjectId> updated = geogig.command(RebuildGraphOp.class).call(); assertEquals(2, updated.size()); assertTrue(updated.contains(c1.getId()));