Search in sources :

Example 96 with RevCommit

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

the class FetchOpTest method testFetchNewRefWithShallowClone.

@Test
public void testFetchNewRefWithShallowClone() throws Exception {
    // Commit several features to the remote
    expectedMaster = new LinkedList<RevCommit>();
    expectedBranch = new LinkedList<RevCommit>();
    insertAndAdd(remoteGeogig.geogig, points1);
    RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call();
    RevCommit originCommit = commit;
    expectedMaster.addFirst(commit);
    expectedBranch.addFirst(commit);
    insertAndAdd(remoteGeogig.geogig, lines1);
    commit = remoteGeogig.geogig.command(CommitOp.class).call();
    expectedMaster.addFirst(commit);
    insertAndAdd(remoteGeogig.geogig, lines2);
    commit = remoteGeogig.geogig.command(CommitOp.class).call();
    expectedMaster.addFirst(commit);
    // Make sure master has all of the commits
    Iterator<RevCommit> logs = remoteGeogig.geogig.command(LogOp.class).call();
    List<RevCommit> logged = Lists.newArrayList(logs);
    assertEquals(expectedMaster, logged);
    // clone the repository
    CloneOp clone = clone();
    clone.setDepth(2);
    clone.setRepositoryURL(remoteGeogig.envHome.getCanonicalPath()).call();
    // Create and checkout branch1
    remoteGeogig.geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName("Branch1").setSource(originCommit.getId().toString()).call();
    // Commit some changes to branch1
    insertAndAdd(remoteGeogig.geogig, points2);
    commit = remoteGeogig.geogig.command(CommitOp.class).call();
    expectedBranch.addFirst(commit);
    insertAndAdd(remoteGeogig.geogig, points3);
    commit = remoteGeogig.geogig.command(CommitOp.class).call();
    expectedBranch.addFirst(commit);
    // Make sure Branch1 has all of the commits
    logs = remoteGeogig.geogig.command(LogOp.class).call();
    logged = Lists.newArrayList(logs);
    assertEquals(expectedBranch, logged);
    FetchOp fetch = fetch();
    fetch.call();
    // Make sure the local repository got all of the commits from master
    localGeogig.geogig.command(CheckoutOp.class).setSource("refs/remotes/origin/master").call();
    logs = localGeogig.geogig.command(LogOp.class).call();
    logged = Lists.newArrayList(logs);
    assertEquals(2, logged.size());
    assertEquals(expectedMaster.get(0), logged.get(0));
    assertEquals(expectedMaster.get(1), logged.get(1));
    // Make sure the local repository got all of the commits from Branch1
    localGeogig.geogig.command(CheckoutOp.class).setSource("refs/remotes/origin/Branch1").call();
    logs = localGeogig.geogig.command(LogOp.class).call();
    logged = Lists.newArrayList(logs);
    assertEquals(2, logged.size());
    assertEquals(expectedBranch.get(0), logged.get(0));
    assertEquals(expectedBranch.get(1), logged.get(1));
}
Also used : CloneOp(org.locationtech.geogig.api.porcelain.CloneOp) FetchOp(org.locationtech.geogig.api.porcelain.FetchOp) LogOp(org.locationtech.geogig.api.porcelain.LogOp) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 97 with RevCommit

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

the class FetchOpTest method testFetchDepth.

@Test
public void testFetchDepth() throws Exception {
    prepareForFetch(false);
    // clone the repository
    CloneOp clone = clone();
    clone.setDepth(2);
    String repositoryURL = remoteGeogig.envHome.getCanonicalPath();
    clone.setRepositoryURL(repositoryURL).call();
    FetchOp fetch = fetch();
    fetch.setDepth(3);
    fetch.call();
    // Make sure the local repository got all of the commits from master
    localGeogig.geogig.command(CheckoutOp.class).setSource("refs/remotes/origin/master").call();
    Iterator<RevCommit> logs = localGeogig.geogig.command(LogOp.class).call();
    List<RevCommit> logged = Lists.newArrayList(logs);
    assertEquals(3, logged.size());
    assertEquals(expectedMaster.get(0), logged.get(0));
    assertEquals(expectedMaster.get(1), logged.get(1));
    assertEquals(expectedMaster.get(2), logged.get(2));
    // Make sure the local repository got all of the commits from Branch1
    localGeogig.geogig.command(CheckoutOp.class).setSource("refs/remotes/origin/Branch1").call();
    logs = localGeogig.geogig.command(LogOp.class).call();
    logged = Lists.newArrayList(logs);
    assertEquals(3, logged.size());
    assertEquals(expectedBranch.get(0), logged.get(0));
    assertEquals(expectedBranch.get(1), logged.get(1));
    assertEquals(expectedBranch.get(2), logged.get(2));
}
Also used : CloneOp(org.locationtech.geogig.api.porcelain.CloneOp) FetchOp(org.locationtech.geogig.api.porcelain.FetchOp) LogOp(org.locationtech.geogig.api.porcelain.LogOp) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 98 with RevCommit

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

