@Override public boolean exists(ObjectId id) { return subject.get().exists(id); }
@Override public boolean exists(ObjectId id) { return subject.get().exists(id); }
/** * Test if a blob exists in the object database * * @param id the ID of the blob in the object database * @return true if the blob exists with the parameter ID, false otherwise */ @Override public boolean blobExists(final ObjectId id) { return context().objectDatabase().exists(id); }
private Optional<ObjectId> resolveAncestor(ObjectId objectId, int ancestorN) { GraphDatabase graph = graphDatabase(); ObjectId ancestor = objectId; for (int i = 0; i < ancestorN; i++) { ImmutableList<ObjectId> parents = graph.getParents(ancestor); if (parents.isEmpty()) { return Optional.absent(); } ancestor = parents.get(0);// use first parent } ObjectDatabase odb = objectDatabase(); if (!odb.exists(ancestor)) { // the ancestor might not exist in case the commit was the origin of a shallow clone ancestor = null; } return Optional.fromNullable(ancestor); }
/** * Test if a blob exists in the object database * * @param id the ID of the blob in the object database * @return true if the blob exists with the parameter ID, false otherwise */ @Override public boolean blobExists(final ObjectId id) { return context().objectDatabase().exists(id); }
private Optional<ObjectId> resolveAncestor(ObjectId objectId, int ancestorN) { GraphDatabase graph = graphDatabase(); ObjectId ancestor = objectId; for (int i = 0; i < ancestorN; i++) { ImmutableList<ObjectId> parents = graph.getParents(ancestor); if (parents.isEmpty()) { return Optional.absent(); } ancestor = parents.get(0);// use first parent } ObjectDatabase odb = objectDatabase(); if (!odb.exists(ancestor)) { // the ancestor might not exist in case the commit was the origin of a shallow clone ancestor = null; } return Optional.fromNullable(ancestor); }
/** * Determines if the provided object exists in the repository. * * @param objectId the object to look for * @return true if the object existed, false otherwise */ @Override public boolean objectExists(ObjectId objectId) { return objectId.isNull() || localRepository.objectDatabase().exists(objectId); }
/** * Determines if the provided object exists in the repository. * * @param objectId the object to look for * @return true if the object existed, false otherwise */ @Override public boolean objectExists(ObjectId objectId) { return objectId.isNull() || localRepository.objectDatabase().exists(objectId); }
private void verifyMetadata(Node node) { if (node.getMetadataId().isPresent()) { ObjectId mdId = node.getMetadataId().get(); String msg = "RevFeatureType " + mdId + " is not present (from " + node.getName() + ")"; assertTrue(msg, objectDb.exists(mdId)); } }
private void verifyMetadata(Node node) { if (node.getMetadataId().isPresent()) { ObjectId mdId = node.getMetadataId().get(); String msg = "RevFeatureType " + mdId + " is not present (from " + node.getName() + ")"; assertTrue(msg, objectDb.exists(mdId)); } }
private void verifyFeature(Node node) { ObjectId objectId = node.getObjectId(); assertTrue("feature " + node.getName() + " -> " + objectId + " is not present in objectDb", objectDb.exists(objectId)); }
private void verifyFeature(Node node) { ObjectId objectId = node.getObjectId(); assertTrue("feature " + node.getName() + " -> " + objectId + " is not present in objectDb", objectDb.exists(objectId)); }
private void walkTree(ObjectId treeId, ObjectDatabase source) { assertTrue(source.exists(treeId)); RevTree tree = source.getTree(treeId); for (Bucket b : tree.getBuckets()) { walkTree(b.getObjectId(), source); } } }
private void walkTree(ObjectId treeId, ObjectDatabase source) { assertTrue(source.exists(treeId)); RevTree tree = source.getTree(treeId); for (Bucket b : tree.buckets().values()) { walkTree(b.getObjectId(), source); } } }
@Test public void testSimple() { RevTree tree = createTree("blob"); NodeRef child = NodeRef.tree("subtree", tree.getId(), ObjectId.NULL); RevTree newRoot = context.command(UpdateTree.class).setRoot(RevTree.EMPTY).setChild(child) .call(); assertTrue(odb.exists(newRoot.getId())); Optional<NodeRef> ref = new DepthSearch(odb).find(newRoot.getId(), "subtree"); assertTrue(ref.isPresent()); assertEquals(child, ref.get()); }
@Test public void testSimple() { RevTree tree = createTree("blob"); NodeRef child = NodeRef.tree("subtree", tree.getId(), ObjectId.NULL); RevTree newRoot = context.command(UpdateTree.class).setRoot(RevTree.EMPTY).setChild(child) .call(); assertTrue(odb.exists(newRoot.getId())); Optional<NodeRef> ref = new DepthSearch(odb).find(newRoot.getId(), "subtree"); assertTrue(ref.isPresent()); assertEquals(child, ref.get()); }
@Test public void testSingleLevel() { RevTree tree = createTree("blob"); NodeRef level1 = NodeRef.tree("level1", tree.getId(), hashString("fake")); RevTree newRoot = context.command(UpdateTree.class).setRoot(RevTree.EMPTY).setChild(level1) .call(); assertTrue(odb.exists(newRoot.getId())); // created the intermediate tree node? Optional<NodeRef> ref; DepthSearch depthSearch = new DepthSearch(odb); ref = depthSearch.find(newRoot, "level1"); assertTrue(ref.isPresent()); ref = depthSearch.find(newRoot, "level1/blob"); assertTrue(ref.isPresent()); }
@Test public void testSingleLevel() { RevTree tree = createTree("blob"); NodeRef level1 = NodeRef.tree("level1", tree.getId(), hashString("fake")); RevTree newRoot = context.command(UpdateTree.class).setRoot(RevTree.EMPTY).setChild(level1) .call(); assertTrue(odb.exists(newRoot.getId())); // created the intermediate tree node? Optional<NodeRef> ref; DepthSearch depthSearch = new DepthSearch(odb); ref = depthSearch.find(newRoot, "level1"); assertTrue(ref.isPresent()); ref = depthSearch.find(newRoot, "level1/blob"); assertTrue(ref.isPresent()); }
@Test public void testSiblingsNested() { RevTree tree1 = createTree("blob"); RevTree tree2 = createTree("blob"); Preconditions.checkState(odb.isOpen()); NodeRef level2 = NodeRef.tree("subtree1/level2", tree1.getId(), hashString("tree1")); RevTree newRoot1 = context.command(UpdateTree.class).setRoot(RevTree.EMPTY).setChild(level2) .call(); assertTrue(odb.exists(newRoot1.getId())); NodeRef level3 = NodeRef.tree("subtree2/level2/level3", tree2.getId(), hashString("tree2")); RevTree newRoot2 = context.command(UpdateTree.class).setRoot(newRoot1).setChild(level3) .call(); // created the intermediate tree node? DepthSearch depthSearch = new DepthSearch(odb); assertTrue(depthSearch.find(newRoot2, "subtree1").isPresent()); assertTrue(depthSearch.find(newRoot2, "subtree1/level2").isPresent()); assertTrue(depthSearch.find(newRoot2, "subtree1/level2/blob").isPresent()); assertTrue(depthSearch.find(newRoot2, "subtree2").isPresent()); assertTrue(depthSearch.find(newRoot2, "subtree2/level2").isPresent()); assertTrue(depthSearch.find(newRoot2, "subtree2/level2/level3").isPresent()); assertTrue(depthSearch.find(newRoot2, "subtree2/level2/level3/blob").isPresent()); }
@Test public void testSiblingsNested() { RevTree tree1 = createTree("blob"); RevTree tree2 = createTree("blob"); Preconditions.checkState(odb.isOpen()); NodeRef level2 = NodeRef.tree("subtree1/level2", tree1.getId(), hashString("tree1")); RevTree newRoot1 = context.command(UpdateTree.class).setRoot(RevTree.EMPTY).setChild(level2) .call(); assertTrue(odb.exists(newRoot1.getId())); NodeRef level3 = NodeRef.tree("subtree2/level2/level3", tree2.getId(), hashString("tree2")); RevTree newRoot2 = context.command(UpdateTree.class).setRoot(newRoot1).setChild(level3) .call(); // created the intermediate tree node? DepthSearch depthSearch = new DepthSearch(odb); assertTrue(depthSearch.find(newRoot2, "subtree1").isPresent()); assertTrue(depthSearch.find(newRoot2, "subtree1/level2").isPresent()); assertTrue(depthSearch.find(newRoot2, "subtree1/level2/blob").isPresent()); assertTrue(depthSearch.find(newRoot2, "subtree2").isPresent()); assertTrue(depthSearch.find(newRoot2, "subtree2/level2").isPresent()); assertTrue(depthSearch.find(newRoot2, "subtree2/level2/level3").isPresent()); assertTrue(depthSearch.find(newRoot2, "subtree2/level2/level3/blob").isPresent()); }