/** * Constructs a new {@code LinearHistoryIterator} with the given parameters. * * @param tip the first commit in the history * @param repo the repository where the commits are stored. */ @SuppressWarnings("unchecked") public LinearHistoryIterator(final ObjectId tip, final Repository repo) { this.nextCommitId = (Optional<ObjectId>) (tip.isNull() ? Optional.absent() : Optional.of(tip)); this.repo = repo; }
@Override public String toString() { String revTreeId = originalTreeId.equals(RevTree.EMPTY_TREE_ID) ? "EMPTY" : originalTreeId.toString().substring(0, 8); return String.format( "DAG[id:%s, orig:%s, status: %s, size: %,d, children: %,d, buckets: %,d)[children: %s, buckets: %s]", id, revTreeId, state, childCount, children.size(), buckets.size(), children, buckets); }
@Override public void objectToEntry(@Nullable ObjectId object, TupleOutput output) { if (null == object || object.isNull()) { output.write(0); } else { output.write(ObjectId.NUM_BYTES); output.write(object.getRawValue()); } } }
@Test public void testToString() { ObjectId id1 = ObjectId.valueOf("abc123000000000000001234567890abcdef0000"); ObjectId id2 = ObjectId.valueOf("abc123000000000000001234567890abcdef0001"); ObjectId id3 = ObjectId.valueOf("abc123000000000000001234567890abcdef0002"); Conflict conflict = new Conflict("Points/1", id1, id2, id3); String conflictStr = conflict.toString(); assertTrue(conflictStr.contains("Points/1")); assertTrue(conflictStr.contains(id1.toString())); assertTrue(conflictStr.contains(id2.toString())); assertTrue(conflictStr.contains(id3.toString())); }
private void printObject(String name, ObjectId id, Console console, GeoGIG geogig) throws IOException { console.println(name + "\t" + id.toString()); if (!id.isNull()) { Optional<RevObject> obj = geogig.command(RevObjectParse.class).setObjectId(id).call(); CharSequence s = geogig.command(CatObject.class) .setObject(Suppliers.ofInstance(obj.get())).call(); console.println(s); } }
/** * @return whether or not this object id represents the {@link #NULL} object id */ public boolean isNull() { return NULL.equals(this); }
@Test public void testPutGetRef() { byte[] raw = new byte[20]; Arrays.fill(raw, (byte) 1); ObjectId oid = new ObjectId(raw); String value = refDb.getRef(Ref.MASTER); assertNull(value + " is not null", value); refDb.putRef(Ref.MASTER, oid.toString()); assertEquals(oid.toString(), refDb.getRef(Ref.MASTER)); refDb.putRef(Ref.WORK_HEAD, sampleId.toString()); assertEquals(sampleId.toString(), refDb.getRef(Ref.WORK_HEAD)); }
@Test public void testEquals() { ObjectId nullId = ObjectId.valueOf("0000000000000000000000000000000000000000"); ObjectId id1 = ObjectId.valueOf("abc123000000000000001234567890abcdef0000"); ObjectId id2 = ObjectId.valueOf("abc123000000000000001234567890abcdef0000"); assertNotSame(id1, id2); assertEquals(ObjectId.NULL, nullId); assertEquals(id1, id2); assertFalse(id1.equals(ObjectId.valueOf("abc123000000000000001234567890abcdef0001"))); assertFalse(id1.equals("blah")); }
/** * @return the id of the {@link RevObject} this Node points to */ public ObjectId getObjectId() { return ObjectId.create(objectId_h1, objectId_h2, objectId_h3); }
private static ObjectId id(@Nullable String partialHash) { if (partialHash == null) { return ObjectId.NULL; } partialHash = Strings.padEnd(partialHash, 2 * ObjectId.NUM_BYTES, '0'); return ObjectId.valueOf(partialHash); }
/** * @return a raw byte array of the hash code for this object id. Changes to the returned array * do not affect this object. */ public byte[] getRawValue() { byte[] raw = new byte[NUM_BYTES]; getRawValue(raw); return raw; }
@Test public void testGetRawValue() { ObjectId oid = ObjectId.valueOf("ff68b74766e20cca000000000000000000000000"); byte[] raw = new byte[ObjectId.NUM_BYTES]; oid.getRawValue(raw); byte[] oidRaw = oid.getRawValue(); for (int i = 0; i < ObjectId.NUM_BYTES; i++) { assertEquals(oidRaw[i], raw[i]); } }
public final static ObjectId readObjectId(DataInput in) throws IOException { byte[] bytes = new byte[ObjectId.NUM_BYTES]; in.readFully(bytes); return ObjectId.createNoClone(bytes); }
private static Node createNode(int i) { byte[] rawID = FAKE_ID.getRawValue(); String key = "Feature." + i; ObjectId id = new ObjectId(rawID); Envelope env = new Envelope(0, 0, i, i); Node ref = Node.create(key, id, FAKE_ID, TYPE.FEATURE, env); return ref; }
@Test public void testNodeAndNodeRefToString() { Node node = RevObjectFactory.defaultInstance().createNode("Points.1", ObjectId.valueOf("abc123000000000000001234567890abcdef0000"), ObjectId.NULL, TYPE.FEATURE, null, null); NodeRef nodeRef = new NodeRef(node, "Points", ObjectId.NULL); String readableNode = nodeRef.toString(); assertTrue(readableNode .equals("NodeRef[Points/Points.1 -> " + node.getObjectId().toString() + "]")); }
private void printObject(String name, ObjectId id, Console console, GeoGIG geogig) throws IOException { console.println(name + "\t" + id.toString()); if (!id.isNull()) { Optional<RevObject> obj = geogig.command(RevObjectParse.class).setObjectId(id).call(); CharSequence s = geogig.command(CatObject.class) .setObject(Suppliers.ofInstance(obj.get())).call(); console.println(s); } }
@Override public void objectToEntry(@Nullable ObjectId object, TupleOutput output) { if (null == object || object.isNull()) { output.write(0); } else { output.write(ObjectId.NUM_BYTES); output.write(object.getRawValue()); } } }
/** * Get the name of this object. * * @return unique hash of this object. */ public final ObjectId getId() { return ObjectId.create(h1, h2, h3); }