the class FetchOpTest method testFetchNewCommitsWithShallowClone2.

@Test
public void testFetchNewCommitsWithShallowClone2() throws Exception {
    insertAndAdd(remoteGeogig.geogig, points1);
    RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).setMessage("1").call();
    insertAndAdd(remoteGeogig.geogig, points2);
    commit = remoteGeogig.geogig.command(CommitOp.class).setMessage("2").call();
    insertAndAdd(remoteGeogig.geogig, points3);
    commit = remoteGeogig.geogig.command(CommitOp.class).setMessage("3").call();
    // clone the repository
    CloneOp clone = clone();
    clone.setDepth(2);
    clone.setRepositoryURL(remoteGeogig.envHome.getCanonicalPath()).call();
    // Checkout master and commit some changes
    remoteGeogig.geogig.command(CheckoutOp.class).setSource("master").call();
    insertAndAdd(remoteGeogig.geogig, lines1);
    commit = remoteGeogig.geogig.command(CommitOp.class).setMessage("4").call();
    insertAndAdd(remoteGeogig.geogig, points1_modified);
    commit = remoteGeogig.geogig.command(CommitOp.class).setMessage("5").call();
    insertAndAdd(remoteGeogig.geogig, lines2);
    commit = remoteGeogig.geogig.command(CommitOp.class).setMessage("6").call();
    insertAndAdd(remoteGeogig.geogig, lines3);
    commit = remoteGeogig.geogig.command(CommitOp.class).setMessage("7").call();
    FetchOp fetch = fetch();
    // fetch.setDepth(2);
    fetch.call();
    localGeogig.geogig.command(CheckoutOp.class).setSource("refs/remotes/origin/master").call();
    Iterator<RevCommit> logs = localGeogig.geogig.command(LogOp.class).call();
    List<RevCommit> logged = Lists.newArrayList(logs);
    // Should have the previous 2 commits, plus all 4 new commits.
    assertEquals(6, logged.size());
}
Also used : CloneOp(org.locationtech.geogig.api.porcelain.CloneOp) FetchOp(org.locationtech.geogig.api.porcelain.FetchOp) LogOp(org.locationtech.geogig.api.porcelain.LogOp) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 99 with RevCommit

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

the class CloneOpTest method testCloneWithTags.

