@Override public void runInternal(GeogigCLI cli) throws IOException { checkParameter(commits.size() == 2, "Two commit references must be provided"); Console console = cli.getConsole(); GeoGIG geogig = cli.getGeogig(); Optional<RevObject> left = geogig.command(RevObjectParse.class).setRefSpec(commits.get(0)) .call(); checkParameter(left.isPresent(), commits.get(0) + " does not resolve to any object."); checkParameter(left.get() instanceof RevCommit, commits.get(0) + " does not resolve to a commit"); Optional<RevObject> right = geogig.command(RevObjectParse.class).setRefSpec(commits.get(1)) .call(); checkParameter(right.isPresent(), commits.get(1) + " does not resolve to any object."); checkParameter(right.get() instanceof RevCommit, commits.get(1) + " does not resolve to a commit"); Optional<ObjectId> ancestor = geogig.command(FindCommonAncestor.class) .setLeft((RevCommit) left.get()).setRight((RevCommit) right.get()).call(); checkParameter(ancestor.isPresent(), "No common ancestor was found."); console.print(ancestor.get().toString()); }
@Override public void runInternal(GeogigCLI cli) throws IOException { checkParameter(commits.size() == 2, "Two commit references must be provided"); Console console = cli.getConsole(); GeoGIG geogig = cli.getGeogig(); Optional<RevObject> left = geogig.command(RevObjectParse.class).setRefSpec(commits.get(0)) .call(); checkParameter(left.isPresent(), commits.get(0) + " does not resolve to any object."); checkParameter(left.get() instanceof RevCommit, commits.get(0) + " does not resolve to a commit"); Optional<RevObject> right = geogig.command(RevObjectParse.class).setRefSpec(commits.get(1)) .call(); checkParameter(right.isPresent(), commits.get(1) + " does not resolve to any object."); checkParameter(right.get() instanceof RevCommit, commits.get(1) + " does not resolve to a commit"); Optional<ObjectId> ancestor = geogig.command(FindCommonAncestor.class) .setLeft((RevCommit) left.get()).setRight((RevCommit) right.get()).call(); checkParameter(ancestor.isPresent(), "No common ancestor was found."); console.print(ancestor.get().toString()); }
@Override public void runInternal(GeogigCLI cli) throws IOException { checkParameter(commits.size() == 2, "Two commit references must be provided"); Console console = cli.getConsole(); GeoGIG geogig = cli.getGeogig(); Optional<RevObject> left = geogig.command(RevObjectParse.class).setRefSpec(commits.get(0)) .call(); checkParameter(left.isPresent(), commits.get(0) + " does not resolve to any object."); checkParameter(left.get() instanceof RevCommit, commits.get(0) + " does not resolve to a commit"); Optional<RevObject> right = geogig.command(RevObjectParse.class).setRefSpec(commits.get(1)) .call(); checkParameter(right.isPresent(), commits.get(1) + " does not resolve to any object."); checkParameter(right.get() instanceof RevCommit, commits.get(1) + " does not resolve to a commit"); Optional<ObjectId> ancestor = geogig.command(FindCommonAncestor.class) .setLeft((RevCommit) left.get()).setRight((RevCommit) right.get()).call(); checkParameter(ancestor.isPresent(), "No common ancestor was found."); console.print(ancestor.get().toString()); }
return Boolean.FALSE; Optional<ObjectId> ancestor = command(FindCommonAncestor.class).setLeft(commits.get(0)) .setRight(commits.get(1)).call(); Preconditions.checkState(ancestor.isPresent(), "No ancestor commit could be found."); for (int i = 2; i < commits.size(); i++) { ancestor = command(FindCommonAncestor.class).setLeft(commits.get(i)) .setRightId(ancestor.get()).call(); Preconditions.checkState(ancestor.isPresent(), "No ancestor commit could be found.");
private void printRefspecs(Conflict conflict, Console console, GeoGIG geogig) throws IOException { ObjectId theirsHeadId = getTheirsHeadId(); Optional<RevCommit> theirsHead = geogig.command(RevObjectParse.class) .setObjectId(theirsHeadId).call(RevCommit.class); ObjectId oursHeadId = geogig.command(RefParse.class).setName(Ref.ORIG_HEAD).call().get() .getObjectId(); Optional<RevCommit> oursHead = geogig.command(RevObjectParse.class).setObjectId(oursHeadId) .call(RevCommit.class); Optional<ObjectId> commonAncestor = geogig.command(FindCommonAncestor.class) .setLeft(theirsHead.get()).setRight(oursHead.get()).call(); String ancestorPath = commonAncestor.get().toString() + ":" + conflict.getPath(); StringBuilder sb = new StringBuilder(); sb.append(conflict.getPath()); sb.append(" "); sb.append(ancestorPath); sb.append(" "); sb.append(oursHeadId.toString() + ":" + conflict.getPath()); sb.append(" "); sb.append(theirsHeadId.toString() + ":" + conflict.getPath()); console.println(sb.toString()); }
private void printRefspecs(Conflict conflict, Console console, GeoGIG geogig) throws IOException { ObjectId theirsHeadId = getTheirsHeadId(); Optional<RevCommit> theirsHead = geogig.command(RevObjectParse.class) .setObjectId(theirsHeadId).call(RevCommit.class); ObjectId oursHeadId = geogig.command(RefParse.class).setName(Ref.ORIG_HEAD).call().get() .getObjectId(); Optional<RevCommit> oursHead = geogig.command(RevObjectParse.class).setObjectId(oursHeadId) .call(RevCommit.class); Optional<ObjectId> commonAncestor = geogig.command(FindCommonAncestor.class) .setLeft(theirsHead.get()).setRight(oursHead.get()).call(); String ancestorPath = commonAncestor.get().toString() + ":" + conflict.getPath(); StringBuilder sb = new StringBuilder(); sb.append(conflict.getPath()); sb.append(" "); sb.append(ancestorPath); sb.append(" "); sb.append(oursHeadId.toString() + ":" + conflict.getPath()); sb.append(" "); sb.append(theirsHeadId.toString() + ":" + conflict.getPath()); console.println(sb.toString()); }
private void printRefspecs(Conflict conflict, Console console, GeoGIG geogig) throws IOException { ObjectId theirsHeadId = getTheirsHeadId(); Optional<RevCommit> theirsHead = geogig.command(RevObjectParse.class) .setObjectId(theirsHeadId).call(RevCommit.class); ObjectId oursHeadId = geogig.command(RefParse.class).setName(Ref.ORIG_HEAD).call().get() .getObjectId(); Optional<RevCommit> oursHead = geogig.command(RevObjectParse.class).setObjectId(oursHeadId) .call(RevCommit.class); Optional<ObjectId> commonAncestor = geogig.command(FindCommonAncestor.class) .setLeft(theirsHead.get()).setRight(oursHead.get()).call(); String ancestorPath = commonAncestor.get().toString() + ":" + conflict.getPath(); StringBuilder sb = new StringBuilder(); sb.append(conflict.getPath()); sb.append(" "); sb.append(ancestorPath); sb.append(" "); sb.append(oursHeadId.toString() + ":" + conflict.getPath()); sb.append(" "); sb.append(theirsHeadId.toString() + ":" + conflict.getPath()); console.println(sb.toString()); }
return Boolean.FALSE; Optional<ObjectId> ancestor = command(FindCommonAncestor.class).setLeft(commits.get(0)) .setRight(commits.get(1)).call(); Preconditions.checkState(ancestor.isPresent(), "No ancestor commit could be found."); for (int i = 2; i < commits.size(); i++) { ancestor = command(FindCommonAncestor.class).setLeft(commits.get(i)) .setRightId(ancestor.get()).call(); Preconditions.checkState(ancestor.isPresent(), "No ancestor commit could be found.");
private void printConflictDiff(Conflict conflict, Console console, GeoGIG geogig) throws IOException { FullDiffPrinter diffPrinter = new FullDiffPrinter(false, true); console.println("---" + conflict.getPath() + "---"); ObjectId theirsHeadId = getTheirsHeadId(); Optional<RevCommit> theirsHead = geogig.command(RevObjectParse.class) .setObjectId(theirsHeadId).call(RevCommit.class); ObjectId oursHeadId = geogig.command(RefParse.class).setName(Ref.ORIG_HEAD).call().get() .getObjectId(); Optional<RevCommit> oursHead = geogig.command(RevObjectParse.class).setObjectId(oursHeadId) .call(RevCommit.class); Optional<ObjectId> commonAncestor = geogig.command(FindCommonAncestor.class) .setLeft(theirsHead.get()).setRight(oursHead.get()).call(); String ancestorPath = commonAncestor.get().toString() + ":" + conflict.getPath(); Optional<NodeRef> ancestorNodeRef = geogig.command(FeatureNodeRefFromRefspec.class) .setRefspec(ancestorPath).call(); String path = Ref.ORIG_HEAD + ":" + conflict.getPath(); Optional<NodeRef> oursNodeRef = geogig.command(FeatureNodeRefFromRefspec.class) .setRefspec(path).call(); DiffEntry diffEntry = new DiffEntry(ancestorNodeRef.orNull(), oursNodeRef.orNull()); console.println("Ours"); diffPrinter.print(geogig, console, diffEntry); path = theirsHeadId + ":" + conflict.getPath(); Optional<NodeRef> theirsNodeRef = geogig.command(FeatureNodeRefFromRefspec.class) .setRefspec(path).call(); diffEntry = new DiffEntry(ancestorNodeRef.orNull(), theirsNodeRef.orNull()); console.println("Theirs"); diffPrinter.print(geogig, console, diffEntry); }
private void printConflictDiff(Conflict conflict, Console console, GeoGIG geogig) throws IOException { FullDiffPrinter diffPrinter = new FullDiffPrinter(false, true); console.println("---" + conflict.getPath() + "---"); ObjectId theirsHeadId = getTheirsHeadId(); Optional<RevCommit> theirsHead = geogig.command(RevObjectParse.class) .setObjectId(theirsHeadId).call(RevCommit.class); ObjectId oursHeadId = geogig.command(RefParse.class).setName(Ref.ORIG_HEAD).call().get() .getObjectId(); Optional<RevCommit> oursHead = geogig.command(RevObjectParse.class).setObjectId(oursHeadId) .call(RevCommit.class); Optional<ObjectId> commonAncestor = geogig.command(FindCommonAncestor.class) .setLeft(theirsHead.get()).setRight(oursHead.get()).call(); String ancestorPath = commonAncestor.get().toString() + ":" + conflict.getPath(); Optional<NodeRef> ancestorNodeRef = geogig.command(FeatureNodeRefFromRefspec.class) .setRefspec(ancestorPath).call(); String path = Ref.ORIG_HEAD + ":" + conflict.getPath(); Optional<NodeRef> oursNodeRef = geogig.command(FeatureNodeRefFromRefspec.class) .setRefspec(path).call(); DiffEntry diffEntry = new DiffEntry(ancestorNodeRef.orNull(), oursNodeRef.orNull()); console.println("Ours"); diffPrinter.print(geogig, console, diffEntry); path = theirsHeadId + ":" + conflict.getPath(); Optional<NodeRef> theirsNodeRef = geogig.command(FeatureNodeRefFromRefspec.class) .setRefspec(path).call(); diffEntry = new DiffEntry(ancestorNodeRef.orNull(), theirsNodeRef.orNull()); console.println("Theirs"); diffPrinter.print(geogig, console, diffEntry); }
private void printConflictDiff(Conflict conflict, Console console, GeoGIG geogig) throws IOException { FullDiffPrinter diffPrinter = new FullDiffPrinter(false, true); console.println("---" + conflict.getPath() + "---"); ObjectId theirsHeadId = getTheirsHeadId(); Optional<RevCommit> theirsHead = geogig.command(RevObjectParse.class) .setObjectId(theirsHeadId).call(RevCommit.class); ObjectId oursHeadId = geogig.command(RefParse.class).setName(Ref.ORIG_HEAD).call().get() .getObjectId(); Optional<RevCommit> oursHead = geogig.command(RevObjectParse.class).setObjectId(oursHeadId) .call(RevCommit.class); Optional<ObjectId> commonAncestor = geogig.command(FindCommonAncestor.class) .setLeft(theirsHead.get()).setRight(oursHead.get()).call(); String ancestorPath = commonAncestor.get().toString() + ":" + conflict.getPath(); Optional<NodeRef> ancestorNodeRef = geogig.command(FeatureNodeRefFromRefspec.class) .setRefspec(ancestorPath).call(); String path = Ref.ORIG_HEAD + ":" + conflict.getPath(); Optional<NodeRef> oursNodeRef = geogig.command(FeatureNodeRefFromRefspec.class) .setRefspec(path).call(); DiffEntry diffEntry = new DiffEntry(ancestorNodeRef.orNull(), oursNodeRef.orNull()); console.println("Ours"); diffPrinter.print(geogig, console, diffEntry); path = theirsHeadId + ":" + conflict.getPath(); Optional<NodeRef> theirsNodeRef = geogig.command(FeatureNodeRefFromRefspec.class) .setRefspec(path).call(); diffEntry = new DiffEntry(ancestorNodeRef.orNull(), theirsNodeRef.orNull()); console.println("Theirs"); diffPrinter.print(geogig, console, diffEntry); }
@Override protected MergeScenarioReport _call() { if (consumer == null) { consumer = new MergeScenarioConsumer(); } final Optional<ObjectId> ancestorOpt = command(FindCommonAncestor.class).setLeft(toMerge) .setRight(mergeInto).call(); Preconditions.checkState(ancestorOpt.isPresent(), "No ancestor commit could be found."); final ObjectId ancestor = ancestorOpt.get(); MergeScenarioReport report = null; try (AutoCloseableIterator<DiffEntry> mergeIntoDiffs = command(DiffTree.class) .setOldTree(ancestor).setReportTrees(true).setNewTree(mergeInto.getId()) .setPreserveIterationOrder(true).call(); AutoCloseableIterator<DiffEntry> toMergeDiffs = command(DiffTree.class) .setOldTree(ancestor).setReportTrees(true).setNewTree(toMerge.getId()) .setPreserveIterationOrder(true).call();) { Iterator<MergeDiffRef> tupleIterator = new MergeDiffIterator(mergeIntoDiffs, toMergeDiffs); final RevCommit ancestorCommit = objectDatabase().getCommit(ancestor); final RevTree ancestorTree = objectDatabase().getTree(ancestorCommit.getTreeId()); report = process(tupleIterator, ancestorTree); } return report; }
@Override protected MergeScenarioReport _call() { if (consumer == null) { consumer = new MergeScenarioConsumer(); } final Optional<ObjectId> ancestorOpt = command(FindCommonAncestor.class).setLeft(toMerge) .setRight(mergeInto).call(); Preconditions.checkState(ancestorOpt.isPresent(), "No ancestor commit could be found."); final ObjectId ancestor = ancestorOpt.get(); MergeScenarioReport report = null; try (AutoCloseableIterator<DiffEntry> mergeIntoDiffs = command(DiffTree.class) .setOldTree(ancestor).setReportTrees(true).setNewTree(mergeInto.getId()) .setPreserveIterationOrder(true).call(); AutoCloseableIterator<DiffEntry> toMergeDiffs = command(DiffTree.class) .setOldTree(ancestor).setReportTrees(true).setNewTree(toMerge.getId()) .setPreserveIterationOrder(true).call();) { Iterator<MergeDiffRef> tupleIterator = new MergeDiffIterator(mergeIntoDiffs, toMergeDiffs); final RevCommit ancestorCommit = objectDatabase().getCommit(ancestor); final RevTree ancestorTree = objectDatabase().getTree(ancestorCommit.getTreeId()); report = process(tupleIterator, ancestorTree); } return report; }
@Override protected void writeError(StreamingWriter w, Throwable cause) throws StreamWriterException { if (cause instanceof GeopkgMergeConflictsException) { Context context = cmd.getContext(); GeopkgMergeConflictsException m = (GeopkgMergeConflictsException) cause; final RevCommit ours = context.repository().getCommit(m.getOurs()); final RevCommit theirs = context.repository().getCommit(m.getTheirs()); final Optional<ObjectId> ancestor = context.command(FindCommonAncestor.class) .setLeft(ours).setRight(theirs).call(); PagedMergeScenarioConsumer consumer = new PagedMergeScenarioConsumer(0); final MergeScenarioReport report = context.command(ReportMergeScenarioOp.class) .setMergeIntoCommit(ours).setToMergeCommit(theirs).setConsumer(consumer) .call(); ResponseWriter out = new ResponseWriter(w, getMediaType()); Optional<RevCommit> mergeCommit = Optional.absent(); w.writeStartElement("result"); out.writeMergeConflictsResponse(mergeCommit, report, context, ours.getId(), theirs.getId(), ancestor.get(), consumer); w.writeStartElement("import"); writeImportResult(m.importResult, w, out); w.writeEndElement(); w.writeEndElement(); } else { super.writeError(w, cause); } }
final RevCommit theirs = context.getRepository().getCommit(m.getTheirs()); final Optional<ObjectId> ancestor = transaction.command(FindCommonAncestor.class) .setLeft(ours).setRight(theirs).call(); final PagedMergeScenarioConsumer consumer = new PagedMergeScenarioConsumer(0); final MergeScenarioReport report = transaction.command(ReportMergeScenarioOp.class)
.call(); Optional<ObjectId> commonAncestor = geogig.command(FindCommonAncestor.class).setLeft(left) .setRight(right).call();
.call(); Optional<ObjectId> commonAncestor = geogig.command(FindCommonAncestor.class).setLeft(left) .setRight(right).call();
.call(); Optional<ObjectId> commonAncestor = geogig.command(FindCommonAncestor.class).setLeft(left) .setRight(right).call();
.call(); Optional<ObjectId> commonAncestor = geogig.command(FindCommonAncestor.class).setLeft(left) .setRight(right).call();
.setLeft(mergeReport.getMergeCommit()).setRight(branch2).call();