Search in sources :

Example 16 with RevTag

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

the class LocalRemoteRepo method walkHead.

protected void walkHead(final ObjectId newHeadId, final boolean fetch, final ProgressListener progress) {
    Repository from = localRepository;
    Repository to = remoteGeoGig.getRepository();
    if (fetch) {
        Repository tmp = to;
        to = from;
        from = tmp;
    }
    final ObjectDatabase fromDb = from.objectDatabase();
    final ObjectDatabase toDb = to.objectDatabase();
    final RevObject object = fromDb.get(newHeadId);
    RevCommit commit = null;
    RevTag tag = null;
    if (object.getType().equals(TYPE.COMMIT)) {
        commit = (RevCommit) object;
    } else if (object.getType().equals(TYPE.TAG)) {
        tag = (RevTag) object;
        commit = fromDb.getCommit(tag.getCommitId());
    }
    if (commit != null) {
        final RevTree newTree = fromDb.getTree(commit.getTreeId());
        List<ObjectId> parentIds = new ArrayList<>(commit.getParentIds());
        if (parentIds.isEmpty()) {
            parentIds.add(ObjectId.NULL);
        }
        RevTree oldTree = RevTree.EMPTY;
        // the diff against each parent is not working. For some reason some buckets that are
        // equal between the two ends of the comparison never get transferred (at some point
        // they shouldn't be equal and so the Consumer notified of it/them). Yet with the target
        // databse exists check for each tree the performance is good enough.
        // for (ObjectId parentId : parentIds) {
        // if (!parentId.isNull()) {
        // RevCommit parent = fromDb.getCommit(parentId);
        // oldTree = fromDb.getTree(parent.getTreeId());
        // }
        copyNewObjects(oldTree, newTree, fromDb, toDb, progress);
        // }
        Preconditions.checkState(toDb.exists(newTree.getId()));
        toDb.put(commit);
    }
    if (tag != null) {
        toDb.put(tag);
    }
}
Also used : Repository(org.locationtech.geogig.repository.Repository) RevTag(org.locationtech.geogig.api.RevTag) ObjectDatabase(org.locationtech.geogig.storage.ObjectDatabase) RevObject(org.locationtech.geogig.api.RevObject) ObjectId(org.locationtech.geogig.api.ObjectId) ArrayList(java.util.ArrayList) RevTree(org.locationtech.geogig.api.RevTree) RevCommit(org.locationtech.geogig.api.RevCommit)

Aggregations

RevTag (org.locationtech.geogig.api.RevTag)16 ObjectId (org.locationtech.geogig.api.ObjectId)8 RevCommit (org.locationtech.geogig.api.RevCommit)8 RevObject (org.locationtech.geogig.api.RevObject)6 Test (org.junit.Test)4 Ref (org.locationtech.geogig.api.Ref)3 CommitOp (org.locationtech.geogig.api.porcelain.CommitOp)3 TagCreateOp (org.locationtech.geogig.api.porcelain.TagCreateOp)3 TagListOp (org.locationtech.geogig.api.porcelain.TagListOp)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Context (org.locationtech.geogig.api.Context)2 GeoGIG (org.locationtech.geogig.api.GeoGIG)2 RevPerson (org.locationtech.geogig.api.RevPerson)2 RevTagImpl (org.locationtech.geogig.api.RevTagImpl)2 RevTree (org.locationtech.geogig.api.RevTree)2 UpdateRef (org.locationtech.geogig.api.plumbing.UpdateRef)2 CommandContext (org.locationtech.geogig.web.api.CommandContext)2 CommandResponse (org.locationtech.geogig.web.api.CommandResponse)2 Optional (com.google.common.base.Optional)1