@Test
public void testCloneWithTags() throws Exception {
    // Commit several features to the remote
    List<Feature> features = Arrays.asList(points1, lines1, points2, lines2, points3, lines3);
    LinkedList<RevCommit> expected = new LinkedList<RevCommit>();
    List<RevTag> tags = Lists.newArrayList();
    for (Feature f : features) {
        ObjectId oId = insertAndAdd(remoteGeogig.geogig, f);
        final RevCommit commit = remoteGeogig.geogig.command(CommitOp.class).call();
        expected.addFirst(commit);
        Optional<RevObject> childObject = remoteGeogig.geogig.command(RevObjectParse.class).setObjectId(oId).call();
        assertTrue(childObject.isPresent());
        RevTag tag = remoteGeogig.geogig.command(TagCreateOp.class).setCommitId(commit.getId()).setName(f.getIdentifier().getID()).call();
        tags.add(tag);
    }
    // Make sure the remote has all of the commits
    Iterator<RevCommit> logs = remoteGeogig.geogig.command(LogOp.class).call();
    List<RevCommit> logged = new ArrayList<RevCommit>();
    for (; logs.hasNext(); ) {
        logged.add(logs.next());
    }
    assertEquals(expected, logged);
    // Make sure the remote has all of the tags
    ImmutableList<RevTag> remoteTags = remoteGeogig.geogig.command(TagListOp.class).call();
    assertEquals(tags.size(), remoteTags.size());
    for (RevTag tag : tags) {
        assertTrue(remoteTags.contains(tag));
    }
    // Make sure the local repository has no commits prior to clone
    logs = localGeogig.geogig.command(LogOp.class).call();
    assertNotNull(logs);
    assertFalse(logs.hasNext());
    // clone from the remote
    CloneOp clone = clone();
    clone.setDepth(0);
    clone.setRepositoryURL(remoteGeogig.envHome.getCanonicalPath()).call();
    // Make sure the local repository got all of the commits
    logs = localGeogig.geogig.command(LogOp.class).call();
    logged = new ArrayList<RevCommit>();
    for (; logs.hasNext(); ) {
        logged.add(logs.next());
    }
    assertEquals(expected, logged);
/*
         * This is commented out, since the clone operation does not clone tags yet This test
         * verifies that no errors are raised when the repo to clone contains tags, but not to
         * verify that tags are also cloned, since that is not supported
         * 
         * I leave this dommented code here, to uncomment it once tag support is implemented for the
         * clone operation
         * 
         * 
         * // Make sure the local repository got all of the tags
         * 
         * ImmutableList<RevTag> localTags = localGeogig.geogig.command(TagListOp.class).call();
         * 
         * assertEquals(tags.size(), localTags.size());
         * 
         * for (RevTag tag : tags) {
         * 
         * assertTrue(localTags.contains(tag));
         * 
         * }
         */
}
Also used : CloneOp(org.locationtech.geogig.api.porcelain.CloneOp) RevTag(org.locationtech.geogig.api.RevTag) ObjectId(org.locationtech.geogig.api.ObjectId) RevObject(org.locationtech.geogig.api.RevObject) LogOp(org.locationtech.geogig.api.porcelain.LogOp) ArrayList(java.util.ArrayList) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) Feature(org.opengis.feature.Feature) LinkedList(java.util.LinkedList) TagListOp(org.locationtech.geogig.api.porcelain.TagListOp) TagCreateOp(org.locationtech.geogig.api.porcelain.TagCreateOp) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 100 with RevCommit

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

the class DiffOpTest method testSingleDeletion.

@Test
public void testSingleDeletion() throws Exception {
    final ObjectId featureContentId = insertAndAdd(points1);
    final RevCommit addCommit = geogig.command(CommitOp.class).setAll(true).call();
    assertTrue(deleteAndAdd(points1));
    final RevCommit deleteCommit = geogig.command(CommitOp.class).setAll(true).call();
    List<DiffEntry> difflist = toList(diffOp.setOldVersion(addCommit.getId()).setNewVersion(deleteCommit.getId()).call());
    final String path = NodeRef.appendChild(pointsName, points1.getIdentifier().getID());
    assertNotNull(difflist);
    assertEquals(1, difflist.size());
    DiffEntry de = difflist.get(0);
    assertEquals(path, de.oldPath());
    assertEquals(DiffEntry.ChangeType.REMOVED, de.changeType());
    assertEquals(featureContentId, de.oldObjectId());
    assertEquals(ObjectId.NULL, de.newObjectId());
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) RevCommit(org.locationtech.geogig.api.RevCommit) DiffEntry(org.locationtech.geogig.api.plumbing.diff.DiffEntry) Test(org.junit.Test)

Aggregations

RevCommit (org.locationtech.geogig.api.RevCommit)291 Test (org.junit.Test)212 ObjectId (org.locationtech.geogig.api.ObjectId)109 CommitOp (org.locationtech.geogig.api.porcelain.CommitOp)107 LogOp (org.locationtech.geogig.api.porcelain.LogOp)86 Ref (org.locationtech.geogig.api.Ref)71 Feature (org.opengis.feature.Feature)52 NodeRef (org.locationtech.geogig.api.NodeRef)47 ArrayList (java.util.ArrayList)44 BranchCreateOp (org.locationtech.geogig.api.porcelain.BranchCreateOp)44 RevTree (org.locationtech.geogig.api.RevTree)36 SymRef (org.locationtech.geogig.api.SymRef)33 RefParse (org.locationtech.geogig.api.plumbing.RefParse)33 DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)31 RevObject (org.locationtech.geogig.api.RevObject)30 UpdateRef (org.locationtech.geogig.api.plumbing.UpdateRef)30 MergeScenarioReport (org.locationtech.geogig.api.plumbing.merge.MergeScenarioReport)30 UpdateSymRef (org.locationtech.geogig.api.plumbing.UpdateSymRef)26 LinkedList (java.util.LinkedList)24 AddOp (org.locationtech.geogig.api.porcelain.AddOp)21