Search in sources :

Example 1 with RevCommitImpl

use of org.locationtech.geogig.api.RevCommitImpl in project GeoGig by boundlessgeo.

the class FormatCommonV1 method readCommit.

public static RevCommit readCommit(ObjectId id, DataInput in) throws IOException {
    byte tag = in.readByte();
    if (tag != COMMIT_TREE_REF) {
        throw new IllegalArgumentException("Commit should include a tree ref");
    }
    final byte[] treeIdBytes = new byte[20];
    in.readFully(treeIdBytes);
    final ObjectId treeId = ObjectId.createNoClone(treeIdBytes);
    final Builder<ObjectId> parentListBuilder = ImmutableList.builder();
    while (true) {
        tag = in.readByte();
        if (tag != COMMIT_PARENT_REF) {
            break;
        } else {
            final byte[] parentIdBytes = new byte[20];
            in.readFully(parentIdBytes);
            parentListBuilder.add(ObjectId.createNoClone(parentIdBytes));
        }
    }
    if (tag != COMMIT_AUTHOR_PREFIX) {
        throw new IllegalArgumentException("Expected AUTHOR element following parent ids in commit");
    }
    final RevPerson author = readRevPerson(in);
    tag = in.readByte();
    if (tag != COMMIT_COMMITTER_PREFIX) {
        throw new IllegalArgumentException("Expected COMMITTER element following author in commit");
    }
    final RevPerson committer = readRevPerson(in);
    final String message = in.readUTF();
    return new RevCommitImpl(id, treeId, parentListBuilder.build(), author, committer, message);
}
Also used : RevPerson(org.locationtech.geogig.api.RevPerson) ObjectId(org.locationtech.geogig.api.ObjectId) RevCommitImpl(org.locationtech.geogig.api.RevCommitImpl)

Example 2 with RevCommitImpl

use of org.locationtech.geogig.api.RevCommitImpl in project GeoGig by boundlessgeo.

the class FormatCommonV2 method readCommit.

public static RevCommit readCommit(ObjectId id, DataInput in) throws IOException {
    final ObjectId treeId = readObjectId(in);
    final int nParents = readUnsignedVarInt(in);
    final Builder<ObjectId> parentListBuilder = ImmutableList.builder();
    for (int i = 0; i < nParents; i++) {
        ObjectId parentId = readObjectId(in);
        parentListBuilder.add(parentId);
    }
    final RevPerson author = readRevPerson(in);
    final RevPerson committer = readRevPerson(in);
    final String message = in.readUTF();
    return new RevCommitImpl(id, treeId, parentListBuilder.build(), author, committer, message);
}
Also used : RevPerson(org.locationtech.geogig.api.RevPerson) ObjectId(org.locationtech.geogig.api.ObjectId) Integer.toBinaryString(java.lang.Integer.toBinaryString) RevCommitImpl(org.locationtech.geogig.api.RevCommitImpl)

Aggregations

ObjectId (org.locationtech.geogig.api.ObjectId)2 RevCommitImpl (org.locationtech.geogig.api.RevCommitImpl)2 RevPerson (org.locationtech.geogig.api.RevPerson)2 Integer.toBinaryString (java.lang.Integer.toBinaryString)1