/** * Executes the apply command, applying the given patch If it cannot be applied and no partial * application is allowed, a {@link CannotApplyPatchException} exception is thrown. Returns a * patch with rejected entries, in case partial application is allowed * * @return the modified {@link WorkingTree working tree}. */ @Override protected Patch _call() throws RuntimeException { Preconditions.checkArgument(patch != null, "No patch file provided"); VerifyPatchResults verify = command(VerifyPatchOp.class).setPatch(patch).setReverse(reverse) .call(); Patch toReject = verify.getToReject(); Patch toApply = verify.getToApply(); if (!applyPartial) { if (!toReject.isEmpty()) { throw new CannotApplyPatchException(toReject); } applyPatch(toApply); return null; } else { applyPatch(toApply); return toReject; } }
private RevFeatureType getType(ObjectId featureTypeId, Map<ObjectId, RevFeatureType> typeCache) { RevFeatureType type = typeCache.get(featureTypeId); if (null == type) { type = objectDatabase().getFeatureType(featureTypeId); typeCache.put(featureTypeId, type); } return type; }
path = diff.getPath(); String refSpec = Ref.WORK_HEAD + ":" + path; obj = command(RevObjectParse.class).setRefSpec(refSpec).call(); if (!obj.isPresent()) { toReject.addModifiedFeature(diff); DepthSearch depthSearch = new DepthSearch(objectDatabase()); Optional<NodeRef> noderef = depthSearch.find(workingTree().getTree(), path); RevFeatureType featureType = command(RevObjectParse.class) .setObjectId(noderef.get().getMetadataId()).call(RevFeatureType.class).get(); ImmutableList<PropertyDescriptor> descriptors = featureType.descriptors(); for (FeatureInfo feature : added) { String refSpec = Ref.WORK_HEAD + ":" + feature.getPath(); obj = command(RevObjectParse.class).setRefSpec(refSpec).call(); if (obj.isPresent()) { toReject.addAddedFeature(feature.getPath(), feature.getFeature(), getType(feature.getFeatureTypeId(), typeCache)); } else { toApply.addAddedFeature(feature.getPath(), feature.getFeature(), getType(feature.getFeatureTypeId(), typeCache)); for (FeatureInfo feature : removed) { String refSpec = Ref.WORK_HEAD + ":" + feature.getPath(); obj = command(RevObjectParse.class).setRefSpec(refSpec).call(); if (!obj.isPresent()) { toReject.addRemovedFeature(feature.getPath(), feature.getFeature(), getType(feature.getFeatureTypeId(), typeCache)); } else {
path = diff.getPath(); String refSpec = Ref.WORK_HEAD + ":" + path; obj = command(RevObjectParse.class).setRefSpec(refSpec).call(); if (!obj.isPresent()) { toReject.addModifiedFeature(diff); DepthSearch depthSearch = new DepthSearch(objectDatabase()); Optional<NodeRef> noderef = depthSearch.find(workingTree().getTree(), path); RevFeatureType featureType = command(RevObjectParse.class) .setObjectId(noderef.get().getMetadataId()).call(RevFeatureType.class).get(); ImmutableList<PropertyDescriptor> descriptors = featureType.descriptors(); for (FeatureInfo feature : added) { String refSpec = Ref.WORK_HEAD + ":" + feature.getPath(); obj = command(RevObjectParse.class).setRefSpec(refSpec).call(); if (obj.isPresent()) { toReject.addAddedFeature(feature.getPath(), feature.getFeature(), getType(feature.getFeatureTypeId(), typeCache)); } else { toApply.addAddedFeature(feature.getPath(), feature.getFeature(), getType(feature.getFeatureTypeId(), typeCache)); for (FeatureInfo feature : removed) { String refSpec = Ref.WORK_HEAD + ":" + feature.getPath(); obj = command(RevObjectParse.class).setRefSpec(refSpec).call(); if (!obj.isPresent()) { toReject.addRemovedFeature(feature.getPath(), feature.getFeature(), getType(feature.getFeatureTypeId(), typeCache)); } else {
/** * Executes the apply command, applying the given patch If it cannot be applied and no partial * application is allowed, a {@link CannotApplyPatchException} exception is thrown. Returns a * patch with rejected entries, in case partial application is allowed * * @return the modified {@link WorkingTree working tree}. */ @Override protected Patch _call() throws RuntimeException { Preconditions.checkArgument(patch != null, "No patch file provided"); VerifyPatchResults verify = command(VerifyPatchOp.class).setPatch(patch).setReverse(reverse) .call(); Patch toReject = verify.getToReject(); Patch toApply = verify.getToApply(); if (!applyPartial) { if (!toReject.isEmpty()) { throw new CannotApplyPatchException(toReject); } applyPatch(toApply); return null; } else { applyPatch(toApply); return toReject; } }
private RevFeatureType getType(ObjectId featureTypeId, Map<ObjectId, RevFeatureType> typeCache) { RevFeatureType type = typeCache.get(featureTypeId); if (null == type) { type = objectDatabase().getFeatureType(featureTypeId); typeCache.put(featureTypeId, type); } return type; }
Closeables.closeQuietly(stream); VerifyPatchResults verify = cli.getGeogig().command(VerifyPatchOp.class).setPatch(patch) .setReverse(reverse).call(); Patch toReject = verify.getToReject(); Patch toApply = verify.getToApply();
Closeables.closeQuietly(stream); VerifyPatchResults verify = cli.getGeogig().command(VerifyPatchOp.class).setPatch(patch) .setReverse(reverse).call(); Patch toReject = verify.getToReject(); Patch toApply = verify.getToApply();
Closeables.closeQuietly(stream); VerifyPatchResults verify = cli.getGeogig().command(VerifyPatchOp.class).setPatch(patch) .setReverse(reverse).call(); Patch toReject = verify.getToReject(); Patch toApply = verify.getToApply();